added poems and redesigned

This commit is contained in:
2017-04-03 15:19:07 +02:00
parent f697c77de5
commit e4aa56ee98
7 changed files with 81 additions and 22 deletions

1
.gitignore vendored
View File

@@ -1 +1,2 @@
index.html
out/

View File

@@ -4,28 +4,48 @@
(import-all "mustache")
(import-all "pandoc")
(define tpl (read-contents "layout.html"))
(define post-tpl (read-contents "post.html"))
(define list-tpl (read-contents "list.html"))
(define poem-dir "poems/")
(define out-dir "out/")
(define (all-poems)
(define (all-sites)
(let* ((ls (os:ls poem-dir))
(ls (filter ($ (not (in? ["." ".."] %))) ls)))
(map (curry ++ poem-dir) ls)))
ls))
(define (from-path file)
(regex:sub r/.md$/ "" (list:last (string:split file "/"))))
(define (all-poems elem)
(let* ((dir (++ poem-dir elem "/"))
(ls (os:ls dir))
(ls (filter ($ (not (in? ["." ".."] %))) ls)))
(map (curry ++ dir) ls)))
(define (filename file)
(list:last (string:split file "/")))
(define (treat str)
(regex:gsub r/<br \/>/ "</p><p>" (regex:gsub r/<p>/ "<p class='paragraph'>" str)))
(define (render targets)
(define (render name targets)
(let* ((strs (map read-contents targets))
(args (make-hash
"poems" (map (compose treat
(curry pandoc:convert "markdown" "html"))
strs))))
(with-output-file "index.html"
(curry write (mustache:template tpl args)))))
(with-output-file name
(curry write (mustache:template post-tpl args)))))
(let ((targets (all-poems)))
(render targets))
(define (make-index elems)
(let ((names (map ($ (make-hash
"name" (regex:gsub r/_/ " " %)
"url" (++ % ".html")))
elems)))
(with-output-file "index.html"
(curry write (mustache:template list-tpl (make-hash "names" names))))))
(let ((elems (all-sites)))
(map (lambda (elem)
(let ((targets (all-poems elem)))
(render (++ out-dir elem ".html") targets)))
elems)
(make-index elems))

15
list.html Normal file
View File

@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Veit's Poems</title>
<link rel="stylesheet" type="text/css" href="/poems/style.css">
</head>
<body>
<div id="links">
{{#names}}
<a class="elem" href="./{{url}}">{{name}}</a>
{{/names}}
</div>
</body>
</html>

View File

@@ -70,3 +70,26 @@ p {
size: auto;
margin: 0mm;
}
#links {
max-width: 600px;
padding-top: 10vh;
margin: auto;
}
.elem {
display: block;
width: 300px;
text-decoration: none;
color: #000;
margin: 1em;
font-size: 23px;
border-bottom: 5px solid;
box-sizing: border-box;
}
.elem:nth-child(odd) {
margin-left: 2em;
}
.elem:hover {
color: #666;
border-color: #666;
padding-left: 2em;
}