This commit is contained in:
blankie 2022-10-08 22:26:17 +07:00
parent fd4d65abb2
commit 04ed98fb4b
Signed by: blankie
GPG key ID: CC15FC822C7F61F5

View file

@ -28,6 +28,30 @@
; (define category-json-data ; (define category-json-data
; '#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((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")))))))))
(define (html-from-url image-url)
([media-detail (define dest-url
(format "~a/wikia.php?~a"
origin
(params->query `(("format" . "json")
("controller" . "Lightbox")
("method" . "getMediaDetail")
("fileTitle" . ,prefixed-title)))))
(log-outgoing dest-url)
(define dest-res (easy:get dest-url #:timeouts timeouts))
(easy:response-json dest-res)]
(log-outgoing image-url)
(define dest-res (easy:head image-url #:timeouts timeouts))
(define content-type (response-headers-ref dest-res "Content-Type"))
(cond
[(eq? content-type #f) ""]
[(regexp-match? #rx"^image/" content-type)
(img (@ (src ,(u-proxy-url image-url))))]
[(regexp-match? #rx"^audio/" content-type)
(audio (@ (src ,(u-proxy-url image-url)) (controls)))]
[(regexp-match? #rx"^video/" content-type)
(video (@ (src ,(u-proxy-url image-url)) (controls)))]
[else ""]))
(define (generate-results-page (define (generate-results-page
#:source-url source-url #:source-url source-url
#:wikiname wikiname #:wikiname wikiname
@ -42,16 +66,22 @@
(define smaller-article-list (jp "/smallerArticleList" media-detail)) (define smaller-article-list (jp "/smallerArticleList" media-detail))
(define article-list-is-smaller (jp "/articleListIsSmaller" media-detail)) (define article-list-is-smaller (jp "/articleListIsSmaller" media-detail))
(define image-description (jp "/imageDescription" media-detail #f)) (define image-description (jp "/imageDescription" media-detail #f))
(define maybe-proxied-raw-image-url (if (config-true? 'strict_proxy)
(u-proxy-url raw-image-url)
raw-image-url))
(generate-wiki-page (generate-wiki-page
#:source-url source-url #:source-url source-url
#:wikiname wikiname #:wikiname wikiname
#:title title #:title title
#:license license #:license license
`(div `(div
,(if (non-empty-string? video-embed-code)
(update-tree-wiki (html->xexp (preprocess-html-wiki video-embed-code)) wikiname)
`(html-from-url image-url))
(p (p
,(if (non-empty-string? video-embed-code) ,(if (non-empty-string? video-embed-code)
`"" `""
`(span (a (@ (href ,(u-proxy-url raw-image-url))) "View original file") ". ")) `(span (a (@ (href ,maybe-proxied-raw-image-url)) "View original file") ". "))
"Added by " "Added by "
(a (@ (href ,(format "/~a/wiki/User:~a" wikiname username))) ,username) (a (@ (href ,(format "/~a/wiki/User:~a" wikiname username))) ,username)
"." "."