1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
(define-module (theme)
#:use-module (haunt html)
#:use-module (haunt site)
#:use-module (haunt post)
#:use-module (haunt artifact)
#:use-module (haunt builder blog)
#:use-module (sxml xpath)
#:use-module (sxml simple)
#:export (hwebs-theme
flat-page-template
now-page))
(define (post-uri post site prefix)
(string-append (or prefix "") "/"
(site-post-slug site post) ".html"))
(define (read-xml port)
(xml->sxml port))
;;
;; BLOG
;;
(define layout
(lambda (site title body)
`((doctype "html")
(html
(@ (lang "en"))
(head
(meta (@ (http-equiv "Content-Type")
(content "text/html")
(charset "utf-8")))
(meta (@ (name "viewport")
(content "width=device-width, initial-scale=1.0")))
(meta (@ (name "color-scheme")
(content "light dark")))
(link (@ (rel "stylesheet")
(href "/style.css")))
(link (@ (rel "icon")
(href "data:,")))
(link (@ (rel "alternate")
(type "application/atom+xml")
(title "Atom feed")
(href "/blog/feed.xml")))
(title ,(string-append title " — " (site-title site))))
(body
(header (span ,(assq-ref (site-default-metadata site) 'author))
(nav (ul (li (a (@ (href "/")) "Home"))
;; TODO stop hardcoding this href
(li (a (@ (href "/now.html")) "Now"))
(li (a (@ (href "/blog")) "Blog")))))
(main ,body)
(footer (span "© 2026 Henry J. Webster")
(ul (li (a (@ (href "https://git.hwebs.info/")) "Git Repos"))
(li (a (@ (href "https://www.linkedin.com/in/hwebs/")) "LinkedIn")))))))))
(define hwebs-theme
(theme #:name "hwebs"
#:layout layout
#:post-template
(lambda (post)
;; TODO fill in datetime correctly
;; TODO add <author>? (as hidden?)
`((article (h1 ,(post-title post))
(time ,(date->string*(post-date post)))
,(post-sxml post))))
#:collection-template
(lambda (site title posts prefix)
`((h1 ,title)
(p (a (@ (href "/blog/feed.xml")) "Atom feed."))
(ul
,@(map (lambda (post)
`(li (a (@ (href ,(post-uri post site prefix)))
,(post-ref post 'title)
" — "
,(date->string* (post-date post)))))
posts))))))
(define (flat-page-template site metadata body)
((theme-layout hwebs-theme) site (assq-ref metadata 'title) `((h1 ,(assq-ref metadata 'title)) ,body)))
;;
;; NOW
;;
(define (rss-items-template items)
`(ul
,@(map (lambda (item)
`(li ,item))
items)))
(define (rss-items feed)
((sxpath '(rss channel item title *text*)) feed))
;;; static pages that need some more
(define (static-page title file-name body)
(lambda (site posts)
(serialized-artifact file-name
;; TODO: simplify this
(with-layout hwebs-theme site title body)
sxml->html)))
(define* (now-page #:key title file-name feed)
(let ((items (rss-items (call-with-input-file feed read-xml))))
(define body
`((h1 ,title)
(p "My implementation of "
(a (@ (href "https://nownownow.com/about")) "the \"now\" page concept by Derek Sivers")
".")
(p "Normally I would have more on here but I'm in an experimental phase.")
(section (h2 "Recently Watched")
,(rss-items-template
(list-head items (min 5 (length items)))))))
(static-page title file-name body)))
|