aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXe Iaso <me@christine.website>2022-12-13 19:57:54 -0500
committerXe Iaso <me@christine.website>2022-12-13 19:57:54 -0500
commit3e15f58a9621ea2a46432bfac23e6337b76824b3 (patch)
treeed2cc1fb19a672441b85b59b37606559a1585260
parent3eafc1bd10b312bcdebce6280c851ae46f385019 (diff)
downloadxesite-3e15f58a9621ea2a46432bfac23e6337b76824b3.tar.xz
xesite-3e15f58a9621ea2a46432bfac23e6337b76824b3.zip
tmpl/nag: have separate messages for debug mode
Signed-off-by: Xe Iaso <me@christine.website>
-rw-r--r--src/tmpl/nag.rs32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/tmpl/nag.rs b/src/tmpl/nag.rs
index 36ed4c6..3504382 100644
--- a/src/tmpl/nag.rs
+++ b/src/tmpl/nag.rs
@@ -1,16 +1,25 @@
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();
}
+#[cfg(debug_assertions)]
+pub fn referer(_: Option<String>) -> Markup {
+ html! {
+ .warning {
+ "This is a development instance of xesite. Things here are probably unfinished or in drafting. Don't take anything here super seriously. If you want to share this to an online aggregator, please don't. Drafts are not finalized yet for a reason."
+ }
+ br;
+ }
+}
+
+#[cfg(not(debug_assertions))]
pub fn referer(referer: Option<String>) -> Markup {
+ use xesite_templates::conv as xeblog_conv;
if referer.is_none() {
return xesite_templates::advertiser_nag();
}
@@ -25,19 +34,19 @@ pub fn referer(referer: Option<String>) -> Markup {
};
}
- 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;
- }
- };
- }
+ if DEV_SERVER.is_match(&referer) {}
xesite_templates::advertiser_nag()
}
+#[cfg(debug_assertions)]
+pub fn prerelease(_: &Post) -> Markup {
+ html! {}
+}
+
+#[cfg(not(debug_assertions))]
pub fn prerelease(post: &Post) -> Markup {
+ use chrono::prelude::*;
if Utc::now().date_naive().num_days_from_ce() < post.date.num_days_from_ce() {
html! {
.warning {
@@ -47,6 +56,7 @@ pub fn prerelease(post: &Post) -> Markup {
" 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."
+ br;
}))
}
}