Use <!DOCTYPE html> standards mode on all pages

This commit is contained in:
Cadence Ember 2022-11-05 23:40:05 +13:00
parent 1219334d06
commit aab52bd92b
Signed by: cadence
GPG Key ID: BC1C2C61CF521B17
5 changed files with 101 additions and 82 deletions

View File

@ -116,7 +116,9 @@
; 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
`(*TOP*
(*DECL* DOCTYPE html)
(html
(head
(meta (@ (name "viewport") (content "width=device-width, initial-scale=1")))
(title ,(format "~a | ~a+~a"
@ -155,7 +157,7 @@
(div (@ (id "content") #;(class "page-content"))
(div (@ (id "mw-content-text"))
,content))
,(application-footer source-url #:license (siteinfo^-license siteinfo))))))))
,(application-footer source-url #:license (siteinfo^-license siteinfo)))))))))
(module+ test
(define page
(parameterize ([(config-parameter 'strict_proxy) "true"])

View File

@ -60,7 +60,9 @@
(p "If you want to create your own wiki, try Miraheze!")))
(define body
`(html
`(*TOP*
(*DECL* DOCTYPE html)
(html
(head
(meta (@ (name "viewport") (content "width=device-width, initial-scale=1")))
(title "About | BreezeWiki")
@ -78,7 +80,7 @@
(div (@ (id "content") #;(class "page-content"))
(div (@ (id "mw-content-text"))
,@content))
,(application-footer #f)))))))
,(application-footer #f))))))))
(module+ test
(check-not-false (xexp->html body)))

View File

@ -175,7 +175,8 @@
; proxy images from inline styles, if strict_proxy is set
(curry u
(λ (v) (config-true? 'strict_proxy))
(λ (v) (attribute-maybe-update 'style
(λ (v) (attribute-maybe-update
'style
(λ (style)
(regexp-replace #rx"url\\(['\"]?(.*?)['\"]?\\)" style
(λ (whole url)

View File

@ -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)))

View File

@ -157,11 +157,17 @@
(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 '&))
(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
element]
[#t
; regular element, transform it
(match (transformer element element-type attributes contents)
[(list element-type attributes contents)
@ -169,8 +175,14 @@
(if (pair? attributes) (list (append '(@) attributes)) (list))
(map (λ (content)
(if (element-is-element? content) (loop content) content))
contents))]))))
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 "/"))))))