(module html mzscheme
(provide (all-defined))
(require (lib "kw.ss")
"default.scm")
(define-default current-page-title "A title" )
(define-default current-page-header '(h1 "A Header"))
(define-default current-page-body "A body")
(define-default current-page-content-type "text/html;charset=UTF-8")
(define-default current-page-style-sheet "")
(define/kw
(html-page #:key
(title (current-page-title))
(title-atts #f)
(header (current-page-header))
(head-atts #f)
(body (current-page-body))
(body-atts #f)
(style-sheet (current-page-style-sheet))
(content-type (current-page-content-type)))
(let ([title-atts (if title-atts (list title-atts) '())]
[head-atts (if head-atts (list head-atts) '())]
[body-atts (if body-atts (list body-atts) '())])
`(html (head (title ,@title-atts ,title)
(link ((rel "stylesheet")
(type "text/css")
(href ,style-sheet)))
(meta ((http-equiv "Content-Type")
(content ,content-type)))
,@head-atts)
(body ,@body-atts
,header
,body))))
(define (html-a-submit formname formitem id text)
`(a ((href ,(string-append
(format "javascript:document.~a.~a.value='~a';" formname formitem id)
(format "document.~a.submit();" formname))))
,text))
(define/kw (html-form name action #:key (method "post") (atts '()) #:body body)
`(form ((name ,name) (action ,action) (method ,method) ,@atts)
,@body))
(define/kw (html-input name #:key (type 'submit) (value "none") (src ""))
(let* ([atts '()])
(set! atts (cons `(name ,name) atts))
(set! atts (cons `(value ,value) atts))
(case type
[(image) `(input ((type "image") (src ,src) ,@atts))]
[(text) `(input ((type "text") ,@atts))]
[(submit) `(input ((type "submit") ,@atts))]
[(hidden) `(input ((type "hidden") ,@atts))])))
)