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!
|
; 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/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")))
|
"~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
|
`(*TOP*
|
||||||
(head
|
(*DECL* DOCTYPE html)
|
||||||
(meta (@ (name "viewport") (content "width=device-width, initial-scale=1")))
|
(html
|
||||||
(title ,(format "~a | ~a+~a"
|
(head
|
||||||
title
|
(meta (@ (name "viewport") (content "width=device-width, initial-scale=1")))
|
||||||
(regexp-replace #rx" ?Wiki$" (siteinfo^-sitename siteinfo) "")
|
(title ,(format "~a | ~a+~a"
|
||||||
(config-get 'application_name)))
|
title
|
||||||
,@(map (λ (url)
|
(regexp-replace #rx" ?Wiki$" (siteinfo^-sitename siteinfo) "")
|
||||||
`(link (@ (rel "stylesheet") (type "text/css") (href ,url))))
|
(config-get 'application_name)))
|
||||||
(required-styles (format "https://~a.fandom.com" wikiname)))
|
,@(map (λ (url)
|
||||||
(link (@ (rel "stylesheet") (type "text/css") (href ,(get-static-url "main.css"))))
|
`(link (@ (rel "stylesheet") (type "text/css") (href ,url))))
|
||||||
(script "const BWData = "
|
(required-styles (format "https://~a.fandom.com" wikiname)))
|
||||||
,(jsexpr->string (hasheq 'wikiname wikiname
|
(link (@ (rel "stylesheet") (type "text/css") (href ,(get-static-url "main.css"))))
|
||||||
'strict_proxy (config-true? 'strict_proxy))))
|
(script "const BWData = "
|
||||||
,(if (config-true? 'feature_search_suggestions)
|
,(jsexpr->string (hasheq 'wikiname wikiname
|
||||||
`(script (@ (type "module") (src ,(get-static-url "search-suggestions.js"))))
|
'strict_proxy (config-true? 'strict_proxy))))
|
||||||
"")
|
,(if (config-true? 'feature_search_suggestions)
|
||||||
(link (@ (rel "icon") (href ,(u (λ (v) (config-true? 'strict_proxy))
|
`(script (@ (type "module") (src ,(get-static-url "search-suggestions.js"))))
|
||||||
(λ (v) (u-proxy-url v))
|
"")
|
||||||
(head-data^-icon-url head-data))))))
|
(link (@ (rel "icon") (href ,(u (λ (v) (config-true? 'strict_proxy))
|
||||||
(body (@ (class ,(head-data^-body-class head-data)))
|
(λ (v) (u-proxy-url v))
|
||||||
(div (@ (class "main-container"))
|
(head-data^-icon-url head-data))))))
|
||||||
(div (@ (class "fandom-community-header__background tileHorizontally header")))
|
(body (@ (class ,(head-data^-body-class head-data)))
|
||||||
(div (@ (class "page"))
|
(div (@ (class "main-container"))
|
||||||
(main (@ (class "page__main"))
|
(div (@ (class "fandom-community-header__background tileHorizontally header")))
|
||||||
,(niwa-notice wikiname title)
|
(div (@ (class "page"))
|
||||||
(div (@ (class "custom-top"))
|
(main (@ (class "page__main"))
|
||||||
(h1 (@ (class "page-title")) ,title)
|
,(niwa-notice wikiname title)
|
||||||
(nav (@ (class "sitesearch"))
|
(div (@ (class "custom-top"))
|
||||||
(form (@ (action ,(format "/~a/search" wikiname))
|
(h1 (@ (class "page-title")) ,title)
|
||||||
(class "bw-search-form")
|
(nav (@ (class "sitesearch"))
|
||||||
(id "bw-pr-search-form"))
|
(form (@ (action ,(format "/~a/search" wikiname))
|
||||||
(label (@ (for "bw-search-input")) "Search ")
|
(class "bw-search-form")
|
||||||
(div (@ (id "bw-pr-search-input"))
|
(id "bw-pr-search-form"))
|
||||||
(input (@ (type "text") (name "q") (id "bw-search-input") (autocomplete "off"))))
|
(label (@ (for "bw-search-input")) "Search ")
|
||||||
(div (@ (class "bw-ss__container") (id "bw-pr-search-suggestions"))))))
|
(div (@ (id "bw-pr-search-input"))
|
||||||
(div (@ (id "content") #;(class "page-content"))
|
(input (@ (type "text") (name "q") (id "bw-search-input") (autocomplete "off"))))
|
||||||
(div (@ (id "mw-content-text"))
|
(div (@ (class "bw-ss__container") (id "bw-pr-search-suggestions"))))))
|
||||||
,content))
|
(div (@ (id "content") #;(class "page-content"))
|
||||||
,(application-footer source-url #:license (siteinfo^-license siteinfo))))))))
|
(div (@ (id "mw-content-text"))
|
||||||
|
,content))
|
||||||
|
,(application-footer source-url #:license (siteinfo^-license siteinfo)))))))))
|
||||||
(module+ test
|
(module+ test
|
||||||
(define page
|
(define page
|
||||||
(parameterize ([(config-parameter 'strict_proxy) "true"])
|
(parameterize ([(config-parameter 'strict_proxy) "true"])
|
||||||
|
|
|
@ -60,25 +60,27 @@
|
||||||
(p "If you want to create your own wiki, try Miraheze!")))
|
(p "If you want to create your own wiki, try Miraheze!")))
|
||||||
|
|
||||||
(define body
|
(define body
|
||||||
`(html
|
`(*TOP*
|
||||||
(head
|
(*DECL* DOCTYPE html)
|
||||||
(meta (@ (name "viewport") (content "width=device-width, initial-scale=1")))
|
(html
|
||||||
(title "About | BreezeWiki")
|
(head
|
||||||
(link (@ (rel "stylesheet") (type "text/css") (href ,(get-static-url "internal.css"))))
|
(meta (@ (name "viewport") (content "width=device-width, initial-scale=1")))
|
||||||
(link (@ (rel "stylesheet") (type "text/css") (href ,(get-static-url "main.css"))))
|
(title "About | BreezeWiki")
|
||||||
(link (@ (rel "icon") (href ,(head-data^-icon-url head-data-default)))))
|
(link (@ (rel "stylesheet") (type "text/css") (href ,(get-static-url "internal.css"))))
|
||||||
(body (@ (class "skin-fandomdesktop theme-fandomdesktop-light internal"))
|
(link (@ (rel "stylesheet") (type "text/css") (href ,(get-static-url "main.css"))))
|
||||||
(div (@ (class "main-container"))
|
(link (@ (rel "icon") (href ,(head-data^-icon-url head-data-default)))))
|
||||||
(div (@ (class "fandom-community-header__background tileBoth header")))
|
(body (@ (class "skin-fandomdesktop theme-fandomdesktop-light internal"))
|
||||||
(div (@ (class "page"))
|
(div (@ (class "main-container"))
|
||||||
(main (@ (class "page__main"))
|
(div (@ (class "fandom-community-header__background tileBoth header")))
|
||||||
(div (@ (class "custom-top"))
|
(div (@ (class "page"))
|
||||||
(h1 (@ (class "page-title"))
|
(main (@ (class "page__main"))
|
||||||
"About BreezeWiki"))
|
(div (@ (class "custom-top"))
|
||||||
(div (@ (id "content") #;(class "page-content"))
|
(h1 (@ (class "page-title"))
|
||||||
(div (@ (id "mw-content-text"))
|
"About BreezeWiki"))
|
||||||
,@content))
|
(div (@ (id "content") #;(class "page-content"))
|
||||||
,(application-footer #f)))))))
|
(div (@ (id "mw-content-text"))
|
||||||
|
,@content))
|
||||||
|
,(application-footer #f))))))))
|
||||||
(module+ test
|
(module+ test
|
||||||
(check-not-false (xexp->html body)))
|
(check-not-false (xexp->html body)))
|
||||||
|
|
||||||
|
|
|
@ -175,14 +175,15 @@
|
||||||
; proxy images from inline styles, if strict_proxy is set
|
; proxy images from inline styles, if strict_proxy is set
|
||||||
(curry u
|
(curry u
|
||||||
(λ (v) (config-true? 'strict_proxy))
|
(λ (v) (config-true? 'strict_proxy))
|
||||||
(λ (v) (attribute-maybe-update 'style
|
(λ (v) (attribute-maybe-update
|
||||||
(λ (style)
|
'style
|
||||||
(regexp-replace #rx"url\\(['\"]?(.*?)['\"]?\\)" style
|
(λ (style)
|
||||||
(λ (whole url)
|
(regexp-replace #rx"url\\(['\"]?(.*?)['\"]?\\)" style
|
||||||
(string-append
|
(λ (whole url)
|
||||||
"url("
|
(string-append
|
||||||
(u-proxy-url url)
|
"url("
|
||||||
")")))) v)))
|
(u-proxy-url url)
|
||||||
|
")")))) v)))
|
||||||
; and also their links, if strict_proxy is set
|
; and also their links, if strict_proxy is set
|
||||||
(curry u
|
(curry u
|
||||||
(λ (v)
|
(λ (v)
|
||||||
|
|
|
@ -12,7 +12,9 @@
|
||||||
(define built (simple-form-path (build-path path-static f)))
|
(define built (simple-form-path (build-path path-static f)))
|
||||||
(values built (file-or-directory-modify-seconds built))))
|
(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 (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)))
|
(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 element-type (car element))
|
||||||
(define attributes (bits->attributes (cdr element)))
|
(define attributes (bits->attributes (cdr element)))
|
||||||
(define contents (filter element-is-content? (cdr element))) ; provide elements and strings
|
(define contents (filter element-is-content? (cdr element))) ; provide elements and strings
|
||||||
(if (or (equal? element-type '*DECL)
|
(cond
|
||||||
(equal? element-type '@)
|
[(equal? element-type '*DECL*)
|
||||||
(equal? element-type '&))
|
; declarations like <!DOCTYPE html> get mapped as attributes as if the element were (*DECL* (@ (DOCTYPE) (html)))
|
||||||
; special element, do nothing
|
(match (transformer element element-type (map list (cdr element)) null)
|
||||||
element
|
[(list element-type attributes contents)
|
||||||
; regular element, transform it
|
`(*DECL* ,@(map car attributes))]
|
||||||
(match (transformer element element-type attributes contents)
|
[#f ""])]
|
||||||
[(list element-type attributes contents)
|
[(member element-type '(@ &))
|
||||||
(append (list element-type)
|
; special element, do nothing
|
||||||
(if (pair? attributes) (list (append '(@) attributes)) (list))
|
element]
|
||||||
(map (λ (content)
|
[#t
|
||||||
(if (element-is-element? content) (loop content) content))
|
; regular element, transform it
|
||||||
contents))]))))
|
(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
|
(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 (& x) sequences are preserved
|
||||||
(check-equal? (update-tree (λ (e t a c) (list t a c)) '(body "Hey" (& nbsp) (a (@ (href "/")))))
|
(check-equal? (update-tree (λ (e t a c) (list t a c)) '(body "Hey" (& nbsp) (a (@ (href "/")))))
|
||||||
'(body "Hey" (& nbsp) (a (@ (href "/"))))))
|
'(body "Hey" (& nbsp) (a (@ (href "/"))))))
|
||||||
|
|
Loading…
Reference in a new issue