From 040d9b94dec02c260b871caeceed80ae4d3fd7c4 Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Sun, 16 Apr 2023 00:05:54 +1200 Subject: [PATCH] New option: promotions::indie_wiki_buddy --- src/application-globals.rkt | 12 +++++++++++- src/config.rkt | 16 +++++++++++++--- src/page-home.rkt | 6 ++++-- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/application-globals.rkt b/src/application-globals.rkt index b6777ef..10b4530 100644 --- a/src/application-globals.rkt +++ b/src/application-globals.rkt @@ -62,10 +62,19 @@ (p (a (@ (href "https://lists.sr.ht/~cadence/breezewiki-discuss")) "Chat / Bug reports / Feature requests")) + ,(if (config-member? 'promotions::indie_wiki_buddy "footer") + `(p + (a (@ (href "https://getindie.wiki/")) + "Get Indie Wiki Buddy browser extension - be redirected to BreezeWiki every time!")) + "") ,(if (config-true? 'instance_is_official) `(p ,(format "This instance is run by the ~a developer, " (config-get 'application_name)) (a (@ (href "https://cadence.moe/contact")) - "Cadence.")) + "Cadence") + ". Proudly hosted by " + (a (@ (href "http://alphamethyl.barr0w.net")) + "Barrow Network Solutions" (sup "XD")) + ".") `(p ,(format "This unofficial instance is based off the ~a source code, but is not controlled by the code developer." (config-get 'application_name))))) ,(if source-url @@ -201,6 +210,7 @@ ,(let ([extension-eligible? (cond/var [(not req) #f] + [(not (config-member? 'promotions::indie_wiki_buddy "banner")) #f] (var ua-pair (assq 'user-agent (request-headers req))) [(not ua-pair) #f] (var ua (string-downcase (cdr ua-pair))) diff --git a/src/config.rkt b/src/config.rkt index 09407c4..2158e77 100644 --- a/src/config.rkt +++ b/src/config.rkt @@ -8,6 +8,7 @@ (provide config-parameter config-true? + config-member? config-get) (module+ test @@ -23,6 +24,11 @@ (define (config-true? key) (not (member ((config-parameter key)) '("" "false")))) +(: config-member? (Symbol String [#:sep String] -> Boolean)) +(define (config-member? key item #:sep [sep #px"\\s+"]) + (and (config-true? key) + (not (not (member item (string-split (config-get key) sep)))))) + (: config-get (Symbol -> String)) (define (config-get key) ((config-parameter key))) @@ -42,7 +48,9 @@ (feature_offline::format . "json.gz") (feature_offline::only . "false") - (access_log::enabled . "false"))) + (access_log::enabled . "false") + + (promotions::indie_wiki_buddy . "banner home"))) (define loaded-alist (with-handlers @@ -109,8 +117,10 @@ (module+ test ; this is just a sanity check (parameterize ([(config-parameter 'application_name) "JeffWiki"] - [(config-parameter 'strict_proxy) ""]) + [(config-parameter 'strict_proxy) ""] + [(config-parameter 'promotions::indie_wiki_buddy) "a b c"]) (check-equal? (config-get 'application_name) "JeffWiki") (check-false (config-true? 'strict_proxy)) - (check-equal? (string? (config-get 'feature_offline::format)) #t))) + (check-equal? (string? (config-get 'feature_offline::format)) #t) + (check-true (config-member? 'promotions::indie_wiki_buddy "b")))) diff --git a/src/page-home.rkt b/src/page-home.rkt index 95793d3..24f7393 100644 --- a/src/page-home.rkt +++ b/src/page-home.rkt @@ -31,8 +31,10 @@ (url-host (string->url (config-get 'canonical_origin))) "breezewiki.com"))) (p "If you'd like to be automatically sent to BreezeWiki every time in the future, " - (a (@ (href "https://getindie.wiki")) "get our affiliated browser extension (NEW!)") - " or " + ,@(if (config-member? 'promotions::indie_wiki_buddy "home") + `((a (@ (href "https://getindie.wiki")) "get our affiliated browser extension (NEW!)") + " or ") + null) (a (@ (href "https://docs.breezewiki.com/Automatic_Redirection.html")) "check out the tutorial in the manual.")) (p "BreezeWiki is available on several different websites called " (a (@ (href "https://en.wikipedia.org/wiki/Mirror_site")) "mirrors") ". Each is independently run. If one mirror is offline, the others still work. " (a (@ (href "https://docs.breezewiki.com/Links.html#%28part._.Mirrors%29")) "See the list."))