...
 
Commits (2)
......@@ -162,7 +162,24 @@ exec guile -L $(pwd) -e '(@ (web) main)' -s "$0" "$@"
`(p (@ (class "error")) ,error)
'()))
(define (alist->class alist)
(define (make-value value)
(match value
((? string? string) string)
((? symbol? symbol) (symbol->string symbol))))
(define (make-style alist)
(let loop ((alist alist)
(out ""))
(if (null? alist)
(string-append out ";")
(loop (cdr alist)
(string-append out
"; "
(symbol->string (caar alist))
": "
(make-value (cdar alist)))))))
(define (make-class alist)
"Create html class attribute with an ALIST"
(let loop ((alist alist)
(out ""))
......@@ -176,21 +193,22 @@ exec guile -L $(pwd) -e '(@ (web) main)' -s "$0" "$@"
(let ((login-error (assoc-ref errors "login"))
(password-error (assoc-ref errors "password"))
(confirmation-error (assoc-ref errors "confirmation")))
(template "login"
`(form (@ (method "POST"))
(template "signup"
`(form (@ (method "POST")
(style ,(make-style `((border . "1px solid black")))))
(h2 "Sign up")
(div (@ (class ,(alist->class `(("form-item" . #t)
(div (@ (class ,(make-class `(("form-item" . #t)
("error" . ,login-error)))))
(p (label "login")
(input (@ (name "login")
(type "text"))))
,(maybe-error login-error))
(div (@ (class ,(alist->class `(("form-item" . #t)
(div (@ (class ,(make-class `(("form-item" . #t)
("error" . ,password-error)))))
(p (label "password")
(input (@ (name "password")
(type "password")))))
(div (@ (class ,(alist->class `(("form-item" . #t)
(div (@ (class ,(make-class `(("form-item" . #t)
("error" . ,confirmation-error)))))
(p (label "confirmation")
(input (@ (name "confirmation")
......