forked from cadence/breezewiki
idfk
This commit is contained in:
parent
5fb7301ce1
commit
0148c1c3f9
1 changed files with 34 additions and 32 deletions
|
@ -72,41 +72,43 @@
|
||||||
))
|
))
|
||||||
|
|
||||||
(define (page-file req)
|
(define (page-file req)
|
||||||
(response-handler
|
(define wikiname (path/param-path (first (url-path (request-uri req)))))
|
||||||
(define wikiname (path/param-path (first (url-path (request-uri req)))))
|
(define prefixed-title (path/param-path (caddr (url-path (request-uri req)))))
|
||||||
(define prefixed-title (path/param-path (caddr (url-path (request-uri req)))))
|
(define origin (format "https://~a.fandom.com" wikiname))
|
||||||
(define origin (format "https://~a.fandom.com" wikiname))
|
(define source-url (format "~a/wiki/~a" origin prefixed-title))
|
||||||
(define source-url (format "~a/wiki/~a" origin prefixed-title))
|
|
||||||
|
|
||||||
(thread-let
|
(thread-let
|
||||||
([media-detail (define dest-url
|
([media-detail (define dest-url
|
||||||
(format "~a/wikia.php?~a"
|
(format "~a/wikia.php?~a"
|
||||||
origin
|
origin
|
||||||
(params->query `(("format" . "json")
|
(params->query `(("format" . "json")
|
||||||
("controller" . "Lightbox")
|
("controller" . "Lightbox")
|
||||||
("method" . "getMediaDetail")
|
("method" . "getMediaDetail")
|
||||||
("fileTitle" . prefixed-title)))))
|
("fileTitle" . prefixed-title)))))
|
||||||
(log-outgoing dest-url)
|
(log-outgoing dest-url)
|
||||||
(define dest-res (easy:get dest-url #:timeouts timeouts))
|
(define dest-res (easy:get dest-url #:timeouts timeouts))
|
||||||
(easy:response-json dest-res)]
|
(easy:response-json dest-res)]
|
||||||
[license (license-auto wikiname)])
|
[license (license-auto wikiname)])
|
||||||
|
|
||||||
(define title (jp "/fileTitle" page-data media-detail)))
|
(if (not (jp "/exists" media-detail #f))
|
||||||
(define body (generate-results-page
|
(next-dispatcher)
|
||||||
#:source-url source-url
|
(response-handler
|
||||||
#:wikiname wikiname
|
(define title (jp "/fileTitle" media-detail)))
|
||||||
#:title title
|
(define body (generate-results-page
|
||||||
#:media-detail media-detail
|
#:source-url source-url
|
||||||
#:license license))
|
#:wikiname wikiname
|
||||||
|
#:title title
|
||||||
|
#:media-detail media-detail
|
||||||
|
#:license license))
|
||||||
|
|
||||||
(when (config-true? 'debug)
|
(when (config-true? 'debug)
|
||||||
; used for its side effects
|
; used for its side effects
|
||||||
; convert to string with error checking, error will be raised if xexp is invalid
|
; convert to string with error checking, error will be raised if xexp is invalid
|
||||||
(xexp->html body))
|
(xexp->html body))
|
||||||
(response/output
|
(response/output
|
||||||
#:code 200
|
#:code 200
|
||||||
(λ (out)
|
(λ (out)
|
||||||
(write-html body out))))))
|
(write-html body out))))))
|
||||||
;(module+ test
|
;(module+ test
|
||||||
; (check-not-false ((query-selector (attribute-selector 'href "/test/wiki/Ankle_Monitor")
|
; (check-not-false ((query-selector (attribute-selector 'href "/test/wiki/Ankle_Monitor")
|
||||||
; (generate-results-page
|
; (generate-results-page
|
||||||
|
|
Loading…
Reference in a new issue