make dashboard HTML standards-compliant by adding DOCTYPE and <title> element (closes #23)

pull/27/head
Matthew Butterick 10 years ago
parent dba97e6fd1
commit 451370c7e5

@ -15,9 +15,13 @@
(provide route-dashboard route-xexpr route-default route-404 route-in route-out) (provide route-dashboard route-xexpr route-default route-404 route-in route-out)
(define (body-wrapper content-xexpr) (define (response/xexpr+doctype xexpr)
(response/xexpr #:preamble #"<!DOCTYPE html>" xexpr))
(define (body-wrapper content-xexpr #:title [title #f])
`(html `(html
(head (head
(title ,(if title title "Pollen"))
(meta ([charset "UTF-8"])) (meta ([charset "UTF-8"]))
(link ([rel "stylesheet"] (link ([rel "stylesheet"]
[type "text/css"] [type "text/css"]
@ -49,7 +53,7 @@
(λ(req . string-args) (λ(req . string-args)
(logger req) (logger req)
(define path (apply build-path (world:current-project-root) (flatten string-args))) (define path (apply build-path (world:current-project-root) (flatten string-args)))
(response/xexpr (route-proc path)))) (response/xexpr+doctype (route-proc path))))
;; extract main xexpr from a path ;; extract main xexpr from a path
@ -190,7 +194,7 @@
(cached-require (->path dashboard-ptree) world:main-pollen-export) (cached-require (->path dashboard-ptree) world:main-pollen-export)
(directory->pagetree dashboard-dir)))))) (directory->pagetree dashboard-dir))))))
(body-wrapper (body-wrapper #:title (format "~a" dashboard-dir)
`(table `(table
,@(cons (make-parent-row) ,@(cons (make-parent-row)
(if (not (null? project-paths)) (if (not (null? project-paths))
@ -228,7 +232,7 @@
(request? . -> . response?) (request? . -> . response?)
(define error-text (format "route-404: Can't find ~a" (->string (req->path req)))) (define error-text (format "route-404: Can't find ~a" (->string (req->path req))))
(message error-text) (message error-text)
(response/xexpr `(html ,error-text))) (response/xexpr+doctype `(html ,error-text)))

Loading…
Cancel
Save