]> git.r.bdr.sh - rbdr/blog/blame - src/archiver/gopher.rs
Make this created_on more readable
[rbdr/blog] / src / archiver / gopher.rs
CommitLineData
b17907fa 1use crate::template::{find, parse, Context};
6352ebb0 2use std::fs::write;
50f53dc4 3use std::io::{Error, ErrorKind::Other, Result};
d7fef30a 4use std::path::Path;
6352ebb0
RBR
5
6const FILENAME: &str = "index.gph";
7
d7fef30a
RBR
8pub fn archive(
9 _: &Path,
10 template_directory: &Path,
11 target: &Path,
b17907fa 12 context: &Context,
d7fef30a
RBR
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)?;
6352ebb0
RBR
20 }
21 Ok(())
22}