forked from cadence/breezewiki
Use <!DOCTYPE html> standards mode on all pages
This commit is contained in:
parent
1219334d06
commit
aab52bd92b
5 changed files with 101 additions and 82 deletions
|
@ -116,46 +116,48 @@
|
|||
; combine the above entries into a single request for potentially extra speed - fandom.com doesn't even do this!
|
||||
"~a/wikia.php?controller=ThemeApi&method=themeVariables"
|
||||
"~a/load.php?lang=en&modules=skin.fandomdesktop.styles%7Cext.fandom.PortableInfoboxFandomDesktop.css%7Cext.fandom.GlobalComponents.CommunityHeaderBackground.css%7Cext.gadget.site-styles%2Csound-styles%7Csite.styles&only=styles&skin=fandomdesktop")))
|
||||
`(html
|
||||
(head
|
||||
(meta (@ (name "viewport") (content "width=device-width, initial-scale=1")))
|
||||
(title ,(format "~a | ~a+~a"
|
||||
title
|
||||
(regexp-replace #rx" ?Wiki$" (siteinfo^-sitename siteinfo) "")
|
||||
(config-get 'application_name)))
|
||||
,@(map (λ (url)
|
||||
`(link (@ (rel "stylesheet") (type "text/css") (href ,url))))
|
||||
(required-styles (format "https://~a.fandom.com" wikiname)))
|
||||
(link (@ (rel "stylesheet") (type "text/css") (href ,(get-static-url "main.css"))))
|
||||
(script "const BWData = "
|
||||
,(jsexpr->string (hasheq 'wikiname wikiname
|
||||
'strict_proxy (config-true? 'strict_proxy))))
|
||||
,(if (config-true? 'feature_search_suggestions)
|
||||
`(script (@ (type "module") (src ,(get-static-url "search-suggestions.js"))))
|
||||
"")
|
||||
(link (@ (rel "icon") (href ,(u (λ (v) (config-true? 'strict_proxy))
|
||||
(λ (v) (u-proxy-url v))
|
||||
(head-data^-icon-url head-data))))))
|
||||
(body (@ (class ,(head-data^-body-class head-data)))
|
||||
(div (@ (class "main-container"))
|
||||
(div (@ (class "fandom-community-header__background tileHorizontally header")))
|
||||
(div (@ (class "page"))
|
||||
(main (@ (class "page__main"))
|
||||
,(niwa-notice wikiname title)
|
||||
(div (@ (class "custom-top"))
|
||||
(h1 (@ (class "page-title")) ,title)
|
||||
(nav (@ (class "sitesearch"))
|
||||
(form (@ (action ,(format "/~a/search" wikiname))
|
||||
(class "bw-search-form")
|
||||
(id "bw-pr-search-form"))
|
||||
(label (@ (for "bw-search-input")) "Search ")
|
||||
(div (@ (id "bw-pr-search-input"))
|
||||
(input (@ (type "text") (name "q") (id "bw-search-input") (autocomplete "off"))))
|
||||
(div (@ (class "bw-ss__container") (id "bw-pr-search-suggestions"))))))
|
||||
(div (@ (id "content") #;(class "page-content"))
|
||||
(div (@ (id "mw-content-text"))
|
||||
,content))
|
||||
,(application-footer source-url #:license (siteinfo^-license siteinfo))))))))
|
||||
`(*TOP*
|
||||
(*DECL* DOCTYPE html)
|
||||
(html
|
||||
(head
|
||||
(meta (@ (name "viewport") (content "width=device-width, initial-scale=1")))
|
||||
(title ,(format "~a | ~a+~a"
|
||||
title
|
||||
(regexp-replace #rx" ?Wiki$" (siteinfo^-sitename siteinfo) "")
|
||||
(config-get 'application_name)))
|
||||
,@(map (λ (url)
|
||||
`(link (@ (rel "stylesheet") (type "text/css") (href ,url))))
|
||||
(required-styles (format "https://~a.fandom.com" wikiname)))
|
||||
(link (@ (rel "stylesheet") (type "text/css") (href ,(get-static-url "main.css"))))
|
||||
(script "const BWData = "
|
||||
,(jsexpr->string (hasheq 'wikiname wikiname
|
||||
'strict_proxy (config-true? 'strict_proxy))))
|
||||
,(if (config-true? 'feature_search_suggestions)
|
||||
`(script (@ (type "module") (src ,(get-static-url "search-suggestions.js"))))
|
||||
"")
|
||||
(link (@ (rel "icon") (href ,(u (λ (v) (config-true? 'strict_proxy))
|
||||
(λ (v) (u-proxy-url v))
|
||||
(head-data^-icon-url head-data))))))
|
||||
(body (@ (class ,(head-data^-body-class head-data)))
|
||||
(div (@ (class "main-container"))
|
||||
(div (@ (class "fandom-community-header__background tileHorizontally header")))
|
||||
(div (@ (class "page"))
|
||||
(main (@ (class "page__main"))
|
||||
,(niwa-notice wikiname title)
|
||||
(div (@ (class "custom-top"))
|
||||
(h1 (@ (class "page-title")) ,title)
|
||||
(nav (@ (class "sitesearch"))
|
||||
(form (@ (action ,(format "/~a/search" wikiname))
|
||||
(class "bw-search-form")
|
||||
(id "bw-pr-search-form"))
|
||||
(label (@ (for "bw-search-input")) "Search ")
|
||||
(div (@ (id "bw-pr-search-input"))
|
||||
(input (@ (type "text") (name "q") (id "bw-search-input") (autocomplete "off"))))
|
||||
(div (@ (class "bw-ss__container") (id "bw-pr-search-suggestions"))))))
|
||||
(div (@ (id "content") #;(class "page-content"))
|
||||
(div (@ (id "mw-content-text"))
|
||||
,content))
|
||||
,(application-footer source-url #:license (siteinfo^-license siteinfo)))))))))
|
||||
(module+ test
|
||||
(define page
|
||||
(parameterize ([(config-parameter 'strict_proxy) "true"])
|
||||
|
|
|
@ -60,25 +60,27 @@
|
|||
(p "If you want to create your own wiki, try Miraheze!")))
|
||||
|
||||
(define body
|
||||
`(html
|
||||
(head
|
||||
(meta (@ (name "viewport") (content "width=device-width, initial-scale=1")))
|
||||
(title "About | BreezeWiki")
|
||||
(link (@ (rel "stylesheet") (type "text/css") (href ,(get-static-url "internal.css"))))
|
||||
(link (@ (rel "stylesheet") (type "text/css") (href ,(get-static-url "main.css"))))
|
||||
(link (@ (rel "icon") (href ,(head-data^-icon-url head-data-default)))))
|
||||
(body (@ (class "skin-fandomdesktop theme-fandomdesktop-light internal"))
|
||||
(div (@ (class "main-container"))
|
||||
(div (@ (class "fandom-community-header__background tileBoth header")))
|
||||
(div (@ (class "page"))
|
||||
(main (@ (class "page__main"))
|
||||
(div (@ (class "custom-top"))
|
||||
(h1 (@ (class "page-title"))
|
||||
"About BreezeWiki"))
|
||||
(div (@ (id "content") #;(class "page-content"))
|
||||
(div (@ (id "mw-content-text"))
|
||||
,@content))
|
||||
,(application-footer #f)))))))
|
||||
`(*TOP*
|
||||
(*DECL* DOCTYPE html)
|
||||
(html
|
||||
(head
|
||||
(meta (@ (name "viewport") (content "width=device-width, initial-scale=1")))
|
||||
(title "About | BreezeWiki")
|
||||
(link (@ (rel "stylesheet") (type "text/css") (href ,(get-static-url "internal.css"))))
|
||||
(link (@ (rel "stylesheet") (type "text/css") (href ,(get-static-url "main.css"))))
|
||||
(link (@ (rel "icon") (href ,(head-data^-icon-url head-data-default)))))
|
||||
(body (@ (class "skin-fandomdesktop theme-fandomdesktop-light internal"))
|
||||
(div (@ (class "main-container"))
|
||||
(div (@ (class "fandom-community-header__background tileBoth header")))
|
||||
(div (@ (class "page"))
|
||||
(main (@ (class "page__main"))
|
||||
(div (@ (class "custom-top"))
|
||||
(h1 (@ (class "page-title"))
|
||||
"About BreezeWiki"))
|
||||
(div (@ (id "content") #;(class "page-content"))
|
||||
(div (@ (id "mw-content-text"))
|
||||
,@content))
|
||||
,(application-footer #f))))))))
|
||||
(module+ test
|
||||
(check-not-false (xexp->html body)))
|
||||
|
||||
|
|
|
@ -175,14 +175,15 @@
|
|||
; proxy images from inline styles, if strict_proxy is set
|
||||
(curry u
|
||||
(λ (v) (config-true? 'strict_proxy))
|
||||
(λ (v) (attribute-maybe-update 'style
|
||||
(λ (style)
|
||||
(regexp-replace #rx"url\\(['\"]?(.*?)['\"]?\\)" style
|
||||
(λ (whole url)
|
||||
(string-append
|
||||
"url("
|
||||
(u-proxy-url url)
|
||||
")")))) v)))
|
||||
(λ (v) (attribute-maybe-update
|
||||
'style
|
||||
(λ (style)
|
||||
(regexp-replace #rx"url\\(['\"]?(.*?)['\"]?\\)" style
|
||||
(λ (whole url)
|
||||
(string-append
|
||||
"url("
|
||||
(u-proxy-url url)
|
||||
")")))) v)))
|
||||
; and also their links, if strict_proxy is set
|
||||
(curry u
|
||||
(λ (v)
|
||||
|
|
|
@ -12,7 +12,9 @@
|
|||
(define built (simple-form-path (build-path path-static f)))
|
||||
(values built (file-or-directory-modify-seconds built))))
|
||||
|
||||
(: get-static-url ((U String Path) -> String))
|
||||
(: get-static-url (Path-String -> String))
|
||||
(define (get-static-url path-or-filename)
|
||||
(define the-path (simple-form-path (if (path? path-or-filename) path-or-filename (build-path path-static path-or-filename))))
|
||||
(define the-path (simple-form-path (if (path? path-or-filename)
|
||||
path-or-filename
|
||||
(build-path path-static path-or-filename))))
|
||||
(format "/static/~a?t=~a" (file-name-from-path the-path) (hash-ref static-data the-path)))
|
||||
|
|
|
@ -157,20 +157,32 @@
|
|||
(define element-type (car element))
|
||||
(define attributes (bits->attributes (cdr element)))
|
||||
(define contents (filter element-is-content? (cdr element))) ; provide elements and strings
|
||||
(if (or (equal? element-type '*DECL)
|
||||
(equal? element-type '@)
|
||||
(equal? element-type '&))
|
||||
; special element, do nothing
|
||||
element
|
||||
; regular element, transform it
|
||||
(match (transformer element element-type attributes contents)
|
||||
[(list element-type attributes contents)
|
||||
(append (list element-type)
|
||||
(if (pair? attributes) (list (append '(@) attributes)) (list))
|
||||
(map (λ (content)
|
||||
(if (element-is-element? content) (loop content) content))
|
||||
contents))]))))
|
||||
(cond
|
||||
[(equal? element-type '*DECL*)
|
||||
; declarations like <!DOCTYPE html> get mapped as attributes as if the element were (*DECL* (@ (DOCTYPE) (html)))
|
||||
(match (transformer element element-type (map list (cdr element)) null)
|
||||
[(list element-type attributes contents)
|
||||
`(*DECL* ,@(map car attributes))]
|
||||
[#f ""])]
|
||||
[(member element-type '(@ &))
|
||||
; special element, do nothing
|
||||
element]
|
||||
[#t
|
||||
; regular element, transform it
|
||||
(match (transformer element element-type attributes contents)
|
||||
[(list element-type attributes contents)
|
||||
(append (list element-type)
|
||||
(if (pair? attributes) (list (append '(@) attributes)) (list))
|
||||
(map (λ (content)
|
||||
(if (element-is-element? content) (loop content) content))
|
||||
contents))])])))
|
||||
(module+ test
|
||||
; check doctype is preserved when present
|
||||
(check-equal? (update-tree (λ (e t a c) (list t a c)) '(*TOP* (*DECL* DOCTYPE html) (html (body "Hey"))))
|
||||
'(*TOP* (*DECL* DOCTYPE html) (html (body "Hey"))))
|
||||
; check doctype can be removed if desirable
|
||||
(check-equal? (update-tree (λ (e t a c) (if (eq? t '*DECL*) #f (list t a c))) '(*TOP* (*DECL* DOCTYPE html) (html (body "Hey"))))
|
||||
'(*TOP* "" (html (body "Hey"))))
|
||||
; check (& x) sequences are preserved
|
||||
(check-equal? (update-tree (λ (e t a c) (list t a c)) '(body "Hey" (& nbsp) (a (@ (href "/")))))
|
||||
'(body "Hey" (& nbsp) (a (@ (href "/"))))))
|
||||
|
|
Loading…
Reference in a new issue