crabmail

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

commit 680debddd3fd8340786b0f54542f1e03a0c269d3
parent 1645b5b4025fba5cf4a596e7aac5c93967367105
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Sat,  5 Mar 2022 15:03:17 -0800

wip

Diffstat:
Msrc/main.rs | 11++++++++---
Msrc/templates/html.rs | 8+++++++-
2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/main.rs b/src/main.rs @@ -37,7 +37,12 @@ impl Lists<'_> { } fn write_lists(&self) { - // write index - ez + std::fs::create_dir_all(&self.out_dir); + let css = include_bytes!("style.css"); + 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()); for list in &self.lists { list.write_all_files() } @@ -58,17 +63,17 @@ fn write_if_unchanged(path: &PathBuf, data: &[u8]) -> bool { } // / is disallowed in paths. ; is disallowed in message IDs +// assumes unix-like filesystem. TODO windows compatability if someone asks fn pathescape_msg_id(s: &str) -> PathBuf { PathBuf::from(s.replace("/", ";")) } -enum Formats { +enum Format { XML, HTML, GMI, } -fn write_format() {} impl List<'_> { // TODO move to main // fn from_maildir() -> Self { // TODO figure out init diff --git a/src/templates/html.rs b/src/templates/html.rs @@ -21,7 +21,13 @@ const layout: &str = r#"<!DOCTYPE html> impl Lists<'_> { pub fn to_html(&self) -> String { - template(r#""#, &[("title", "tbd")]).unwrap() + template( + r#" + <h1>Mail Archives</h1> + "#, + &[("title", "tbd")], + ) + .unwrap() } }