commit 4b827c36a8c6d0a45e9d4c95ae303f0fcc2a3683
parent 0254aadec66d241ee314e73781b2da2b43198896
Author: alex wennerberg <alex@alexwennerberg.com>
Date: Tue, 14 Dec 2021 20:00:16 -0800
Add homepage to config
Diffstat:
4 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/crabmail.conf b/crabmail.conf
@@ -1,3 +1,4 @@
list_email=~aw/flounder@lists.sr.ht
list_name=Flounder Mailing List
url=https://lists.flounder.online/flounder
+homepage=https://admin.flounder.online/mailing-list.gmi
diff --git a/src/config.rs b/src/config.rs
@@ -10,6 +10,7 @@ pub struct Config {
pub list_name: String,
pub list_email: String,
pub url: String,
+ pub homepage: Option<String>,
}
pub static INSTANCE: OnceCell<Config> = OnceCell::new();
@@ -24,6 +25,7 @@ impl Config {
let mut list_name = "Crabmail Mailing List".to_string();
let mut list_email = "setme@foo.local".to_string();
let mut url = "flounder.online".to_string();
+ let mut homepage = None;
for l in io::BufReader::new(file).lines() {
let line = l?;
@@ -37,6 +39,7 @@ impl Config {
"list_name" => list_name = value.to_string(),
"list_email" => list_email = value.to_string(),
"url" => url = value.to_string(),
+ "homepage" => homepage = Some(value.to_string()),
_ => {}
}
} else {
@@ -48,6 +51,7 @@ impl Config {
list_name,
list_email,
url,
+ homepage,
})
}
}
diff --git a/src/filters.rs b/src/filters.rs
@@ -5,6 +5,9 @@ pub fn time_ago(amount: &u64) -> askama::Result<String> {
}
const SOLAR_YEAR_SECS: u64 = 31556926;
+// TODO filter body:
+// add <span> for lines starting with > to make them grey
+// parse hyperlinks for you
fn timeago(unixtime: u64) -> String {
let current_time = SystemTime::now()
diff --git a/templates/threadlist.html b/templates/threadlist.html
@@ -2,7 +2,8 @@
{% block content %}
<div class="page-title"><h1>{{config.list_name}}</h1></div>
- <a href="mailto:{{config.list_email}}">{{config.list_email}}</a>
+{% match config.homepage %}{% when Some with (home) %}<a href="{{home}}">about</a> | {%when none%}{%endmatch%}
+ <a href="mailto:{{config.list_email}}">✉️ {{config.list_email}}</a>
<hr class="thin">
{% for thread in threads %}
{% let message = thread.messages[0] %}