avoid repetition of post list table code
[~bandali/bndl.org] / haunt.scm
CommitLineData
85314da0
AB
1(use-modules (haunt asset)
2 (haunt builder blog)
3 (haunt builder atom)
4 (haunt builder assets)
99ac860d 5 (haunt builder rss)
85314da0
AB
6 (haunt html)
7 (haunt page)
8 (haunt post)
9 (haunt reader commonmark)
10 (haunt site)
11 (haunt utils)
12 (ice-9 match)
13 (srfi srfi-19))
14
8c2dfb46
AB
15(define my-scheme 'https)
16(define my-domain "bandali.eu.org")
17(define my-url
18 (string-append (symbol->string my-scheme) "://" my-domain))
cfff0eef 19(define my-tag-prefix "tags")
38037201 20(define my-date-format "~B ~e, ~Y")
2527e234 21
85314da0
AB
22(define (stylesheet name)
23 `(link (@ (rel "stylesheet")
24 (href ,(string-append "/" name ".css")))))
25
455bb137
AB
26(define* (aa content #:optional (uri content) . title)
27 `(a (@ (href ,uri) (title ,(apply string-append title))) ,content))
28
6f911f10 29(define* (base-layout site body #:key title copy license-page?)
85314da0
AB
30 `((doctype "html")
31 (html
32 (head
33 (meta (@ (charset "utf-8")))
34 (title ,(if title (string-append title " — " (site-title site))
35 "Amin Bandali’s Personal Site"))
36 ,(stylesheet "reset")
37 ,(stylesheet "style"))
38 (body
39 (main ,body)
40 (footer
6f911f10
AB
41 (p "Copyright © "
42 ,(if copy copy "2016–2019")
43 " Amin Bandali. See "
44 ,(if license-page? "the above"
45 (aa "license.html" "/license.html"))
61246b59 46 " for license conditions. Please copy and share."))))))
85314da0 47
cfff0eef
AB
48(define* (tag-uri prefix tag #:optional (ext ".html"))
49 "Return a URI relative to the site's root for a page listing entries
50in PREFIX that are tagged with TAG."
51 (string-append "/" my-tag-prefix "/" tag ext))
52
53(define* (tag-pages #:key
54 (theme bandali-theme)
55 (prefix "")
56 (filter posts/reverse-chronological))
57 "Return a builder procedure that renders a list page for every tag
58used in a post. All arguments are optional:
59
60PREFIX: The directory in which to write the posts
61FILTER: The procedure called to manipulate the posts list before rendering"
62 (lambda (site posts)
63 (define (tag-list tag posts all-posts)
64 (define (render-list title posts prefix)
65 (let ((body ((theme-collection-template theme)
66 site title posts prefix all-posts tag)))
67 ((theme-layout theme) site title body)))
68 (make-page (tag-uri my-tag-prefix tag)
69 (render-list (string-append "Notes tagged ‘" tag "’")
70 (filter posts)
71 prefix)
72 sxml->html))
73 (let ((tag-groups (posts/group-by-tag posts)))
74 (map (match-lambda
75 ((tag . tagged-posts) (tag-list tag tagged-posts posts)))
76 tag-groups))))
77
78(define (tag-links posts)
79 "Generate an alphabetically sorted list of links to tagged posts.
80The link text consists of the tag name and the number of tagged posts
81in parentheses."
82 `(ul (@ (class "tag-list"))
83 ,(map (match-lambda
84 ((tag . posts)
85 `(li
86 ,(aa (string-append tag
87 " ("
88 (number->string (length posts))
89 ")")
90 (tag-uri my-tag-prefix tag)))))
91 ;; sort by tag
92 (sort (posts/group-by-tag posts)
93 (lambda (a b) (string<? (car a) (car b)))))))
2527e234
AB
94
95(register-metadata-parser! 'updated string->date*)
cd5ad35b 96
cfff0eef
AB
97(define (intersperse lst delim)
98 "Return the elements of LST delimited by DELIM, such that the
99resulting list is of an odd length and every second element is DELIM."
100 (if (<= (length lst) 1)
101 lst
102 (cons* (car lst)
103 delim
104 (intersperse (cdr lst) delim))))
105
cd5ad35b 106(define (my-post-template post)
85314da0
AB
107 `((header
108 (h1 ,(post-ref post 'title))
455bb137 109 (address "By " ,(aa (post-ref post 'author) "/")
85314da0
AB
110 " <" ,(post-ref post 'email) ">")
111 (p (@ (class "date"))
2527e234
AB
112 "Published "
113 ,(date->string (post-date post) my-date-format))
114 ,(if (post-ref post 'updated)
115 `(p (@ (class "updated"))
116 "Updated "
117 ,(date->string (post-ref post 'updated)
cfff0eef
AB
118 my-date-format)) '())
119 ,(if (post-ref post 'tags)
120 `(p (@ (class "tags"))
121 "Tagged "
122 ,@(intersperse
123 (map (lambda (tag)
124 (aa tag (tag-uri my-tag-prefix tag)))
125 (post-ref post 'tags))
126 ", "))
127 '()))
90169139
AB
128 ,(post-sxml post)
129 (p (@ (class "muted inbox"))
130 "Have a question or comment? Start a discussion in my "
455bb137 131 ,(aa "public inbox" "https://lists.sr.ht/~bandali/public-inbox")
90169139 132 " by sending an email to "
455bb137
AB
133 ,(aa "~bandali/public-inbox@lists.sr.ht"
134 "mailto:~bandali/public-inbox@lists.sr.ht")
90169139 135 (small
455bb137
AB
136 " [" ,(aa "mailing list etiquette"
137 "https://man.sr.ht/lists.sr.ht/etiquette.md") "]")
90169139 138 ".")))
85314da0 139
60a33c6f
AB
140(define* (post-uri site post #:optional prefix)
141 (string-append (or prefix "") "/"
142 (site-post-slug site post) ".html"))
143
144(define* (post-list-table site posts #:optional prefix)
145 `((table
146 (@ (class "post-list"))
147 (tbody
148 ,@(map
149 (lambda (post)
150 `(tr
151 (td ,(aa (post-ref post 'title)
152 (post-uri site post prefix)))
153 (td (small ,(date->string (post-date post)
154 my-date-format)))))
155 posts)))))
156
cfff0eef
AB
157(define* (my-collection-template site title posts prefix
158 #:optional all-posts tag)
cfff0eef
AB
159 `((h2 ,title
160 ,(if tag
08d93db6
AB
161 (aa `(img (@ (class "feed-icon-h2")
162 (src "/icon-16px.png")
cfff0eef
AB
163 (alt "subscribe to atom feed")))
164 (tag-uri my-tag-prefix tag ".xml"))
165 '()))
60a33c6f 166 ,(post-list-table site posts prefix)
cfff0eef
AB
167 (h2 "Tags")
168 ,(tag-links (or all-posts posts))
169 ,(if tag
170 '(a (@ (href "/notes.html"))
08d93db6 171 "← all notes")
cfff0eef 172 '())))
85314da0
AB
173
174(define bandali-theme
175 (theme #:name "bandali"
176 #:layout
177 (lambda (site title body)
178 (base-layout site body
179 #:title title))
cd5ad35b
AB
180 #:post-template my-post-template
181 #:collection-template my-collection-template))
182
6f911f10 183(define* (static-page title file-name body copy #:key license?)
cd5ad35b
AB
184 (lambda (site posts)
185 (make-page file-name
6f911f10
AB
186 (base-layout site body #:title title #:copy copy
187 #:license-page? license?)
cd5ad35b 188 sxml->html)))
85314da0
AB
189
190(define (index-material site posts)
61246b59 191 `((h1 (@ (style "font-size: 0;"))
85314da0
AB
192 "Amin Bandali")
193 (p (@ (style "margin-top: 0;"))
194 "Hi, I’m "
455bb137
AB
195 ,(aa "Amin Bandali" "images/bandali-with-rms.jpg"
196 "photo of bandali with rms wearing a "
197 "“pay cash don’t be tracked” pin")
85314da0 198 ". I’m a graduate student at "
455bb137 199 ,(aa "WatForm" "https://watform.uwaterloo.ca")
85314da0 200 " at University of Waterloo, supervised by "
455bb137 201 ,(aa "Dr. Nancy Day" "https://cs.uwaterloo.ca/~nday/")
85314da0
AB
202 ". The main goal of my research is improving "
203 (strong "software and systems reliability")
204 " through application of " (em "formal methods") ".")
205 (p "My research at WatForm focuses on formal logic, model "
206 "checking, and verification. I’m also interested in "
207 "programming languages, theorem provers, and their "
208 "type systems. You may wish to view my academic "
455bb137 209 ,(aa "curriculum vitae" "bandali-cv.html") ".")
85314da0
AB
210 (p (@ (class "notice"))
211 (strong "SE 212 students: ")
455bb137
AB
212 "see " ,(aa "here" "se212-f19/") " for slides and other "
213 "material from the tutorials.")
85314da0 214 (p "On the side, I dabble in "
455bb137
AB
215 ,(aa "Lean" "https://leanprover.github.io") " and enjoy "
216 ,(aa "hacking" "https://stallman.org/articles/on-hacking.html")
85314da0 217 " on "
455bb137
AB
218 ,(aa "Elisp"
219 "https://www.gnu.org/software/emacs/manual/elisp.html")
220 ". I’m a " ,(aa "Free Software"
221 "https://www.gnu.org/philosophy/free-sw.html")
99ac860d 222 " activist, a GNU "
455bb137 223 ,(aa "maintainer" "https://www.gnu.org/people/#bandali")
85314da0 224 " and "
455bb137
AB
225 ,(aa "webmaster"
226 "https://www.gnu.org/people/webmeisters.html#bandali")
227 ", and an " ,(aa "associate member"
228 "https://www.fsf.org/associate/")
229 " of the " ,(aa "FSF" "https:///www.fsf.org"
230 "Free Software Foundation")
231 ". I co-host the " ,(aa "Emacs.el" "https://emacsel.com")
232 " podcast with " ,(aa "Daniel Gopar" "https://www.pygopar.com")
233 ", and organize " ,(aa "EmacsConf" "https://emacsconf.org")
234 " with help from many wonderful people. I am also a member of"
235 " the Systems Committee for the "
236 ,(aa "CSC" "https://csclub.uwaterloo.ca"
237 "Computer Science Club of the University of Waterloo")
85314da0 238 ".")
455bb137
AB
239 (p "See my " ,(aa "contact" "contact.html") " page for how to "
240 "best reach me.")
85314da0
AB
241 (h2 (@ (id "papers")) "Papers")
242 (dl
243 (dt "A Comparison of the Declarative Modelling Languages B, DASH,
244 and TLA" (sup "+")
90169139 245 (small
455bb137
AB
246 " [ " ,(aa "pdf" "papers/modre2018-declarative.pdf") " | "
247 ,(aa "bib" "papers/modre2018-declarative.bib") " ]"))
85314da0 248 (dd "Ali Abbassi, "
8c2dfb46 249 ,(aa "Amin Bandali" my-url) ", "
455bb137
AB
250 ,(aa "Nancy A. Day" "https://cs.uwaterloo.ca/~nday/") ", "
251 "Jose Serna"
85314da0
AB
252 (br)
253 (em "2018 IEEE 8th International Model-Driven Requirements"
254 " Engineering Workshop (MoDRE)")
255 (br)
256 "Copyright © 2018 IEEE. All Rights Reserved. Sadly."))
257 (h2 (@ (id "talks")) "Talks")
258 (dl
259 (dt
260 "The Magic of Specifications and Type Systems"
455bb137
AB
261 (small
262 " [ "
263 ,(aa "slides" "talks/cucsc-2017-slides.pdf"
264 "presented at the Canadian Undergraduate Computer Science"
265 " Conference 2017,\n"
266 "University of Toronto, Canada, June 15–17, 2017")
267 " | "
268 ,(aa "poster" "talks/eecs4080-poster.pdf"
269 "presented at the Lassonde Undergraduate Summer Student"
270 " Research Conference,\n"
271 "York University, Toronto, Canada, August 15, 2017")
272 " ]"))
8c2dfb46 273 (dd ,(aa "Amin Bandali" my-url) ", "
455bb137
AB
274 ,(aa "Simon Hudon" "https://github.com/cipher1024") ", "
275 ,(aa "Jonathan S. Ostroff"
276 "http://www.cse.yorku.ca/~jonathan/")))
85314da0
AB
277 (h2 (@ (id "projects")) "Projects")
278 (p "Below are a number of free software projects I have worked "
279 "on:")
280 (dl
455bb137 281 (dt ,(aa "george-mode" "https://git.sr.ht/~bandali/george-mode"))
85314da0 282 (dd "Emacs major mode for editing George files")
455bb137
AB
283 (dt ,(aa "alloy-catalyst"
284 "https://git.uwaterloo.ca/bandali/alloy-catalyst"))
85314da0 285 (dd "Framework for performance analysis of Alloy models")
455bb137 286 (dt ,(aa "unitb-web" "https://github.com/unitb/unitb-web"))
85314da0 287 (dd "Web interface for Unit-B")
455bb137 288 (dt ,(aa "tex2png-hs" "https://github.com/unitb/tex2png-hs"))
85314da0
AB
289 (dd "Library and CLI for converting TeX and LaTeX to PNG "
290 "images"))
291 (h2 (@ (id "notes")) "Notes")
22cb271b 292 (p "Here are notes about a variety of topics and issues I care "
08d93db6
AB
293 "about. They’re also available via "
294 ,(aa `((img (@ (class "feed-icon")
295 (src "/icon-12px.png")
296 (alt "subscribe to atom feed")))
297 "Atom")
298 "notes.atom")
299 " and "
300 ,(aa `((img (@ (class "feed-icon")
301 (src "/icon-12px.png")
302 (alt "subscribe to rss feed")))
303 "RSS") "notes.rss") " feeds.")
60a33c6f 304 ,(post-list-table site posts)))
85314da0
AB
305
306(define (index-page site posts)
307 (make-page
308 "index.html"
309 (base-layout site (index-material site posts))
310 sxml->html))
311
cd5ad35b
AB
312(define license-page
313 (static-page
6f911f10 314 "Licensing Information"
cd5ad35b 315 "license.html"
61246b59
AB
316 `((h1 "License information for "
317 ,(aa my-domain my-url))
cd5ad35b 318 (p "I strongly believe in "
455bb137
AB
319 ,(aa "free culture"
320 "https://questioncopyright.org/what_is_free_culture")
cd5ad35b 321 " and that all creative works everywhere should be "
455bb137 322 ,(aa "free" "https://freedomdefined.org/Definition") ".")
cd5ad35b
AB
323 (p "Unless otherwise noted material on this site is licensed "
324 "under the GNU General Public License as published by the "
325 "Free Software Foundation, either version 3 of the License, "
326 "or (at your option) any later version. A copy of the "
455bb137 327 "license is included at " ,(aa "gpl-3.0.html") ".")
cd5ad35b
AB
328 (p "Some resources on free software and licenses:")
329 (ul
455bb137
AB
330 (li ,(aa "What is free software?"
331 "https://www.gnu.org/philosophy/free-sw.html"))
332 (li ,(aa "Various Licenses and Comments about Them"
333 "https://www.gnu.org/licenses/license-list.html"))
334 (li ,(aa "Proprietary Software Is Often Malware"
6f911f10
AB
335 "https://www.gnu.org/proprietary/proprietary.html"))))
336 "2019"
337 #:license? #t))
cd5ad35b 338
7c12f0da
AB
339(define contact-page
340 (static-page
341 "Contact Information"
342 "contact.html"
343 `((h1 "Contact information")
344 (p "Email is by far my preferred method of communication. I may"
345 " be contacted at any of the following addresses (choose the"
346 " most closely related):")
347 (ul
348 (li "bandali@gnu.org")
349 (li "bandali@uwaterloo.ca")
350 (li "bandali@csclub.uwaterloo.ca"))
351 (p "If you want to send me GPG-encrypted mail, you can use my "
352 ,(aa "public key" "bandali-pubkey.txt") " with the"
353 " fingerprint "
354 (code "BE62 7373 8E61 6D6D 1B3A 08E8 A21A 0202 4881 6103")
355 ".")
356 (table
357 (tbody
358 (tr
359 (td "IRC")
360 (td "bandali on " ,(aa "freenode" "https://freenode.net") ", "
361 ,(aa "moznet" "https://wiki.mozilla.org/IRC") ", and "
362 ,(aa "oftc" "https://www.oftc.net")))
363 (tr
364 (td "XMPP")
365 (td ,(aa "bandali@member.fsf.org"
366 "xmpp:bandali@member.fsf.org")))
367 (tr
368 (td "Matrix")
369 (td ,(aa "@bandali:matrix.org"
370 "https://matrix.to/#/@bandali:matrix.org")))
371 (tr
372 (td "Fediverse")
373 (td ,(aa "@bandali@pleroma.site"
374 "https://pleroma.site/bandali")))))
375 (h2 "Elsewhere")
376 (p "You may also find me at a few other places online. Stricken"
377 " through accounts are those I don’t use anymore, unless"
378 " absolutely necessary.")
379 (ul
380 (li ,(aa "bandali" "https://libreplanet.org/wiki/User:Bandali")
381 " on LibrePlanet")
382 (li ,(aa "bandali" "https://emacsconf.org/bandali")
383 " on EmacsConf")
384 (li ,(aa "bandali" "https://savannah.gnu.org/users/bandali")
385 " on Savannah")
386 (li ,(aa "bandali" "https://git.sr.ht/~bandali")
387 " on Sourcehut")
388 (li ,(aa "bandali" "https://lobste.rs/u/bandali")
389 " on Lobsters")
390 (li ,(aa "bandali" "https://hackage.haskell.org/user/bandali")
391 " on Hackage")
392 (li ,(aa "bandali" "https://gitlab.com/bandali")
e810d7d1 393 " on GitLab")
7c12f0da
AB
394 (li ,(aa "bandali"
395 "https://news.ycombinator.com/user?id=bandali")
396 " on HN")
397 (li ,(aa "bandali" "https://www.reddit.com/u/bandali")
398 " on reddit")
399 (li (del ,(aa "bandali0" "https://github.com/bandali0")
400 " on GitHub"))
401 (li (del ,(aa "bandali0" "https://twitter.com/bandali0")
6f911f10
AB
402 " on Twitter"))))
403 "2019"))
7c12f0da 404
cd68557a
AB
405(define cv-page
406 (static-page
407 "Curriculum vitae"
408 "bandali-cv.html"
409 `((h1 "Curriculum vitae (" ,(aa "PDF" "bandali-cv.pdf") ")")
410 (table
411 (tbody
412 (tr
413 (td "Site")
414 (td ,(aa my-domain my-url)))
415 (tr
416 (td "Email")
417 (td "bandali@uwaterloo.ca"))
418 (tr
419 (td "Phone")
420 (td "available upon request via email"))))
421 (h2 "Education")
422 (h3 "Master of Mathematics (Computer Science) | 2018–present")
423 (p "University of Waterloo, Canada")
424 (p "Supervised by Dr. Nancy Day | GPA: 3.7/4.0 | "
425 "Expected completion: April 2020")
426 (p "Research focusing on formal logic, model checking, and "
427 "verification.")
428 (h3 "B.Sc. Honours Computer Science | 2013–2017")
429 (p "York University, Toronto, Canada")
430 (p "GPA: 7.84/9.0")
431 (p "Relevant courses: System Specification & Refinement, "
432 "Software Requirements Eng., Software Design, "
433 "Operating Systems, Computational Complexity, "
434 "Design & Analysis of Algorithms.")
435 (p "Finished first year (2013-14) at " (em "Carleton University")
436 " with a GPA of 11.0/12.0, then transferred to "
437 (em "York University") " in Fall 2014.")
438 (h2 "Publications")
439 (p "Listed on my " ,(aa "homepage" "/#papers"))
440 (h2 "Work & Research Experience")
441 (h3 "Cheriton School of Computer Science, University of Waterloo"
442 " | 2018–present")
443 (p "Instructional Apprentice, Teaching Assistant, "
444 "Research Assistant")
445 (ul
446 (li (abbr (@ (title "Logic and Computation")) "SE 212") ": "
447 (abbr (@ (title "Instructional Apprentice")) "IA") " in "
448 "Fall 2019, "
449 (abbr (@ (title "Teaching Assistant")) "TA") " in "
450 "Fall 2018")
451 (li (abbr (@ (title ,(string-append
452 "Software Requirements Specification and "
453 "Analysis"))) "SE 463")
454 ": TA in Summer 2019 and 2018")
455 (li (abbr (@ (title ,(string-append
456 "Elementary Algorithm Design and "
457 "Data Abstraction"))) "CS 136")
458 ": TA in Winter 2018"))
459 (h3 (abbr (@ (title
460 ,(string-append
461 "Electrical Engineering & Computer Science")))
462 "EECS")
463 " Department, York University | Fall 2017")
464 (p "Teaching Assistant")
465 (p (abbr (@ (title "Net-Centric Introduction to Computing"))
466 "EECS 1012")
6f911f10
AB
467 ": TA in Fall 2017"))
468 "2019"))
cd68557a 469
577bfe36
AB
470(define se212-f19-page
471 (static-page
472 "SE 212 Material"
473 "se212-f19/index.html"
474 `((h1 "Material from SE 212 tutorials")
475 (p "This page contains slides and other material from "
476 ,(aa "SE 212 tutorials"
477 "https://www.student.cs.uwaterloo.ca/~se212/times.html")
478 " held by me in Fall 2019. "
479 (del "If you have any questions, concerns, or suggestions "
480 "about the presented material, please email me at "
481 "bandali@uwaterloo.ca or come see me during my "
482 ,(aa "Friday office hours"
483 "https://www.student.cs.uwaterloo.ca/~se212/personnel.html")
484 "."))
485 (ul
486 (li "Tutorial 1:"
487 (ul
488 (li ,(aa "TUT 101 slides" "se212-t01-101.pdf"))
489 (li ,(aa "TUT 102 slides" "se212-t01-102.pdf"))
490 (li ,(aa "Org beamer sources" "se212-t01.org"))))
491 (li "Tutorial 2:"
492 (ul
493 (li ,(aa "Homework 2 q04d solution"
494 "se212-h02q04d-soln.grg"))))
495 (li "Tutorial 3: —")
496 (li "Tutorial 4: —")
497 (li "Tutorial 5:"
498 (ul
499 (li ,(aa "Slides" "se212-t05.pdf"))
500 (li ,(aa "Org beamer sources" "se212-t05.org"))))
501 (li "Tutorial 6: —")
502 (li "Tutorial 7: worked through questions 1–5 of Homework 7")
503 (li "Tutorial 8: —")
504 (li "Tutorial 9: —")
505 (li "Tutorial 10: worked through questions 1–10 of "
6f911f10
AB
506 "Homework 10")))
507 "2019"))
577bfe36 508
7e8d7215
AB
509(module-define!
510 (resolve-module '(haunt builder blog))
511 'render-post
512 (lambda (theme site post)
513 (let ((title (post-ref post 'title))
514 (body ((theme-post-template theme) post))
515 (copy (post-ref post 'copyright)))
516 (base-layout site body #:title title #:copy copy))))
517
85314da0 518(site #:title "Amin Bandali"
8c2dfb46
AB
519 ;; TODO: uncomment after new haunt release
520 ;; #:scheme my-scheme
85314da0
AB
521 #:domain my-domain
522 #:default-metadata
523 '((author . "Amin Bandali")
524 (email . "bandali@gnu.org")
525 (domain . my-domain))
526 #:readers (list commonmark-reader)
527 #:builders (list (blog #:theme bandali-theme
528 #:collections
529 `(("Notes" "notes.html"
530 ,posts/reverse-chronological)))
cfff0eef 531 (tag-pages)
85314da0 532 index-page
99ac860d 533 (atom-feed
cfff0eef 534 #:file-name "notes.atom")
99ac860d 535 (atom-feeds-by-tag
cfff0eef 536 #:prefix my-tag-prefix)
99ac860d 537 (rss-feed
cfff0eef 538 #:file-name "notes.rss")
7c12f0da 539 contact-page
cd68557a 540 cv-page
cd5ad35b 541 license-page
577bfe36 542 se212-f19-page
85314da0 543 (static-directory "static" "")))