forked from cadence/breezewiki
Rename wikiname-regex to px-wikiname
I find prefix notation more natural to represent the type/kind of the thing.
This commit is contained in:
parent
57e700cef5
commit
79f04565c7
3 changed files with 8 additions and 8 deletions
|
@ -44,9 +44,9 @@
|
||||||
(pathprocedure:make "/" (hash-ref ds 'page-home))
|
(pathprocedure:make "/" (hash-ref ds 'page-home))
|
||||||
(pathprocedure:make "/proxy" (hash-ref ds 'page-proxy))
|
(pathprocedure:make "/proxy" (hash-ref ds 'page-proxy))
|
||||||
(pathprocedure:make "/search" (hash-ref ds 'page-global-search))
|
(pathprocedure:make "/search" (hash-ref ds 'page-global-search))
|
||||||
(filter:make (pregexp (format "^/~a/wiki/Category:.+$" wikiname-regex)) (lift:make (hash-ref ds 'page-category)))
|
(filter:make (pregexp (format "^/~a/wiki/Category:.+$" px-wikiname)) (lift:make (hash-ref ds 'page-category)))
|
||||||
(filter:make (pregexp (format "^/~a/wiki/.+$" wikiname-regex)) (lift:make (hash-ref ds 'page-wiki)))
|
(filter:make (pregexp (format "^/~a/wiki/.+$" px-wikiname)) (lift:make (hash-ref ds 'page-wiki)))
|
||||||
(filter:make (pregexp (format "^/~a/search$" wikiname-regex)) (lift:make (hash-ref ds 'page-search)))
|
(filter:make (pregexp (format "^/~a/search$" px-wikiname)) (lift:make (hash-ref ds 'page-search)))
|
||||||
(filter:make (pregexp (format "^/~a(/(wiki(/)?)?)?$" wikiname-regex)) (lift:make (hash-ref ds 'redirect-wiki-home)))
|
(filter:make (pregexp (format "^/~a(/(wiki(/)?)?)?$" px-wikiname)) (lift:make (hash-ref ds 'redirect-wiki-home)))
|
||||||
(hash-ref ds 'static-dispatcher)
|
(hash-ref ds 'static-dispatcher)
|
||||||
(lift:make (hash-ref ds 'page-not-found)))))))
|
(lift:make (hash-ref ds 'page-not-found)))))))
|
||||||
|
|
|
@ -143,7 +143,7 @@
|
||||||
(λ (href)
|
(λ (href)
|
||||||
((compose1
|
((compose1
|
||||||
(λ (href) (regexp-replace #rx"^(/wiki/.*)" href (format "/~a\\1" wikiname)))
|
(λ (href) (regexp-replace #rx"^(/wiki/.*)" href (format "/~a\\1" wikiname)))
|
||||||
(λ (href) (regexp-replace (pregexp (format "^https://(~a)\\.fandom\\.com(/wiki/.*)" wikiname-regex)) href "/\\1\\2")))
|
(λ (href) (regexp-replace (pregexp (format "^https://(~a)\\.fandom\\.com(/wiki/.*)" px-wikiname)) href "/\\1\\2")))
|
||||||
href)))
|
href)))
|
||||||
; add noreferrer to a.image
|
; add noreferrer to a.image
|
||||||
(curry u
|
(curry u
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
(provide
|
(provide
|
||||||
; regex to match wiki names
|
; regex to match wiki names
|
||||||
wikiname-regex
|
px-wikiname
|
||||||
; make a query string from an association list of strings
|
; make a query string from an association list of strings
|
||||||
params->query
|
params->query
|
||||||
; make a proxied version of a fandom url
|
; make a proxied version of a fandom url
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
(module+ test
|
(module+ test
|
||||||
(require "typed-rackunit.rkt"))
|
(require "typed-rackunit.rkt"))
|
||||||
|
|
||||||
(define wikiname-regex "[a-zA-Z0-9-]{3,50}")
|
(define px-wikiname "[a-zA-Z0-9-]{3,50}")
|
||||||
|
|
||||||
;; https://url.spec.whatwg.org/#urlencoded-serializing
|
;; https://url.spec.whatwg.org/#urlencoded-serializing
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@
|
||||||
|
|
||||||
(: is-fandom-url? (String -> Boolean))
|
(: is-fandom-url? (String -> Boolean))
|
||||||
(define (is-fandom-url? url)
|
(define (is-fandom-url? url)
|
||||||
(regexp-match? (pregexp (format "^https://static\\.wikia\\.nocookie\\.net/|^https://~a\\.fandom\\.com/" wikiname-regex)) url))
|
(regexp-match? (pregexp (format "^https://static\\.wikia\\.nocookie\\.net/|^https://~a\\.fandom\\.com/" px-wikiname)) url))
|
||||||
(module+ test
|
(module+ test
|
||||||
(check-true (is-fandom-url? "https://static.wikia.nocookie.net/wikiname/images/2/2f/SomeImage.jpg/revision/latest?cb=20110210094136"))
|
(check-true (is-fandom-url? "https://static.wikia.nocookie.net/wikiname/images/2/2f/SomeImage.jpg/revision/latest?cb=20110210094136"))
|
||||||
(check-true (is-fandom-url? "https://test.fandom.com/wiki/Some_Page"))
|
(check-true (is-fandom-url? "https://test.fandom.com/wiki/Some_Page"))
|
||||||
|
|
Loading…
Reference in a new issue