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