forked from cadence/breezewiki
		
	New option: promotions::indie_wiki_buddy
This commit is contained in:
		
							parent
							
								
									b5fb99c8ab
								
							
						
					
					
						commit
						040d9b94de
					
				
					 3 changed files with 28 additions and 6 deletions
				
			
		|  | @ -62,10 +62,19 @@ | ||||||
|                      (p |                      (p | ||||||
|                       (a (@ (href "https://lists.sr.ht/~cadence/breezewiki-discuss")) |                       (a (@ (href "https://lists.sr.ht/~cadence/breezewiki-discuss")) | ||||||
|                          "Chat / Bug reports / Feature requests")) |                          "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) |                      ,(if (config-true? 'instance_is_official) | ||||||
|                           `(p ,(format "This instance is run by the ~a developer, " (config-get 'application_name)) |                           `(p ,(format "This instance is run by the ~a developer, " (config-get 'application_name)) | ||||||
|                               (a (@ (href "https://cadence.moe/contact")) |                               (a (@ (href "https://cadence.moe/contact")) | ||||||
|                                  "Cadence.")) |                                  "Cadence") | ||||||
|  |                               ". Proudly hosted by " | ||||||
|  |                               (a (@ (href "http://alphamethyl.barr0w.net")) | ||||||
|  |                                  "Barrow Network Solutions" (sup "XD")) | ||||||
|  |                               ".") | ||||||
|                           `(p |                           `(p | ||||||
|                             ,(format "This unofficial instance is based off the ~a source code, but is not controlled by the code developer." (config-get 'application_name))))) |                             ,(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 |                 ,(if source-url | ||||||
|  | @ -201,6 +210,7 @@ | ||||||
|            ,(let ([extension-eligible? |            ,(let ([extension-eligible? | ||||||
|                    (cond/var |                    (cond/var | ||||||
|                     [(not req) #f] |                     [(not req) #f] | ||||||
|  |                     [(not (config-member? 'promotions::indie_wiki_buddy "banner")) #f] | ||||||
|                     (var ua-pair (assq 'user-agent (request-headers req))) |                     (var ua-pair (assq 'user-agent (request-headers req))) | ||||||
|                     [(not ua-pair) #f] |                     [(not ua-pair) #f] | ||||||
|                     (var ua (string-downcase (cdr ua-pair))) |                     (var ua (string-downcase (cdr ua-pair))) | ||||||
|  |  | ||||||
|  | @ -8,6 +8,7 @@ | ||||||
| (provide | (provide | ||||||
|  config-parameter |  config-parameter | ||||||
|  config-true? |  config-true? | ||||||
|  |  config-member? | ||||||
|  config-get) |  config-get) | ||||||
| 
 | 
 | ||||||
| (module+ test | (module+ test | ||||||
|  | @ -23,6 +24,11 @@ | ||||||
| (define (config-true? key) | (define (config-true? key) | ||||||
|   (not (member ((config-parameter key)) '("" "false")))) |   (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)) | (: config-get (Symbol -> String)) | ||||||
| (define (config-get key) | (define (config-get key) | ||||||
|   ((config-parameter key))) |   ((config-parameter key))) | ||||||
|  | @ -42,7 +48,9 @@ | ||||||
|     (feature_offline::format . "json.gz") |     (feature_offline::format . "json.gz") | ||||||
|     (feature_offline::only . "false") |     (feature_offline::only . "false") | ||||||
| 
 | 
 | ||||||
|     (access_log::enabled . "false"))) |     (access_log::enabled . "false") | ||||||
|  | 
 | ||||||
|  |     (promotions::indie_wiki_buddy . "banner home"))) | ||||||
| 
 | 
 | ||||||
| (define loaded-alist | (define loaded-alist | ||||||
|   (with-handlers |   (with-handlers | ||||||
|  | @ -109,8 +117,10 @@ | ||||||
| (module+ test | (module+ test | ||||||
|   ; this is just a sanity check |   ; this is just a sanity check | ||||||
|   (parameterize ([(config-parameter 'application_name) "JeffWiki"] |   (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-equal? (config-get 'application_name) "JeffWiki") | ||||||
|     (check-false (config-true? 'strict_proxy)) |     (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")))) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -31,8 +31,10 @@ | ||||||
|                     (url-host (string->url (config-get 'canonical_origin))) |                     (url-host (string->url (config-get 'canonical_origin))) | ||||||
|                     "breezewiki.com"))) |                     "breezewiki.com"))) | ||||||
|     (p "If you'd like to be automatically sent to BreezeWiki every time in the future, " |     (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!)") |        ,@(if (config-member? 'promotions::indie_wiki_buddy "home") | ||||||
|        " or " |              `((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.")) |        (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. " |     (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.")) |        (a (@ (href "https://docs.breezewiki.com/Links.html#%28part._.Mirrors%29")) "See the list.")) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue