aboutsummaryrefslogtreecommitdiff
path: root/src/archiver
diff options
context:
space:
mode:
Diffstat (limited to 'src/archiver')
-rw-r--r--src/archiver/gemini.rs4
-rw-r--r--src/archiver/gopher.rs4
-rw-r--r--src/archiver/mod.rs18
-rw-r--r--src/archiver/raw.rs9
4 files changed, 15 insertions, 20 deletions
diff --git a/src/archiver/gemini.rs b/src/archiver/gemini.rs
index b74d27b..298ace8 100644
--- a/src/archiver/gemini.rs
+++ b/src/archiver/gemini.rs
@@ -1,4 +1,4 @@
-use crate::template::{find, parse, TemplateContext};
+use crate::template::{find, parse, Context};
use std::fs::write;
use std::io::{Error, ErrorKind::Other, Result};
use std::path::Path;
@@ -9,7 +9,7 @@ pub fn archive(
_: &Path,
template_directory: &Path,
target: &Path,
- context: &TemplateContext,
+ context: &Context,
) -> Result<()> {
if let Some(template) = find(template_directory, FILENAME) {
let parsed_template = parse(&template)
diff --git a/src/archiver/gopher.rs b/src/archiver/gopher.rs
index fc0c04f..454e8c4 100644
--- a/src/archiver/gopher.rs
+++ b/src/archiver/gopher.rs
@@ -1,4 +1,4 @@
-use crate::template::{find, parse, TemplateContext};
+use crate::template::{find, parse, Context};
use std::fs::write;
use std::io::{Error, ErrorKind::Other, Result};
use std::path::Path;
@@ -9,7 +9,7 @@ pub fn archive(
_: &Path,
template_directory: &Path,
target: &Path,
- context: &TemplateContext,
+ context: &Context,
) -> Result<()> {
if let Some(template) = find(template_directory, FILENAME) {
let parsed_template = parse(&template)
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
diff --git a/src/archiver/raw.rs b/src/archiver/raw.rs
index c3dc1cf..ce7ecb7 100644
--- a/src/archiver/raw.rs
+++ b/src/archiver/raw.rs
@@ -1,14 +1,9 @@
-use crate::template::TemplateContext;
+use crate::template::Context;
use crate::utils::recursively_copy;
use std::io::Result;
use std::path::Path;
-pub fn archive(
- archive_directory: &Path,
- _: &Path,
- target: &Path,
- _: &TemplateContext,
-) -> Result<()> {
+pub fn archive(archive_directory: &Path, _: &Path, target: &Path, _: &Context) -> Result<()> {
if archive_directory.exists() {
return recursively_copy(archive_directory, target);
}