crabmail

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

commit 42679585662e27be931dc1a892368aa7e1bef4fc
parent 5a4560910821d60caeba0e33eaeaa2ae4d67d11d
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Thu, 13 May 2021 14:12:05 -0700

Add fomat sting

Diffstat:
Msrc/main.rs | 26+++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/main.rs b/src/main.rs @@ -57,22 +57,22 @@ fn parse_path(s: &std::ffi::OsStr) -> Result<std::path::PathBuf, &'static str> { fn email_to_html(email: ParsedMail) -> String { // TODO use format strings here i think - let mut result = String::new(); - result.push_str("Subject: "); - result.push_str( - &email - .headers - .get_first_value("Subject") - .unwrap_or(String::from("<No Subject>")), - ); - result.push_str("\nFrom: "); - result.push_str( - &email + return format!( + r#" +<b>From<b>: {from}<br> +<b>Subject</b>: {subject} +<div id="body"> {body} </div> + "#, + from = &email .headers .get_first_value("From") - .unwrap_or(String::from("<No From?>")), + .unwrap_or("".to_string()), + subject = &email + .headers + .get_first_value("Subject") + .unwrap_or("".to_string()), + body = &email.get_body().unwrap() ); - result } // TODO set lang, title, etc