diff --git a/src/feed_store.rs b/src/feed_store.rs index f63cc1d..0bde5d4 100644 --- a/src/feed_store.rs +++ b/src/feed_store.rs @@ -1,4 +1,4 @@ -use anyhow::{Result, bail}; +use anyhow::{bail, Result}; use camino::{Utf8Path, Utf8PathBuf}; use chrono::{DateTime, Duration, Utc}; use feed_rs::model::Entry; @@ -259,7 +259,7 @@ impl FeedStore { Err(e) => { warn!("Problem parsing feed file for feed {}: {}", feed_url, e); continue; - }, + } }; for entry in &mut feed.entries { diff --git a/src/main.rs b/src/main.rs index ec8058f..a1e7508 100644 --- a/src/main.rs +++ b/src/main.rs @@ -71,6 +71,11 @@ struct Config { max_entries: usize, /// How soon to refresh, in hours refresh: usize, + /// A theme to apply, if any. + /// + /// This is a folder in the templates_dir. If an assets directory + /// exists within, the contents will be copied over to the out_dir. + theme: Option, } pub fn to_checked_pathbuf(dir: &str) -> Utf8PathBuf { diff --git a/src/template_engine.rs b/src/template_engine.rs index 6da36c8..63582ab 100644 --- a/src/template_engine.rs +++ b/src/template_engine.rs @@ -2,13 +2,18 @@ use crate::feed_store::FeedStore; use crate::to_checked_pathbuf; use crate::Config; use anyhow::Result; +use camino::Utf8Path; use feed_rs::model::Feed; use std::collections::HashMap; use std::fs::File; use tera::{from_value, Tera}; pub fn build(config: &Config, feed_store: &mut FeedStore) -> Result<()> { - let mut tera = create_tera(&config.templates_dir)?; + let mut tera = if let Some(theme) = &config.theme { + create_tera(&config.templates_dir.join(theme))? + } else { + create_tera(&config.templates_dir)? + }; let out_dir = to_checked_pathbuf(&config.out_dir); let mut context = tera::Context::new();