crabmail

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

commit 4692da80ef5fff19f684c4ea9ee26e623d39dbaf
parent 2ee35058ef5496f89e80e1301b35cd468ef2eede
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Wed, 22 Dec 2021 15:25:07 -0800

Add RSS links

Diffstat:
Msrc/main.rs | 16++++++++++++++--
Msrc/utils.rs | 18+++++++++++++++++-
2 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/src/main.rs b/src/main.rs @@ -149,7 +149,13 @@ impl<'a> ThreadList<'a> { } pub fn write_to_file(&self) -> Result<()> { let tmp = html! { - h1(class="page-title"): &Config::global().list_name; + h1(class="page-title") { + : &Config::global().list_name; + : Raw(" "); + a(href="atom.xml") { + img(src=utils::rss_svg); + } + } a(href=format!("mailto:{}", &Config::global().list_email)) { : &Config::global().list_email @@ -252,7 +258,13 @@ impl<'a> MailThread<'a> { fn write_to_file(&self) -> Result<()> { let root = self.messages[0]; let tmp = html! { - h1(class="page-title"): &root.subject; + h1(class="page-title") { + : &root.subject; + : Raw(" "); + a(href=format!("./{}.xml", self.hash)) { + img(src=utils::rss_svg); + } + } div { a(href="../") { : &Config::global().list_name diff --git a/src/utils.rs b/src/utils.rs @@ -1,8 +1,24 @@ use linkify::{LinkFinder, LinkKind}; +// gpl licensed from wikipedia https://commons.wikimedia.org/wiki/File:Generic_Feed-icon.svg +pub const rss_svg: &str = r#" +data:image/svg+xml,<?xml version="1.0" encoding="UTF-8"?> +<svg xmlns="http://www.w3.org/2000/svg" + id="RSSicon" + viewBox="0 0 8 8" width="16" height="16"> + <title>RSS feed icon</title> + <style type="text/css"> + .button {stroke: none; fill: orange;} + .symbol {stroke: none; fill: white;} + </style> + <rect class="button" width="8" height="8" rx="1.5" /> + <circle class="symbol" cx="2" cy="6" r="1" /> + <path class="symbol" d="m 1,4 a 3,3 0 0 1 3,3 h 1 a 4,4 0 0 0 -4,-4 z" /> + <path class="symbol" d="m 1,2 a 5,5 0 0 1 5,5 h 1 a 6,6 0 0 0 -6,-6 z" /> +</svg>"#; + // partly stolen from // https://github.com/robinst/linkify/blob/demo/src/lib.rs#L5 - pub fn email_body(body: &str) -> String { let mut bytes = Vec::new(); let mut in_reply: bool = false;