crabmail

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

commit 790053fcc9a65f3d28cf169d7912c36a23ec25d9
parent 3b68aa62d3ad712f9b13dde3e06b0c603e5ca282
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Mon, 17 Jan 2022 09:11:02 -0800

Some cleanup

Diffstat:
Mcrabmail.conf | 2++
Msrc/config.rs | 2++
Msrc/main.rs | 128++++++++++++++++++++++++++++++++++++++++++-------------------------------------
3 files changed, 72 insertions(+), 60 deletions(-)

diff --git a/crabmail.conf b/crabmail.conf @@ -3,6 +3,8 @@ base_url=https://lists.flounder.online email_fmt=lists+%s@flounder.online description=All my lists +reply_thread_link=true + # optionally wirte/overwrite config for specific lists [smallweb] title=Very cool list diff --git a/src/config.rs b/src/config.rs @@ -30,6 +30,7 @@ pub struct Config { pub relative_times: bool, // TODO rem pub include_raw: bool, // TODO rem pub now: String, // TODO rem + pub reply_thread_link: bool, pub subsections: Vec<Subsection>, } @@ -40,6 +41,7 @@ impl Config { "email_fmt" => self.email_fmt = value.to_string(), "base_url" => self.base_url = value.to_string(), "description" => self.description = value.to_string(), + "reply_thread_link" => self.reply_thread_link = value == "true", _ => {} } } diff --git a/src/main.rs b/src/main.rs @@ -293,72 +293,80 @@ impl<'a> MailThread<'a> { fn write_to_file(&self) -> Result<()> { let root = self.messages[0]; let tmp = html! { - h1(class="page-title") { - : &root.subject; - : Raw(" "); - a(href=format!("./{}.xml", self.hash)) { - img(alt="Atom feed", src=utils::RSS_SVG); - } - } - div { - a(href="../") { - : "Back"; - } - hr; - } div { - @ for message in self.messages.iter() { - div(id=&message.id, class="message") { - div(class="message-meta") { - span(class="bold") { - : &message.subject - } - - @ if message.in_reply_to.is_some() { - : " "; - a(title="replies-to", href=format!("#{}", message.in_reply_to.clone().unwrap())){ - : "Parent ^"; - } - } - br; - a(href=format!("mailto:{}", &message.from.addr), class="bold") { - : &message.from.to_string(); + h1(class="page-title") { + : &root.subject; + : Raw(" "); + a(href=format!("./{}.xml", self.hash)) { + img(alt="Atom feed", src=utils::RSS_SVG); } - br; - span(class="light") { - : &message.date_string - } - a(title="permalink", href=format!("#{}", &message.id)) { - : " 🔗" } - @ if &message.mime == "text/html" { - span(class="light italic") { - : " (converted from html)"; + div { + a(href="../") { + : "Back"; } - } - br; - a (class="bold", href=message.mailto(&root.subject, &self.list_name)) { - :"✉️ Reply" - } - @ if Config::global().include_raw { - : " ["; - a(href=format!("../messages/{}", message.id)) { - : "Download" ; - } - : "]"; - }} br; - @ if message.subject.starts_with("[PATCH") || message.subject.starts_with("[PULL") { - div(class="email-body monospace") { - : Raw(utils::email_body(&message.body)) + : " "; + a(href="#bottom") { + : "Latest"; } - } else { - div(class="email-body") { - : Raw(utils::email_body(&message.body)) + hr; + } div { + @ for message in self.messages.iter() { + div(id=&message.id, class="message") { + div(class="message-meta") { + span(class="bold") { + : &message.subject + } + + + br; + a(href=format!("mailto:{}", &message.from.addr), class="bold") { + : &message.from.to_string(); + } + br; + span(class="light") { + : &message.date_string + } + a(title="permalink", href=format!("#{}", &message.id)) { + : " 🔗" + } + @ if &message.mime == "text/html" { + span(class="light italic") { + : " (converted from html)"; + } + } + br; + a (class="bold", href=message.mailto(&root.subject, &self.list_name)) { + :"✉️ Reply" + } + @ if Config::global().include_raw { + : " ["; + a(href=format!("../messages/{}", message.id)) { + : "Download" ; + } + : "]"; + } + @ if message.in_reply_to.is_some() { + : " "; + a(title="replies-to", href=format!("#{}", message.in_reply_to.clone().unwrap())){ + : "Parent"; + } + } + } + br; + @ if message.subject.starts_with("[PATCH") || message.subject.starts_with("[PULL") { + div(class="email-body monospace") { + : Raw(utils::email_body(&message.body)) + } + } else { + div(class="email-body") { + : Raw(utils::email_body(&message.body)) + } + } br; + } } - } br; + a(id="bottom"); } - } - } - }; + }; let thread_dir = Config::global() .out_dir .join(&self.list_name)