...
 
Commits (2)
...@@ -162,7 +162,24 @@ exec guile -L $(pwd) -e '(@ (web) main)' -s "$0" "$@" ...@@ -162,7 +162,24 @@ exec guile -L $(pwd) -e '(@ (web) main)' -s "$0" "$@"
`(p (@ (class "error")) ,error) `(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" "Create html class attribute with an ALIST"
(let loop ((alist alist) (let loop ((alist alist)
(out "")) (out ""))
...@@ -176,21 +193,22 @@ exec guile -L $(pwd) -e '(@ (web) main)' -s "$0" "$@" ...@@ -176,21 +193,22 @@ exec guile -L $(pwd) -e '(@ (web) main)' -s "$0" "$@"
(let ((login-error (assoc-ref errors "login")) (let ((login-error (assoc-ref errors "login"))
(password-error (assoc-ref errors "password")) (password-error (assoc-ref errors "password"))
(confirmation-error (assoc-ref errors "confirmation"))) (confirmation-error (assoc-ref errors "confirmation")))
(template "login" (template "signup"
`(form (@ (method "POST")) `(form (@ (method "POST")
(style ,(make-style `((border . "1px solid black")))))
(h2 "Sign up") (h2 "Sign up")
(div (@ (class ,(alist->class `(("form-item" . #t) (div (@ (class ,(make-class `(("form-item" . #t)
("error" . ,login-error))))) ("error" . ,login-error)))))
(p (label "login") (p (label "login")
(input (@ (name "login") (input (@ (name "login")
(type "text")))) (type "text"))))
,(maybe-error login-error)) ,(maybe-error login-error))
(div (@ (class ,(alist->class `(("form-item" . #t) (div (@ (class ,(make-class `(("form-item" . #t)
("error" . ,password-error))))) ("error" . ,password-error)))))
(p (label "password") (p (label "password")
(input (@ (name "password") (input (@ (name "password")
(type "password"))))) (type "password")))))
(div (@ (class ,(alist->class `(("form-item" . #t) (div (@ (class ,(make-class `(("form-item" . #t)
("error" . ,confirmation-error))))) ("error" . ,confirmation-error)))))
(p (label "confirmation") (p (label "confirmation")
(input (@ (name "confirmation") (input (@ (name "confirmation")
......