]> git.r.bdr.sh - rbdr/blog/blob - src/archiver/gopher.rs
Make this created_on more readable
[rbdr/blog] / src / archiver / gopher.rs
1 use crate::template::{find, parse, Context};
2 use std::fs::write;
3 use std::io::{Error, ErrorKind::Other, Result};
4 use std::path::Path;
5
6 const FILENAME: &str = "index.gph";
7
8 pub fn archive(
9 _: &Path,
10 template_directory: &Path,
11 target: &Path,
12 context: &Context,
13 ) -> Result<()> {
14 if let Some(template) = find(template_directory, FILENAME) {
15 let parsed_template = parse(&template)
16 .ok_or_else(|| Error::new(Other, "Unable to parse Gopher Archive template"))?;
17 let rendered_template = parsed_template.render(context)?;
18 let location = target.join(FILENAME);
19 write(location, rendered_template)?;
20 }
21 Ok(())
22 }