forked from cadence/breezewiki
content-type
This commit is contained in:
parent
915b4a6ad5
commit
e845cc460b
1 changed files with 13 additions and 6 deletions
|
@ -28,18 +28,20 @@
|
||||||
; (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)
|
(define (url-content-type url)
|
||||||
(log-outgoing image-url)
|
(log-outgoing image-url)
|
||||||
(define dest-res (easy:head image-url #:timeouts timeouts))
|
(define dest-res (easy:head image-url #:timeouts timeouts))
|
||||||
(define content-type (easy:response-headers-ref dest-res 'Content-Type))
|
(easy:response-headers-ref dest-res 'Content-Type))
|
||||||
|
|
||||||
|
(define (get-media-html url content-type)
|
||||||
(cond
|
(cond
|
||||||
[(eq? content-type #f) `""]
|
[(eq? content-type #f) `""]
|
||||||
[(regexp-match? #rx"^image/" content-type)
|
[(regexp-match? #rx"^image/" content-type)
|
||||||
`(img (@ (src ,(u-proxy-url image-url))))]
|
`(img (@ (src ,(u-proxy-url url))))]
|
||||||
[(regexp-match? #rx"^audio/|^application/ogg$" content-type)
|
[(regexp-match? #rx"^audio/|^application/ogg$" content-type)
|
||||||
`(audio (@ (src ,(u-proxy-url image-url)) (controls)))]
|
`(audio (@ (src ,(u-proxy-url url)) (controls)))]
|
||||||
[(regexp-match? #rx"^video/" content-type)
|
[(regexp-match? #rx"^video/" content-type)
|
||||||
`(video (@ (src ,(u-proxy-url image-url)) (controls)))]
|
`(video (@ (src ,(u-proxy-url url)) (controls)))]
|
||||||
[else `""]))
|
[else `""]))
|
||||||
|
|
||||||
(define (generate-results-page
|
(define (generate-results-page
|
||||||
|
@ -47,6 +49,7 @@
|
||||||
#:wikiname wikiname
|
#:wikiname wikiname
|
||||||
#:title title
|
#:title title
|
||||||
#:media-detail media-detail
|
#:media-detail media-detail
|
||||||
|
#:image-content-type image-content-type
|
||||||
#:license [license #f])
|
#:license [license #f])
|
||||||
(define video-embed-code (jp "/videoEmbedCode" media-detail ""))
|
(define video-embed-code (jp "/videoEmbedCode" media-detail ""))
|
||||||
(define raw-image-url (jp "/rawImageUrl" media-detail))
|
(define raw-image-url (jp "/rawImageUrl" media-detail))
|
||||||
|
@ -67,7 +70,7 @@
|
||||||
`(div
|
`(div
|
||||||
,(if (non-empty-string? video-embed-code)
|
,(if (non-empty-string? video-embed-code)
|
||||||
(update-tree-wiki (html->xexp (preprocess-html-wiki video-embed-code)) wikiname)
|
(update-tree-wiki (html->xexp (preprocess-html-wiki video-embed-code)) wikiname)
|
||||||
(html-from-url image-url))
|
(get-media-html image-url image-content-type))
|
||||||
(p
|
(p
|
||||||
,(if (non-empty-string? video-embed-code)
|
,(if (non-empty-string? video-embed-code)
|
||||||
`""
|
`""
|
||||||
|
@ -122,11 +125,15 @@
|
||||||
(define title (if (non-empty-string? file-title)
|
(define title (if (non-empty-string? file-title)
|
||||||
(format "File:~a" file-title)
|
(format "File:~a" file-title)
|
||||||
prefixed-title))
|
prefixed-title))
|
||||||
|
(define image-content-type (if (non-empty-string? (jp "/videoEmbedCode" media-detail ""))
|
||||||
|
#f
|
||||||
|
(url-content-type (jp "/imageUrl" media-detail))))
|
||||||
(define body (generate-results-page
|
(define body (generate-results-page
|
||||||
#:source-url source-url
|
#:source-url source-url
|
||||||
#:wikiname wikiname
|
#:wikiname wikiname
|
||||||
#:title title
|
#:title title
|
||||||
#:media-detail media-detail
|
#:media-detail media-detail
|
||||||
|
#:image-content-type image-content-type
|
||||||
#:license license))
|
#:license license))
|
||||||
|
|
||||||
(when (config-true? 'debug)
|
(when (config-true? 'debug)
|
||||||
|
|
Loading…
Reference in a new issue