From 51bd2d03837cab9ee97d81a5f6cf5ebde6adb4c2 Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Wed, 4 Jan 2023 15:49:01 -0500 Subject: show adds for hacker news Signed-off-by: Xe Iaso --- lib/xesite_templates/src/lib.rs | 36 ++++++++++++++++++++---------------- src/tmpl/nag.rs | 8 ++++---- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/lib/xesite_templates/src/lib.rs b/lib/xesite_templates/src/lib.rs index c2e3106..62f7502 100644 --- a/lib/xesite_templates/src/lib.rs +++ b/lib/xesite_templates/src/lib.rs @@ -144,26 +144,30 @@ pub fn video(path: String) -> Markup { } } -pub fn advertiser_nag() -> Markup { +pub fn advertiser_nag(nag: Option) -> Markup { html! { script r#async src="https://media.ethicalads.io/media/client/ethicalads.min.js" { "" } div.adaptive data-ea-publisher="christinewebsite" data-ea-type="text" data-ea-style="fixedfooter" { .warning { - (conv( - "Cadey".into(), - "coffee".into(), - html! { - "Hello! Thank you for visiting my website. You seem to be using an ad-blocker. I understand why you do this, but I'd really appreciate if it you would turn it off for my website. These ads help pay for running the website and are done by " - a href="https://www.ethicalads.io/" { "Ethical Ads" } - ". I do not receive detailed analytics on the ads and from what I understand neither does Ethical Ads. If you don't want to disable your ad blocker, please consider donating on " - a href="https://patreon.com/cadey" { "Patreon" } - " or sending some extra cash to " - code { "xeiaso.eth" } - " or " - code { "0xeA223Ca8968Ca59e0Bc79Ba331c2F6f636A3fB82" } - ". It helps fund the website's hosting bills and pay for the expensive technical editor that I use for my longer articles. Thanks and be well!" - }, - )) + @if let Some(nag) = nag { + (nag) + } @else { + (conv( + "Cadey".into(), + "coffee".into(), + html! { + "Hello! Thank you for visiting my website. You seem to be using an ad-blocker. I understand why you do this, but I'd really appreciate if it you would turn it off for my website. These ads help pay for running the website and are done by " + a href="https://www.ethicalads.io/" { "Ethical Ads" } + ". I do not receive detailed analytics on the ads and from what I understand neither does Ethical Ads. If you don't want to disable your ad blocker, please consider donating on " + a href="https://patreon.com/cadey" { "Patreon" } + " or sending some extra cash to " + code { "xeiaso.eth" } + " or " + code { "0xeA223Ca8968Ca59e0Bc79Ba331c2F6f636A3fB82" } + ". It helps fund the website's hosting bills and pay for the expensive technical editor that I use for my longer articles. Thanks and be well!" + }, + )) + } } } } diff --git a/src/tmpl/nag.rs b/src/tmpl/nag.rs index 7231c56..939d325 100644 --- a/src/tmpl/nag.rs +++ b/src/tmpl/nag.rs @@ -23,13 +23,13 @@ pub fn referer(referer: Option) -> Markup { use xesite_templates::conv as xeblog_conv; if referer.is_none() { - return xesite_templates::advertiser_nag(); + return xesite_templates::advertiser_nag(None); } let referer = referer.unwrap(); if HACKER_NEWS.is_match(&referer) { - return xeblog_conv( + return xesite_templates::advertiser_nag(Some(xeblog_conv( "Mara".into(), "hacker".into(), html! { @@ -37,7 +37,7 @@ pub fn referer(referer: Option) -> Markup { a href="/pronouns" {"this page"} " that explains the pronouns that you should be using. tl;dr: the author of this website is NOT male. Please do not use \"he\" or \"him\" when referring to the author." }, - ); + ))); } if LOBSTERS.is_match(&referer) { @@ -50,7 +50,7 @@ pub fn referer(referer: Option) -> Markup { ); } - xesite_templates::advertiser_nag() + xesite_templates::advertiser_nag(None) } #[cfg(debug_assertions)] -- cgit v1.2.3