Compare commits
No commits in common. "37318b8c50b640ce061163f6130a6b86f3e4968e" and "33ee6a0624f86053f670decf2b01fbe762e556e8" have entirely different histories.
37318b8c50
...
33ee6a0624
6 changed files with 44 additions and 102 deletions
|
@ -55,15 +55,7 @@
|
|||
" Media files and official Fandom documents have different copying restrictions.")
|
||||
(p ,(format "Fandom is a trademark of Fandom, Inc. ~a is not affiliated with Fandom." (config-get 'application_name))))))))
|
||||
|
||||
(define (generate-wiki-page
|
||||
content
|
||||
#:source-url source-url
|
||||
#:wikiname wikiname
|
||||
#:title title
|
||||
#:body-class [body-class-in ""])
|
||||
(define body-class (if (equal? "" body-class-in)
|
||||
"skin-fandomdesktop"
|
||||
body-class-in))
|
||||
(define (generate-wiki-page source-url wikiname title content)
|
||||
(define (required-styles origin)
|
||||
(map (λ (dest-path)
|
||||
(define url (format dest-path origin))
|
||||
|
@ -84,7 +76,7 @@
|
|||
`(link (@ (rel "stylesheet") (type "text/css") (href ,url))))
|
||||
(required-styles (format "https://~a.fandom.com" wikiname)))
|
||||
(link (@ (rel "stylesheet") (type "text/css") (href "/static/main.css"))))
|
||||
(body (@ (class ,body-class))
|
||||
(body (@ (class "skin-fandomdesktop theme-fandomdesktop-light"))
|
||||
(div (@ (class "main-container"))
|
||||
(div (@ (class "fandom-community-header__background tileHorizontally header")))
|
||||
(div (@ (class "page"))
|
||||
|
@ -102,11 +94,7 @@
|
|||
(module+ test
|
||||
(define page
|
||||
(parameterize ([(config-parameter 'strict_proxy) "true"])
|
||||
(generate-wiki-page
|
||||
'(template)
|
||||
#:source-url ""
|
||||
#:title "test"
|
||||
#:wikiname "test")))
|
||||
(generate-wiki-page "" "test" "test" '(template))))
|
||||
; check the page is a valid xexp
|
||||
(check-not-false (xexp->html page))
|
||||
; check the stylesheet is proxied
|
||||
|
|
|
@ -12,7 +12,9 @@
|
|||
|
||||
(provide
|
||||
; syntax to make the hashmap from names
|
||||
dispatcher-tree)
|
||||
dispatcher-tree
|
||||
; procedure to make the tree from the hashmap
|
||||
make-dispatcher-tree)
|
||||
|
||||
; make a hashmap out of the provided names and call make-dispatcher-tree with it
|
||||
(define-syntax (dispatcher-tree stx)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#lang racket/base
|
||||
(require racket/dict
|
||||
racket/list
|
||||
racket/match
|
||||
racket/string
|
||||
(prefix-in easy: net/http-easy)
|
||||
; html libs
|
||||
|
@ -27,19 +26,12 @@
|
|||
(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")))))))))
|
||||
|
||||
(define (generate-results-page
|
||||
#:source-url source-url
|
||||
#:wikiname wikiname
|
||||
#:prefixed-category prefixed-category
|
||||
#:members-data members-data
|
||||
#:page page
|
||||
#:body-class body-class)
|
||||
(define (generate-results-page dest-url wikiname prefixed-category members-data page)
|
||||
(define members (jp "/query/categorymembers" members-data))
|
||||
(generate-wiki-page
|
||||
#:source-url source-url
|
||||
#:wikiname wikiname
|
||||
#:title prefixed-category
|
||||
#:body-class body-class
|
||||
dest-url
|
||||
wikiname
|
||||
prefixed-category
|
||||
`(div
|
||||
,(update-tree-wiki page wikiname)
|
||||
(hr)
|
||||
|
@ -63,8 +55,7 @@
|
|||
(define source-url (format "~a/wiki/~a" origin prefixed-category))
|
||||
|
||||
(thread-let
|
||||
([members-data (define dest-url
|
||||
(format "~a/api.php?~a"
|
||||
([members-data (define dest-url (format "~a/api.php?~a"
|
||||
origin
|
||||
(params->query `(("action" . "query")
|
||||
("list" . "categorymembers")
|
||||
|
@ -75,12 +66,11 @@
|
|||
(printf "out: ~a~n" dest-url)
|
||||
(define dest-res (easy:get dest-url #:timeouts timeouts))
|
||||
(easy:response-json dest-res)]
|
||||
[page-data (define dest-url
|
||||
(format "~a/api.php?~a"
|
||||
[page-data (define dest-url (format "~a/api.php?~a"
|
||||
origin
|
||||
(params->query `(("action" . "parse")
|
||||
("page" . ,prefixed-category)
|
||||
("prop" . "text|headhtml|langlinks")
|
||||
("prop" . "text")
|
||||
("formatversion" . "2")
|
||||
("format" . "json")))))
|
||||
(printf "out: ~a~n" dest-url)
|
||||
|
@ -89,19 +79,7 @@
|
|||
|
||||
(define page-html (preprocess-html-wiki (jp "/parse/text" page-data "")))
|
||||
(define page (html->xexp page-html))
|
||||
(define head-html (jp "/parse/headhtml" page-data ""))
|
||||
(define body-class (match (regexp-match #rx"<body [^>]*class=\"([^\"]*)" head-html)
|
||||
[(list _ classes) classes]
|
||||
[_ ""]))
|
||||
(println head-html)
|
||||
(println body-class)
|
||||
(define body (generate-results-page
|
||||
#:source-url source-url
|
||||
#:wikiname wikiname
|
||||
#:prefixed-category prefixed-category
|
||||
#:members-data members-data
|
||||
#:page page
|
||||
#:body-class body-class))
|
||||
(define body (generate-results-page source-url wikiname prefixed-category members-data page))
|
||||
|
||||
(when (config-true? 'debug)
|
||||
; used for its side effects
|
||||
|
@ -113,9 +91,5 @@
|
|||
(write-html body out))))))
|
||||
(module+ test
|
||||
(check-not-false ((query-selector (attribute-selector 'href "/test/wiki/Ankle_Monitor")
|
||||
(generate-results-page
|
||||
#:source-url ""
|
||||
#:wikiname "test"
|
||||
#:prefixed-category "Category:Items"
|
||||
#:category-data category-json-data
|
||||
#:page '(div "page text"))))))
|
||||
(generate-results-page "" "test" "Category:Items" category-json-data
|
||||
'(div "page text"))))))
|
||||
|
|
|
@ -26,9 +26,9 @@
|
|||
(define (generate-results-page dest-url wikiname query data)
|
||||
(define search-results (jp "/query/search" data))
|
||||
(generate-wiki-page
|
||||
#:source-url dest-url
|
||||
#:wikiname wikiname
|
||||
#:title "Search Results"
|
||||
dest-url
|
||||
wikiname
|
||||
"Search Results"
|
||||
`(div (@ (class "mw-parser-output"))
|
||||
(p ,(format "~a results found for " (length search-results))
|
||||
(strong ,query))
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
(require racket/dict
|
||||
racket/function
|
||||
racket/list
|
||||
racket/match
|
||||
racket/string
|
||||
; libs
|
||||
(prefix-in easy: net/http-easy)
|
||||
|
@ -239,7 +238,7 @@
|
|||
origin
|
||||
(params->query `(("action" . "parse")
|
||||
("page" . ,path)
|
||||
("prop" . "text|headhtml|langlinks")
|
||||
("prop" . "text")
|
||||
("formatversion" . "2")
|
||||
("format" . "json")))))
|
||||
(printf "out: ~a~n" dest-url)
|
||||
|
@ -251,21 +250,12 @@
|
|||
[title (jp "/parse/title" data "")]
|
||||
[page-html (jp "/parse/text" data "")]
|
||||
[page-html (preprocess-html-wiki page-html)]
|
||||
[page (html->xexp page-html)]
|
||||
[head-html (jp "/parse/headhtml" data "")]
|
||||
[body-class (match (regexp-match #rx"<body [^>]*class=\"([^\"]*)" head-html)
|
||||
[(list _ classes) classes]
|
||||
[_ ""])])
|
||||
[page (html->xexp page-html)])
|
||||
(if (equal? "missingtitle" (jp "/error/code" data #f))
|
||||
(next-dispatcher)
|
||||
(response-handler
|
||||
(define body
|
||||
(generate-wiki-page
|
||||
(update-tree-wiki page wikiname)
|
||||
#:source-url source-url
|
||||
#:wikiname wikiname
|
||||
#:title title
|
||||
#:body-class body-class))
|
||||
(generate-wiki-page source-url wikiname title (update-tree-wiki page wikiname)))
|
||||
(define redirect-msg ((query-selector (attribute-selector 'class "redirectMsg") body)))
|
||||
(define headers (if redirect-msg
|
||||
(let* ([dest (get-attribute 'href (bits->attributes ((query-selector (λ (t a c) (eq? t 'a)) redirect-msg))))]
|
||||
|
|
|
@ -1,17 +1,11 @@
|
|||
/* reset the reset */
|
||||
blockquote, code, del, details, div, dl, dt, em, fieldset, figcaption, figure, h1, h2, h3, h4, h5, h6, li, ol, p, pre, q, span, strong, ul {
|
||||
font-family: sans-serif;
|
||||
blockquote, code, del, details, div, dl, dt, em, fieldset, figcaption, figure, h1, h2, h3, h4, h5, h6, li
|
||||
, ol, p, pre, q, span, strong, ul {
|
||||
font-family: initial;
|
||||
margin: initial;
|
||||
padding: initial;
|
||||
border: initial;
|
||||
}
|
||||
input, textarea {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
pre, code {
|
||||
font-family: monospace;
|
||||
font-size: 0.85em;
|
||||
}
|
||||
ul, ol {
|
||||
list-style-type: initial;
|
||||
padding-left: 2em;
|
||||
|
@ -29,6 +23,7 @@ sub {
|
|||
|
||||
/* general page appearance */
|
||||
body.skin-fandomdesktop, button, input, textarea, .wikitable, .va-table {
|
||||
font-family: initial;
|
||||
font-size: 18px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
@ -238,13 +233,6 @@ figcaption, .lightbox-caption, .thumbcaption {
|
|||
}
|
||||
}
|
||||
|
||||
@media (max-width: 699px) { /* narrower than 700 px */
|
||||
/* fit more text on screen */
|
||||
body.skin-fandomdesktop, button, input, textarea, .wikitable, .va-table {
|
||||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 560px) { /* wider than 560 px */
|
||||
/* footer columns */
|
||||
.custom-footer__cols {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue