crabmail

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

commit 1811d91a94c9f0eebd675132636e980b6eb55853
parent 75031cee8b9a32739c576059eb34a0cbfb43c093
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Sun,  6 Feb 2022 11:01:56 -0800

lowercase mailto link headers

apparently this was wrong

Diffstat:
MCargo.lock | 66++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MCargo.toml | 1+
Msrc/main.rs | 20+++++++++++++++-----
3 files changed, 82 insertions(+), 5 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock @@ -37,6 +37,7 @@ dependencies = [ "anyhow", "horrorshow", "linkify", + "mail-parser", "mailparse", "nanohtml2text", "once_cell", @@ -68,6 +69,16 @@ dependencies = [ ] [[package]] +name = "mail-parser" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f31ffdaf350a570dac60afd70433dca8b2a4027f98064a8fca68549a54d2326" +dependencies = [ + "encoding_rs", + "serde", +] + +[[package]] name = "mailparse" version = "0.13.7" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -97,12 +108,67 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5" [[package]] +name = "proc-macro2" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145" +dependencies = [ + "proc-macro2", +] + +[[package]] name = "quoted_printable" version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fee2dce59f7a43418e3382c766554c614e06a552d53a8f07ef499ea4b332c0f" [[package]] +name = "serde" +version = "1.0.136" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.136" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "syn" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "unicode-xid" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" + +[[package]] name = "urlencoding" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/Cargo.toml b/Cargo.toml @@ -20,6 +20,7 @@ horrorshow = "0.8.4" # Largest dependency, required for email parsing mailparse = "0.13.7" +mail-parser = "*" # Small, effective dependencies, little benefit to vendoring linkify = "0.8.0" diff --git a/src/main.rs b/src/main.rs @@ -403,13 +403,13 @@ impl Email { url.push_str(&format!("{}={}&", k, urlencoding::encode(v))); }; let fixed_id = format!("<{}>", &self.id); - pushencode("Cc", &from); - pushencode("In-Reply-To", &fixed_id); + pushencode("cc", &from); + pushencode("in-reply-to", &fixed_id); let list_url = format!("{}/{}", &Config::global().base_url, &thread.list_name); - pushencode("List-Archive", &list_url); - pushencode("Subject", &format!("Re: {}", thread.messages[0].subject)); + pushencode("list-archive", &list_url); + pushencode("subject", &format!("Re: {}", thread.messages[0].subject)); // quoted body - url.push_str("Body="); + url.push_str("body="); // This is ugly and I dont like it. May deprecate it if Config::global().reply_add_link { url.push_str(&format!( @@ -580,6 +580,16 @@ fn write_index(lists: Vec<String>) -> Result<()> { Ok(()) } +fn newmain() -> Result<()> { + let args = arg::Args::from_env(); + let mut config = Config::from_file(&args.config)?; + INSTANCE.set(config).unwrap(); + // if is file, interpret as mbox, else interpret as maildir etc + // mailgen = mbox/mdir generator + for maildir in std::fs::read_dir(&args.maildir).unwrap() {} + Ok(()) +} + fn main() -> Result<()> { let args = arg::Args::from_env();