forked from cadence/breezewiki
Compare commits
2 commits
bab6c56205
...
c3179e71dc
Author | SHA1 | Date | |
---|---|---|---|
c3179e71dc | |||
96af163773 |
1 changed files with 29 additions and 22 deletions
|
@ -22,10 +22,10 @@
|
||||||
|
|
||||||
(provide page-file)
|
(provide page-file)
|
||||||
|
|
||||||
;(module+ test
|
(module+ test
|
||||||
; (require rackunit)
|
(require rackunit)
|
||||||
; (define category-json-data
|
(define test-media-detail
|
||||||
; '#hasheq((batchcomplete . #t) (continue . #hasheq((cmcontinue . "page|4150504c45|41473") (continue . "-||"))) (query . #hasheq((categorymembers . (#hasheq((ns . 0) (pageid . 25049) (title . "Item (entity)")) #hasheq((ns . 0) (pageid . 128911) (title . "3D")) #hasheq((ns . 0) (pageid . 124018) (title . "A Very Fine Item")) #hasheq((ns . 0) (pageid . 142208) (title . "Amethyst Shard")) #hasheq((ns . 0) (pageid . 121612) (title . "Ankle Monitor")))))))))
|
'#hasheq((fileTitle . "Example file") (videoEmbedCode . "") (imageUrl . "https://static.wikia.nocookie.net/examplefile") (rawImageUrl . "https://static.wikia.nocookie.net/examplefile") (userName . "blankie") (isPostedIn . #t) (smallerArticleList . (list #hasheq((title . "Example_article") (titleText . "Example article")))) (articleListIsSmaller . 0) (exists . #t) (imageDescription . #f))))
|
||||||
|
|
||||||
(define (url-content-type url)
|
(define (url-content-type url)
|
||||||
(log-outgoing url)
|
(log-outgoing url)
|
||||||
|
@ -41,16 +41,6 @@
|
||||||
`(audio (@ (src ,maybe-proxied-url) (controls)))]
|
`(audio (@ (src ,maybe-proxied-url) (controls)))]
|
||||||
[(regexp-match? #rx"(?i:^video/)" content-type) `(video (@ (src ,maybe-proxied-url) (controls)))]
|
[(regexp-match? #rx"(?i:^video/)" content-type) `(video (@ (src ,maybe-proxied-url) (controls)))]
|
||||||
[else `""]))
|
[else `""]))
|
||||||
(module+ test
|
|
||||||
(require rackunit)
|
|
||||||
(parameterize ([(config-parameter 'strict_proxy) "true"])
|
|
||||||
(check-equal? (get-media-html "https://static.wikia.nocookie.net/a" "image/jpeg") `(img (@ (src "/proxy?dest=https%3A%2F%2Fstatic.wikia.nocookie.net%2Fa"))))
|
|
||||||
(check-equal? (get-media-html "https://static.wikia.nocookie.net/b" "audio/mp3") `(audio (@ (src "/proxy?dest=https%3A%2F%2Fstatic.wikia.nocookie.net%2Fb") (controls)))))
|
|
||||||
(parameterize ([(config-parameter 'strict_proxy) "no"])
|
|
||||||
(check-equal? (get-media-html "https://static.wikia.nocookie.net/c" "application/ogg") `(audio (@ (src "/proxy?dest=https%3A%2F%2Fstatic.wikia.nocookie.net%2Fc") (controls))))
|
|
||||||
(check-equal? (get-media-html "https://static.wikia.nocookie.net/d" "video/mp4") `(video (@ (src "/proxy?dest=https%3A%2F%2Fstatic.wikia.nocookie.net%2Fd") (controls)))))
|
|
||||||
(check-equal? (get-media-html "https://example.com" "who knows") `"")
|
|
||||||
(check-equal? (get-media-html "https://example.com" #f) `""))
|
|
||||||
|
|
||||||
(define (generate-results-page #:source-url source-url
|
(define (generate-results-page #:source-url source-url
|
||||||
#:wikiname wikiname
|
#:wikiname wikiname
|
||||||
|
@ -138,11 +128,28 @@
|
||||||
(response/output #:code 200
|
(response/output #:code 200
|
||||||
#:headers (list referrer-policy)
|
#:headers (list referrer-policy)
|
||||||
(λ (out) (write-html body out)))))))
|
(λ (out) (write-html body out)))))))
|
||||||
;(module+ test
|
(module+ test
|
||||||
; (check-not-false ((query-selector (attribute-selector 'href "/test/wiki/Ankle_Monitor")
|
(parameterize ([(config-parameter 'strict_proxy) "true"])
|
||||||
; (generate-results-page
|
(check-equal? (get-media-html "https://static.wikia.nocookie.net/a" "image/jpeg")
|
||||||
; #:source-url ""
|
`(img (@ (src "/proxy?dest=https%3A%2F%2Fstatic.wikia.nocookie.net%2Fa"))))
|
||||||
; #:wikiname "test"
|
(check-equal? (get-media-html "https://static.wikia.nocookie.net/b" "audio/mp3")
|
||||||
; #:title "Category:Items"
|
`(audio (@ (src "/proxy?dest=https%3A%2F%2Fstatic.wikia.nocookie.net%2Fb")
|
||||||
; #:members-data category-json-data
|
(controls)))))
|
||||||
; #:page '(div "page text"))))))
|
(parameterize ([(config-parameter 'strict_proxy) "no"])
|
||||||
|
(check-equal? (get-media-html "https://static.wikia.nocookie.net/c" "application/ogg")
|
||||||
|
`(audio (@ (src "/proxy?dest=https%3A%2F%2Fstatic.wikia.nocookie.net%2Fc")
|
||||||
|
(controls))))
|
||||||
|
(check-equal? (get-media-html "https://static.wikia.nocookie.net/d" "video/mp4")
|
||||||
|
`(video (@ (src "/proxy?dest=https%3A%2F%2Fstatic.wikia.nocookie.net%2Fd")
|
||||||
|
(controls)))))
|
||||||
|
(check-equal? (get-media-html "https://example.com" "who knows") `"")
|
||||||
|
(check-equal? (get-media-html "https://example.com" #f) `""))
|
||||||
|
(module+ test
|
||||||
|
(parameterize ([(config-parameter 'strict_proxy) "true"])
|
||||||
|
(check-not-false ((query-selector (attribute-selector 'src "/proxy?dest=https%3A%2F%2Fstatic.wikia.nocookie.net%2Fexamplefile")
|
||||||
|
(generate-results-page
|
||||||
|
#:source-url ""
|
||||||
|
#:wikiname "test"
|
||||||
|
#:title "File:Example file"
|
||||||
|
#:media-detail test-media-detail
|
||||||
|
#:image-content-type "image/jpeg"))))))
|
||||||
|
|
Loading…
Reference in a new issue