blob: 36ed4c6b61d5b856d1da1a8427e6965cfa2b411f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
use crate::post::Post;
use chrono::prelude::*;
use lazy_static::lazy_static;
use maud::{html, Markup};
use regex::Regex;
use xesite_templates::conv as xeblog_conv;
lazy_static! {
static ref LOBSTERS: Regex = Regex::new(r#"^https?://lobste.rs"#).unwrap();
static ref DEV_SERVER: Regex = Regex::new(r#"^https?://pneuma:3030"#).unwrap();
}
pub fn referer(referer: Option<String>) -> Markup {
if referer.is_none() {
return xesite_templates::advertiser_nag();
}
let referer = referer.unwrap();
if LOBSTERS.is_match(&referer) {
return html! {
(xeblog_conv("Mara".into(), "happy".into(), html!{
"Hey, thanks for reading Lobsters! We've disabled the ads to thank you for choosing to use a more ethical aggregator."
}))
};
}
if DEV_SERVER.is_match(&referer) {
return html! {
.warning {
"This is a development instance of xesite. Things here are probably unfinished or in drafting. Don't take anything here super seriously."
br;
}
};
}
xesite_templates::advertiser_nag()
}
pub fn prerelease(post: &Post) -> Markup {
if Utc::now().date_naive().num_days_from_ce() < post.date.num_days_from_ce() {
html! {
.warning {
(xeblog_conv("Mara".into(), "hacker".into(), html!{
"Hey, this post is set to go live on "
(format!("{}", post.detri()))
" UTC. Right now you are reading a pre-publication version of this post. Please do not share this on social media. This post will automatically go live for everyone on the intended publication date. If you want access to these posts, please join the "
a href="https://patreon.com/cadey" { "Patreon" }
". It helps me afford the copyeditor that I contract for the technical content I write."
}))
}
}
} else {
html! {}
}
}
|