First working album
This commit is contained in:
parent
f9192b4398
commit
4815462e89
2 changed files with 38 additions and 5 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
index.html
|
38
album.ss
38
album.ss
|
@ -36,9 +36,41 @@ img {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
"))
|
"))
|
||||||
(body ()
|
,(cons 'body (cons '() (map (lambda (filename) `(img (src ,filename))) (pictures path))))))
|
||||||
,(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)
|
||||||
|
)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue