First working album

This commit is contained in:
Quentin 2022-07-22 17:58:52 +02:00
parent f9192b4398
commit 4815462e89
Signed by: quentin
GPG key ID: E9602264D639FF68
2 changed files with 38 additions and 5 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
index.html

View file

@ -36,9 +36,41 @@ img {
padding: 10px;
}
"))
(body ()
,(map (lambda (filename) `(img (src ,filename))) (pictures path)))))
,(cons 'body (cons '() (map (lambda (filename) `(img (src ,filename))) (pictures path))))))
;(define (sexpr->html
(define (list->attr l)
(cond
((null? l) "")
(#t (string-append (format " ~A=\"~A\"" (car l) (cadr l)) (list->attr (cddr l))))))
(define (list->inner-html l)
(apply
string-append
(map
(lambda (v)
(cond
((list? v) (sexpr->html v))
(#t (format "~A" v))))
l)))
(define (sexpr->html s)
(cond
((null? (cddr s)) ; self-closing tag
(format "<~A~A/>~%" (car s) (list->attr (cadr s))))
(#t ; non self-closing tag
(string-append
; opening tag
(format "<~A~A>~%" (car s) (list->attr (cadr s)))
; inner content
(list->inner-html (cddr s))
; closing tag
(format "</~A>~%" (car s))))
))
(define (build src-folder dest-file)
(call-with-output-file
dest-file
(lambda (p)
(display (sexpr->html (albumize src-folder)) p)
)))