crabmail

Static HTML email archive viewer in Rust
git clone git://git.alexwennerberg.com/crabmail
Log | Files | Refs | README | LICENSE

commit f2eccd2993789c0274354e75a7abcee4d300280c
parent 3012d468cfc17cd969147e2412b729beaf25d3ae
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Sat, 12 Mar 2022 07:25:08 -0800

add gmi option

Diffstat:
Msrc/config.rs | 1+
Msrc/main.rs | 10++++++++--
Msrc/templates/gmi.rs | 13+++++++++++++
3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/src/config.rs b/src/config.rs @@ -27,6 +27,7 @@ pub struct Config { pub title_fmt: String, pub base_url: String, pub description: String, + pub include_gemini: bool, pub out_dir: PathBuf, // TODO rem pub relative_times: bool, // TODO rem pub include_raw: bool, // TODO rem diff --git a/src/main.rs b/src/main.rs @@ -42,7 +42,9 @@ impl Lists<'_> { write_if_unchanged(&self.out_dir.join("style.css"), css); let base_path = self.out_dir.join("index"); write_if_unchanged(&base_path.with_extension("html"), self.to_html().as_bytes()); - // write_if_unchanged(&base_path.with_extension("gmi"), self.to_gmi().as_bytes()); + if Config::global().include_gemini { + write_if_unchanged(&base_path.with_extension("gmi"), self.to_gmi().as_bytes()); + } for list in &self.lists { list.write_all_files() } @@ -95,7 +97,9 @@ impl List<'_> { thread.to_html().as_bytes(), ); write_if_unchanged(&basepath.with_extension("xml"), thread.to_xml().as_bytes()); - write_if_unchanged(&basepath.with_extension("gmi"), thread.to_gmi().as_bytes()); + if Config::global().include_gemini { + write_if_unchanged(&basepath.with_extension("gmi"), thread.to_gmi().as_bytes()); + } // Delete nonexistent messages (cache?) // for file in thread // write raw file @@ -107,6 +111,8 @@ fn main() -> Result<()> { let args = arg::Args::from_env(); let maildir = &args.positional[0]; let mut config = Config::from_file(&args.config)?; + // TODO cleanup + config.include_gemini = args.include_gemini; INSTANCE.set(config).unwrap(); let mut lists = Lists { diff --git a/src/templates/gmi.rs b/src/templates/gmi.rs @@ -1,4 +1,17 @@ use crate::models::*; +use nanotemplate::template; + +impl Lists<'_> { + pub fn to_gmi(&self) -> String { + template( + r#" + # Mail Archive + "#, + &[("title", "tbd")], + ) + .unwrap() + } +} impl Thread<'_> { pub fn to_gmi(&self) -> String {