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