forked from cadence/breezewiki
Compare commits
2 commits
0d03783bbf
...
bf80692c4e
Author | SHA1 | Date | |
---|---|---|---|
bf80692c4e | |||
5a59545963 |
1 changed files with 42 additions and 31 deletions
|
@ -25,7 +25,17 @@
|
||||||
(module+ test
|
(module+ test
|
||||||
(require rackunit)
|
(require rackunit)
|
||||||
(define test-media-detail
|
(define test-media-detail
|
||||||
'#hasheq((fileTitle . "Example file") (videoEmbedCode . "") (imageUrl . "https://static.wikia.nocookie.net/examplefile") (rawImageUrl . "https://static.wikia.nocookie.net/examplefile") (userName . "blankie") (isPostedIn . #t) (smallerArticleList . (#hasheq((title . "Example_article") (titleText . "Example article")))) (articleListIsSmaller . 0) (exists . #t) (imageDescription . #f))))
|
'#hasheq((fileTitle . "Example file")
|
||||||
|
(videoEmbedCode . "")
|
||||||
|
(imageUrl . "https://static.wikia.nocookie.net/examplefile")
|
||||||
|
(rawImageUrl . "https://static.wikia.nocookie.net/examplefile")
|
||||||
|
(userName . "blankie")
|
||||||
|
(isPostedIn . #t)
|
||||||
|
(smallerArticleList . (#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)
|
||||||
|
@ -63,29 +73,29 @@
|
||||||
#:wikiname wikiname
|
#:wikiname wikiname
|
||||||
#:title title
|
#:title title
|
||||||
#:license license
|
#:license license
|
||||||
`(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)
|
(get-media-html image-url image-content-type))
|
||||||
(get-media-html image-url image-content-type))
|
(p ,(if (non-empty-string? video-embed-code)
|
||||||
(p ,(if (non-empty-string? video-embed-code)
|
`""
|
||||||
`""
|
`(span (a (@ (href ,maybe-proxied-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)
|
"."
|
||||||
"."
|
,(if is-posted-in
|
||||||
,(if is-posted-in
|
`(span " Posted in "
|
||||||
`(span " Posted in "
|
,@(map (λ (article)
|
||||||
,@(map (λ (article)
|
(define page-path (jp "/title" article))
|
||||||
(define page-path (jp "/title" article))
|
(define title (jp "/titleText" article page-path))
|
||||||
(define title (jp "/titleText" article page-path))
|
`(span ,(if (eq? (car smaller-article-list) article) "" ", ")
|
||||||
`(span ,(if (eq? (car smaller-article-list) article) "" ", ")
|
(a (@ (href ,(format "/~a/wiki/~a" wikiname page-path)))
|
||||||
(a (@ (href ,(format "/~a/wiki/~a" wikiname page-path))) ,title)))
|
,title)))
|
||||||
smaller-article-list)
|
smaller-article-list)
|
||||||
,(if (eq? article-list-is-smaller 1) "…" "."))
|
,(if (eq? article-list-is-smaller 1) "…" "."))
|
||||||
`""))
|
`""))
|
||||||
,(if (string? image-description)
|
,(if (string? image-description)
|
||||||
(update-tree-wiki (html->xexp (preprocess-html-wiki image-description)) wikiname)
|
(update-tree-wiki (html->xexp (preprocess-html-wiki image-description)) wikiname)
|
||||||
""))))
|
""))))
|
||||||
|
|
||||||
(define (page-file req)
|
(define (page-file req)
|
||||||
(define wikiname (path/param-path (first (url-path (request-uri req)))))
|
(define wikiname (path/param-path (first (url-path (request-uri req)))))
|
||||||
|
@ -146,10 +156,11 @@
|
||||||
(check-equal? (get-media-html "https://example.com" #f) `""))
|
(check-equal? (get-media-html "https://example.com" #f) `""))
|
||||||
(module+ test
|
(module+ test
|
||||||
(parameterize ([(config-parameter 'strict_proxy) "true"])
|
(parameterize ([(config-parameter 'strict_proxy) "true"])
|
||||||
(check-not-false ((query-selector (attribute-selector 'src "/proxy?dest=https%3A%2F%2Fstatic.wikia.nocookie.net%2Fexamplefile")
|
(check-not-false
|
||||||
(generate-results-page
|
((query-selector
|
||||||
#:source-url ""
|
(attribute-selector 'src "/proxy?dest=https%3A%2F%2Fstatic.wikia.nocookie.net%2Fexamplefile")
|
||||||
#:wikiname "test"
|
(generate-results-page #:source-url ""
|
||||||
#:title "File:Example file"
|
#:wikiname "test"
|
||||||
#:media-detail test-media-detail
|
#:title "File:Example file"
|
||||||
#:image-content-type "image/jpeg"))))))
|
#:media-detail test-media-detail
|
||||||
|
#:image-content-type "image/jpeg"))))))
|
||||||
|
|
Loading…
Reference in a new issue