Compare commits
1 commit
main
...
disable-re
Author | SHA1 | Date | |
---|---|---|---|
9611b8c164 |
3 changed files with 156 additions and 138 deletions
|
@ -65,6 +65,12 @@
|
||||||
|
|
||||||
(define (page-category req)
|
(define (page-category req)
|
||||||
(response-handler
|
(response-handler
|
||||||
|
(cond
|
||||||
|
[(config-true? 'feature_offline::only)
|
||||||
|
(response/output #:code 503
|
||||||
|
#:headers (build-headers always-headers)
|
||||||
|
(λ (out) (write-html '(p "Sorry, category pages are temporarily disabled. I hope to have them back soon.") out)))]
|
||||||
|
[else
|
||||||
(define wikiname (path/param-path (first (url-path (request-uri req)))))
|
(define wikiname (path/param-path (first (url-path (request-uri req)))))
|
||||||
(define prefixed-category (string-join (map path/param-path (cddr (url-path (request-uri req)))) "/"))
|
(define prefixed-category (string-join (map path/param-path (cddr (url-path (request-uri req)))) "/"))
|
||||||
(define origin (format "https://~a.fandom.com" wikiname))
|
(define origin (format "https://~a.fandom.com" wikiname))
|
||||||
|
@ -122,7 +128,7 @@
|
||||||
#:code 200
|
#:code 200
|
||||||
#:headers (build-headers always-headers)
|
#:headers (build-headers always-headers)
|
||||||
(λ (out)
|
(λ (out)
|
||||||
(write-html body out)))))
|
(write-html body out)))])))
|
||||||
(module+ test
|
(module+ test
|
||||||
(check-not-false ((query-selector (attribute-selector 'href "/test/wiki/Ankle_Monitor")
|
(check-not-false ((query-selector (attribute-selector 'href "/test/wiki/Ankle_Monitor")
|
||||||
(generate-results-page
|
(generate-results-page
|
||||||
|
|
|
@ -104,6 +104,12 @@
|
||||||
|
|
||||||
(define (page-file req)
|
(define (page-file req)
|
||||||
(response-handler
|
(response-handler
|
||||||
|
(cond
|
||||||
|
[(config-true? 'feature_offline::only)
|
||||||
|
(response/output #:code 503
|
||||||
|
#:headers (build-headers always-headers)
|
||||||
|
(λ (out) (write-html '(p "Sorry, file pages are temporarily disabled. I hope to have them back soon.") out)))]
|
||||||
|
[else
|
||||||
(define wikiname (path/param-path (first (url-path (request-uri req)))))
|
(define wikiname (path/param-path (first (url-path (request-uri req)))))
|
||||||
(define prefixed-title (path/param-path (caddr (url-path (request-uri req)))))
|
(define prefixed-title (path/param-path (caddr (url-path (request-uri req)))))
|
||||||
(define origin (format "https://~a.fandom.com" wikiname))
|
(define origin (format "https://~a.fandom.com" wikiname))
|
||||||
|
@ -147,7 +153,7 @@
|
||||||
(xexp->html body))
|
(xexp->html body))
|
||||||
(response/output #:code 200
|
(response/output #:code 200
|
||||||
#:headers (build-headers always-headers)
|
#:headers (build-headers always-headers)
|
||||||
(λ (out) (write-html body out)))))))
|
(λ (out) (write-html body out)))))])))
|
||||||
(module+ test
|
(module+ test
|
||||||
(parameterize ([(config-parameter 'strict_proxy) "true"])
|
(parameterize ([(config-parameter 'strict_proxy) "true"])
|
||||||
(check-equal? (get-media-html "https://static.wikia.nocookie.net/a" "image/jpeg")
|
(check-equal? (get-media-html "https://static.wikia.nocookie.net/a" "image/jpeg")
|
||||||
|
|
|
@ -68,6 +68,12 @@
|
||||||
(define (page-search req)
|
(define (page-search req)
|
||||||
;; this just means, catch any errors and display them in the browser. it's a function somewhere else
|
;; this just means, catch any errors and display them in the browser. it's a function somewhere else
|
||||||
(response-handler
|
(response-handler
|
||||||
|
(cond
|
||||||
|
[(config-true? 'feature_offline::only)
|
||||||
|
(response/output #:code 503
|
||||||
|
#:headers (build-headers always-headers)
|
||||||
|
(λ (out) (write-html '(body (p "Sorry, full search is temporarily broken, but I have a plan to fix it.") (p "In the meantime, please use the popup search suggestions below the search box.")) out)))]
|
||||||
|
[else
|
||||||
;; the URL will look like "/minecraft/wiki/Special:Search?q=Spawner"
|
;; the URL will look like "/minecraft/wiki/Special:Search?q=Spawner"
|
||||||
;; grab the first part to use as the wikiname, in this case, "minecraft"
|
;; grab the first part to use as the wikiname, in this case, "minecraft"
|
||||||
(define wikiname (path/param-path (first (url-path (request-uri req)))))
|
(define wikiname (path/param-path (first (url-path (request-uri req)))))
|
||||||
|
@ -109,7 +115,7 @@
|
||||||
#:code 200
|
#:code 200
|
||||||
#:headers (build-headers always-headers)
|
#:headers (build-headers always-headers)
|
||||||
(λ (out)
|
(λ (out)
|
||||||
(write-html body out)))))
|
(write-html body out)))])))
|
||||||
(module+ test
|
(module+ test
|
||||||
(parameterize ([(config-parameter 'feature_offline::only) "false"])
|
(parameterize ([(config-parameter 'feature_offline::only) "false"])
|
||||||
(check-not-false ((query-selector (attribute-selector 'href "/test/wiki/Gacha_Capsule")
|
(check-not-false ((query-selector (attribute-selector 'href "/test/wiki/Gacha_Capsule")
|
||||||
|
|
Loading…
Reference in a new issue