X-Git-Url: https://git.r.bdr.sh/rbdr/blog/blobdiff_plain/d7fef30ac3f539975ef9edbba8e0af4a4e9ff3de..b17907faf8d9693cef94a6048d802bd4ced9102f:/src/archiver/mod.rs?ds=sidebyside diff --git a/src/archiver/mod.rs b/src/archiver/mod.rs index 4631bcb..ba8dd69 100644 --- a/src/archiver/mod.rs +++ b/src/archiver/mod.rs @@ -2,7 +2,7 @@ mod gemini; mod gopher; mod raw; -use crate::template::{TemplateContext, TemplateValue}; +use crate::template::{Context, Value}; use std::collections::HashMap; use std::fs::read_dir; use std::io::Result; @@ -16,10 +16,10 @@ struct ArchiveEntry { slug: String, } -type Archiver = fn(&Path, &Path, &Path, &TemplateContext) -> Result<()>; +type Archiver = fn(&Path, &Path, &Path, &Context) -> Result<()>; impl ArchiveEntry { - pub fn to_template_context(archive_entries: &[ArchiveEntry]) -> TemplateContext { + pub fn to_template_context(archive_entries: &[ArchiveEntry]) -> Context { let mut context = HashMap::new(); let archive_entries_collection = archive_entries @@ -29,25 +29,25 @@ impl ArchiveEntry { context.insert( "archive_length".to_string(), - TemplateValue::Unsigned(archive_entries.len().try_into().unwrap()), + Value::Unsigned(archive_entries.len().try_into().unwrap()), ); context.insert( "posts".to_string(), - TemplateValue::Collection(archive_entries_collection), + Value::Collection(archive_entries_collection), ); context } - pub fn to_template_value(&self) -> TemplateContext { + pub fn to_template_value(&self) -> Context { let mut context = HashMap::new(); - context.insert("id".to_string(), TemplateValue::String(self.id.clone())); + context.insert("id".to_string(), Value::String(self.id.clone())); - context.insert("slug".to_string(), TemplateValue::String(self.slug.clone())); + context.insert("slug".to_string(), Value::String(self.slug.clone())); if let Some(title) = self.title() { - context.insert("title".to_string(), TemplateValue::String(title)); + context.insert("title".to_string(), Value::String(title)); } context