summaryrefslogtreecommitdiff
path: root/haunt.scm
blob: 3ce30c36f17f1522b63d4dc8249ae6adf0522bf7 (plain)
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
;;; pelzflorian.de website sources.
;;; Copyright © 2017 Florian Pelz
;;;
;;; This program is free software: you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation, either version 3 of the License, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program.  If not, see <http://www.gnu.org/licenses/>.

;;; This site is built with Haunt. See https://haunt.dthompson.us/ for
;;; instructions on where to get Haunt or just use your distribution’s
;;; package manager.
;;; Once Haunt is installed, just run `haunt build` inside the directory
;;; containing this file.
;;; TODO Well no because of translations, see the file NOTES.

;;; If you wish to contact me, find my contact information on:
;;; https://pelzflorian.de

;;; Sorry that some code here currently isn’t pretty yet.
;;; TODO Switch to the Meson build system and update the above comment
;;;      accordingly.
;;; TODO USE MORE ARIA E.G. FOR LIST ELEMENTS

(use-modules
 (gettext-po)
 (system ffi-help-rt)
 ((system foreign)
  #:prefix ffi:)
 (ice-9 i18n)
 (ice-9 match)
 (ice-9 regex)
 (srfi srfi-1)
 (srfi srfi-19)
 (haunt asset)
 (haunt html)
 (haunt page)
 (haunt post)
 (haunt reader)
 (haunt site)
 (haunt builder assets)
 (haunt builder atom)
 (haunt builder blog))

(define linguas
  (list "de"
        "en"))

(define (xerror-severity->string severity)
  "Returns the enum name for an integer specifying xerror severity."
  (cond ((= severity 0) "PO_SEVERITY_WARNING")
        ((= severity 1) "PO_SEVERITY_ERROR")
        ((= severity 2) "PO_SEVERITY_FATAL_ERROR")
        (else "")))

(define (xerror-output-proc-for-severity severity)
  "Given an xerror severity, returns which procedure to use to signal an \
xerror."
  (if (= severity 2)
      error
      ;; otherwise:
      (lambda args
        (begin
          (apply simple-format #t args)
          (newline)))))

(define (xerror-handler
         severity
         message
         filename
         lineno
         column
         multiline-p1
         message-text)
  (let ((output (xerror-output-proc-for-severity severity)))
    (output "Gettext xerror occurred!  ~A “~A” in ~A:~A."
            (xerror-severity->string severity)
            (ffi:pointer->string message-text)
            (ffi:pointer->string filename)
            lineno)))
(define ~xerror-handler
  (ffi:procedure->pointer
   ffi:void
   xerror-handler
   (list ffi:int
         '*
         '*
         ffi:size_t
         ffi:size_t
         ffi:int
         '*)))

(define (xerror2-handler severity message
                         filename1 lineno1 column1 multiline-p1 message-text1
                         filename2 lineno2 column2 multiline-p2 message-text2)
  (let ((output (xerror-output-proc-for-severity severity)))
    (output "Gettext xerror occurred!  ~A “~A” in ~A:~A, “~A” in ~A:~A."
            (xerror-severity->string severity)
            (ffi:pointer->string message-text1)
            (ffi:pointer->string filename1)
            lineno1
            (ffi:pointer->string message-text2)
            (ffi:pointer->string filename2)
            lineno2)))
(define ~xerror2-handler
  (ffi:procedure->pointer
   ffi:void
   xerror2-handler
   (list ffi:int
         '*
         '*
         ffi:size_t
         ffi:size_t
         ffi:int
         '*
         '*
         '*
         ffi:size_t
         ffi:size_t
         ffi:int '*)))

(define xerror-handler-struct
  (let ((new (make-struct-po_xerror_handler)))
    (begin
      (fh-object-set! new 'xerror (ffi:pointer-address ~xerror-handler))
      (fh-object-set! new 'xerror2 (ffi:pointer-address ~xerror2-handler))
      new)))

(define (translations-for-lingua lingua)
  "Returns po/<lingua>.po converted to an association list of msgid–msgstr \
pairs."
  ;; TODO: STILL DISREGARDING PLURALS AND OTHER INFORMATION
  (let* ((po-file
          (po_file_read_v3
           (string-append "po/" lingua ".po")
           (pointer-to xerror-handler-struct)))
         (translations
          (if (ffi:null-pointer? (unwrap~pointer po-file))
              '()
              ;; otherwise:
              (let ((iter (po_message_iterator po-file ffi:%null-pointer)))
                (let loop ((message (po_next_message iter)))
                  (if (ffi:null-pointer? (unwrap~pointer message))
                      (begin
                        (po_message_iterator_free iter)
                        '())
                      ;; otherwise:
                      (cons
                       (cons
                        (ffi:pointer->string (po_message_msgid message))
                        (ffi:pointer->string (po_message_msgstr message)))
                       (loop (po_next_message iter)))))))))
    (if (not (ffi:null-pointer? (unwrap~pointer po-file)))
        (po_file_free po-file))
    translations))

(define (translations-entry-for-lingua lingua)
  "Returns a pair of LINGUA and an association list of its translations."
  (cons
   lingua
   (translations-for-lingua lingua)))

(define translated-msg
  ;; gettext is not used directly because it would require repeated
  ;; setlocale calls, which should not be necessary.
  ;; See: https://stackoverflow.com/questions/3398113/php-gettext-problems
  (let ((translation-lists
         (map translations-entry-for-lingua linguas)))
    (define (with-default value default)
      (if value value
          default))
    (lambda (msgid lingua)
      "Returns the msgstr for MSGID from the po file for LINGUA."
      (let ((translations (assoc-ref translation-lists lingua)))
        (with-default
         (assoc-ref translations msgid)
         msgid)))))

;; TODO: Unused translations; incorporate into po file later:
;;
;;            ("Unsigned " . "Unsignierte ")
;;            ("macOS binaries (10.10 Yosemite or newer)" . "macOS-binärdateien (10.10 Yosemite oder neuer)")
;;            (" if you are still using macOS (you may need to follow the instructions
;; +from the macOS error messages on how to make macOS trust the binaries)." . ", falls
;; Sie noch immer macOS benutzen (eventuell müssen Sie den instructionen aus den macOS-fehlermeldungen,
;; wie sie macOS dazu bringen, den binärdateien zu vertrauen, folgen).")

(define-syntax _
  (lambda (x)
    "Gettext-like shorthand for translated-msg with what currently is \
current-lingua."
    (syntax-case x ()
      ((_ msg)
       (with-syntax ((current-lingua (datum->syntax x 'current-lingua)))
                    #'(translated-msg msg current-lingua))))))

(define (translated-multipart-msg msg lingua assoc)
  "Looks up MSG for LINGUA via Gettext and returns a list of its parts.

Parts are separated by two vertical bars ||.  If a part is prefixed by
a text followed by a vertical bar the text is looked up a lambda in
the association list ASSOC.  If found, the lambda is called on the
remainder of the part and the result added to the list.  If it is not
found or there is no vertical bar, the entire part is added to the
list."
  (define (split-along-unescaped-matches str pattern)
    "Splits along pattern unless pattern is escaped by a backslash."
    (let loop ((remainder str) ; what to match with
               (start 0)) ; where to start matching, used to ignore
                          ; escaped matches
      (let ((match (string-match pattern remainder start)))
        (if match ; if there is a match:
            (if (and
                 ;; if match not at the beginning
                 (not (= (match:start match) 0))
                 (eq? ; and escaped by a backslash
                  (string-ref
                   remainder
                   (- (match:start match) 1))
                  #\\))
                ;; then continue matching after the escaped match:
                (loop
                 (string-append ; the same as remainder but
                  (string-drop-right (match:prefix match) 1) ; drop backslash
                  (match:substring match)
                  (match:suffix match))
                 (- (match:end match) 1))
                ;; otherwise:
                (cons
                 ;; everything before the match
                 (match:prefix match)
                 (loop ; recursive call
                  (match:suffix match) ; on everything after the match
                  0))) ; start matching at start
            ;; if pattern did not match:
            (list remainder)))))
  (let ((msgstr-parts
         (split-along-unescaped-matches
          (translated-msg msg lingua)
          "\\\|\\\|")))
    (map
     (lambda (msgstr-part)
       (let* ((subparts
               (split-along-unescaped-matches
                msgstr-part
                "\\\|"))
              (from-assoc (assoc-ref assoc (car subparts)))
              (part-lambda (assoc-ref assoc (car subparts)))
              (args (cdr subparts)))
         (if part-lambda
             (if (procedure? part-lambda)
                 (apply part-lambda args)
                 ;; if in assoc but not a procedure, just insert it:
                 from-assoc)
             msgstr-part)))
     msgstr-parts)))

(define-syntax __
  (lambda (x)
    "Gettext shorthand for multipart messages separated by || in the string."
    (syntax-case x ()
      ((__ msg assoc)
       (with-syntax ((current-lingua (datum->syntax x 'current-lingua)))
                    #'(translated-multipart-msg msg current-lingua assoc))))))

(define (date->string-for-lingua date lingua)
  "Custom date->string* variant that deals with lingua and my no longer common \
German language orthographic preferences."
  (match lingua
         ("de"
          (string-append
           (case (date-week-day date)
             ((0) "Sonntag")
             ((1) "Montag")
             ((2) "Dienstag")
             ((3) "Mittwoch")
             ((4) "Donnerstag")
             ((5) "Freitag")
             ((6) "Samstag"))
           ", der "
           (number->string (date-day date))
           ". "
           (case (date-month date)
             ((1) "januar")
             ((2) "februar")
             ((3) "märz")
             ((4) "april")
             ((5) "mai")
             ((6) "juni")
             ((7) "juli")
             ((8) "august")
             ((9) "september")
             ((10) "october")
             ((11) "november")
             ((12) "december"))
           " "
           (number->string (date-year date))))
         ("en"
          (date->string* date))))

(define css-dir "css")
(define feeds-dir "feeds")
(define files-dir "files")
(define image-dir "images")
(define posts-dir "posts")
(define uni-dir "uni")

(define (build-url . path-list)
  "Make a string from path-list with a slash before each component."
  (string-join path-list "/" 'prefix))

(define (a-href url link-content)
  "A hyperlink."
  `(a (@ (href ,url))
      ,link-content))

(define (a-href-list-element url link-content)
  "A list element with a link."
  `(li
    (a (@ (href ,url)
          (class "full-width-link"))
       ,link-content)))

(define (a-href-sidebar-element url link-content)
  "A list element with a link."
  `(li
    (a (@ (href ,url)
          (class "sidebar-conditional-full-width-link"))
       ,link-content)))

(define (a-href-multi-list-element pairs link-content)
  "A list element linking to multiple formats. Pairs should be a list of pairs \
each consisting of a file extension and a url."
  `(li ,link-content
       ,@(map (lambda (pair)
                `(span
                  " "
                  "("
                  (span
                   (@ (class "file-extension"))
                   ,(a-href (cdr pair) (car pair))
                  ")"))
              pairs))))

(define (screenshot url title
                    thumbnail-url thumbnail-width thumbnail-height)
  "SXML for a screenshot.

URL: The URL of the full-size screenshot as a raster graphics image.
TITLE: The title for a link to the full image.
THUMBNAIL-URL: The URL to a smaller version of the image.
THUMBNAIL-WIDTH: The width of the thumbnail image.
THUMBNAIL-HEIGHT: The height of the thumbnail image." ; TODO AUTODETECT
  `(a (@ (href ,url)
         (title ,title))
      (img (@ (class "horizontally-padded-wide")
              (src ,thumbnail-url)
              (width ,(number->string thumbnail-width))
              (height ,(number->string thumbnail-height))
              (alt ,(string-append "Screenshot: " title))))))

(define (sortable-table-for-lingua row-list less-list caption lingua)
  "SXML for a sortable table.  ROW-LIST must be a list of equally long
lists of SXML (the rows).  The first row is used as the list header.
LESS-LIST must be a list of procedures for comparing the elements of
each column, or ‘#f’.  Each column with a procedure in LESS-LIST is
sortable."
  ;; TODO Once CSS4 allows for :has() selectors in browsers, reinsert
  ;; the radio buttons to choose the column to sort by instead of
  ;; using a select element.
  (let* ((current-lingua lingua)
         (header (car row-list))
         (content (cdr row-list))
         (1st-sortable-column
          (list-index procedure? less-list))
         (2nd-sortable-column
          (if 1st-sortable-column
              (+
               (1+ 1st-sortable-column)
               (list-index procedure?
                           (drop less-list
                                 (1+ 1st-sortable-column))))
              #f))
         (table-hash (number->string (string-length ; TODO use proper hash instead!
                                      (with-output-to-string
                                      (lambda ()
                                        (write `(,caption ,row-list))))))))
    (define (sort-content column-index less-proc)
      "The content rows sorted by the column having COLUMN-INDEX as
its index according to LESS-PROC."
      (stable-sort
       content
       (lambda (a b)
         (let ((col-in-a (list-ref a column-index))
               (col-in-b (list-ref b column-index)))
           (less-proc col-in-a col-in-b)))))
    (define (table-id table-number)
      (string-append
       "sortable-table-"
       table-hash
       "-table"
       (number->string table-number)))
    (define (radio-id table-number current-column)
      (string-append
       (table-id table-number)
       "-col"
       (number->string current-column)))
    (define (make-table column-index less-proc)
      `(table
        (@ (role "grid")
           (id ,(table-id column-index)))
        (caption (@ (class "vertically-padded-wide"))
                 ,caption)
        (tr
         (@ (role "row"))
         ,@(map (lambda (column-header current-column)
                  (if (= column-index current-column)
                      `(th (@ (aria-sort "descending")
                              (role "columnheader")
                              (scope "col"))
                           ,column-header)
                      ;; otherwise:
                      `(th ,column-header
                           ;; (input (@ (type "radio")
                           ;;           ,@(if (and
                           ;;                  (= column-index
                           ;;                     2nd-sortable-column)
                           ;;                  (= current-column
                           ;;                     1st-sortable-column))
                           ;;                 '((checked "checked"))
                           ;;                 '())
                           ;;           (name
                           ;;            ,(string-append
                           ;;              "sortable-table-"
                           ;;              table-hash
                           ;;              "-radios"))
                           ;;           (id
                           ;;            ,(radio-id
                           ;;              column-index
                           ;;             current-column))))
                           )))
                header
                (iota (length header))))
        ,(map
          (lambda (row)
            `(tr (@ (role "row"))
                 ,(map
                   (lambda (cell) `(td (@ (role "gridcell"))
                                       ,cell))
                   row)))
          (if less-proc
              (sort-content column-index less-proc)
              content))))

    (let ((header-length (length header)))
      `(div
        ,@(if 2nd-sortable-column
              `((style
                    ,@(map
                       (lambda (i)
                         (if (procedure? (list-ref less-list i))
                             (apply
                              string-append
                              `(
                                ;; tables without a sibling with a
                                ;; descendant that is a checked matching
                                ;; radio button should not be visible
                                ;; TODO Disabled until CSS4 is
                                ;; supported:

                                ;; "#"
                                ;; ,(table-id i)
                                ;; ":has("
                                ;; ,(string-join
                                ;;   (fold
                                ;;    (lambda (j selectors)
                                ;;      (if (not (= i j))
                                ;;          (cons
                                ;;           (string-append
                                ;;            ":not(#"
                                ;;            (radio-id j i)
                                ;;            ":checked)")
                                ;;           selectors)
                                ;;          selectors))
                                ;;    ;; initially no selectors:
                                ;;    '()
                                ;;    (iota header-length))
                                ;;   ",")
                                ;; ")"

                                "#"
                                ,(table-id i)
                                "-button"
                                ":checked"
                                " ~ "
                                "#"
                                ,(table-id i)
                                " { display : table; } "
                                "#"
                                ,(table-id i)

                                " { display : none; } "))
                             '()))
                       (iota header-length))))
              ;; Don’t style if there are not enough sortable columns.
              '())

        ,(if (not 2nd-sortable-column)
             ;; If the number of sortable columns is < 2, draw the
             ;; table once.
             (make-table #f #f) ; do not sort
             ;; Otherwise draw many tables.
             `(div
               ;; TODO Delete these buttons when CSS4 allows using
               ;; radio buttons instead.
               ,(_ "Sort by:")
               " "
               ,@(fold
                  (lambda (column-index other-buttons)
                    (let ((less-proc (list-ref
                                      less-list
                                      column-index)))
                      (if (procedure? less-proc)
                          (cons
                           `(label (@ (for ,(string-append
                                             (table-id column-index)
                                             "-button")))
                                   ,(list-ref header column-index))
                           (cons
                            `(input (@ (type "radio")
                                       ,@(if (= column-index
                                                1st-sortable-column)
                                             '((checked "checked"))
                                             '())
                                       (id ,(string-append
                                             (table-id column-index)
                                             "-button"))
                                       (name
                                        ,(string-append
                                          "sortable-table-"
                                          table-hash
                                          "-radios"))))
                            other-buttons))
                          other-buttons)))
                  '()
                  (iota header-length (- header-length 1) -1))

               ,@(fold
                  (lambda (column-index other-tables)
                    (let ((less-proc (list-ref
                                      less-list
                                      column-index)))
                      (if (procedure? less-proc)
                          (cons
                           ;; Cons the table sorted by LESS-PROC to
                           ;; the other table variants.
                           (make-table column-index less-proc)
                           other-tables)
                          ;; If LESS-PROC is not a procedure, just
                          ;; take the rest:
                          other-tables)))
                  '()
                  (iota header-length (- header-length 1) -1))))))))

(define (back-button-for-lingua lingua)
  "SXML for a link back to the home page."
  (let ((current-lingua lingua))
    `(a (@ (href ,(string-append "/index" "-" lingua ".html"))
           (class "full-width-link"))
        ,(_ "← Back to home page"))))

(define (recent-post-link-for-lingua lingua)
  "SXML for a link to all other posts in this lingua."
  (let ((current-lingua lingua))
    (a-href (build-url posts-dir
                       current-lingua
                       "index.html")
            (_ "See other posts."))))

(define (recent-post-link-for-tag-for-lingua tag description lingua)
  "SXML for a link to posts with a certain tag."
  (let ((current-lingua lingua))
    `(a (@ (href ,(build-url feeds-dir
                             current-lingua
                             (string-append
                              tag
                              ".xml"))))
        ,@(__ "See other posts about ||descrip_||."
              `(("descrip_" . ,description))))))

(define (tags-for-post-for-lingua post lingua)
  "SXML for a list of tags of a post."
  (let ((tags (sort (post-ref post 'tags) string-ci<?))
        (current-lingua lingua))
    (if (not (null? tags))
        `(div
          ,(_ "Tags:")
          ,@(map (lambda (tag)
                   `(span (@ (class "horizontally-padded"))
                          (a (@ (href
                                 ,(build-url feeds-dir
                                             current-lingua
                                             (string-append
                                              tag
                                              ".xml"))))
                             ,tag)))
                 tags))
        "")))

(define (format-post-for-lingua post lingua)
  "SXML including the content of the post, or nothing if post is not a post."
  (if (post? post)
      `(div
        (h1 (a (@ (href ,(build-url posts-dir
                                    lingua
                                    (string-append
                                     (post-slug post)
                                     ".html"))))
               ,(post-ref post 'title)))
        (h2 ,(date->string-for-lingua
              (post-date post) lingua))
        (div
         ,(post-sxml post)))
      "")) ; don’t print any posts if there are no posts yet

(define* (pelzflorian-blue-layout current-lingua #:optional (is-homepage? #f))
  "Template layout for all the blog’s pages. If is-homepage is set, shows no \
back button."
  (lambda (site title body)
    (define (link-to-css filename)
      `(link
        (@ (rel "stylesheet")
           (type "text/css")
           (href ,(build-url css-dir filename)))))
    (define (link-to-feed lingua)
      (let ((current-lingua lingua))
        `(link
          (@ (rel "alternate")
             (type "application/atom+xml")
             ;; TODO Gettext *should* pass the following on into the
             ;; pot file but does not. Why?
             ;; TRANSLATORS: This should be the current language.
             (title ,(_ "My blog in English"))
             (hreflang ,lingua)
             (href
              ,(build-url feeds-dir lingua "feed.xml"))))))
    `((doctype "html")
      (html
       (@ (lang ,(_ "@ietf-lang-tag")))
       (head
        (meta (@ (charset "utf-8")))
        ;; remove ASAP once @viewport becomes normative in CSS:
        (meta (@ (name "viewport")
                 (content "width=device-width, initial-scale=1")))
        (title ,(string-join `(,title "–" ,(site-title site))))
        (link
         (@ (rel "icon")
            (type "image/png")
            (href
             ,(build-url image-dir "favicon.png"))))
        ;; reference Atom feeds for all linguas, current lingua on top
        ,(link-to-feed current-lingua)
        ,(map (lambda (lingua)
                (if (not (equal? lingua current-lingua))
                    (link-to-feed lingua)
                    ""))
              linguas)
        ,(link-to-css "common.css"))
       (body
        (div (@ (id "top-bar"))
             (div (@ (id "name-div"))
                  ,(site-title site))
             (div (@ (id "top-div"))
                  (div (@ (id "linguas-div"))
                       ,(map (lambda (lingua)
                               `(span (@ (class "horizontally-padded"))
                                      ,(if (equal? lingua current-lingua)
                                           lingua
                                           (a-href
                                            ;; TODO LINK TO CORRESPONDING PAGE
                                            (string-append
                                             "/"
                                             "index-"
                                             lingua
                                             ".html")
                                            lingua))))
                             linguas))))
        (div (@ (id "center"))
             (nav (@ (id "side-bar"))
                  ,(if (not is-homepage?)
                       (back-button-for-lingua current-lingua)
                       "")
                  (div (@ (id "link-div"))
                       (ul
                        ,(a-href-sidebar-element
                          "/git/"
                          (_ "Git Projects"))
                        ,(a-href-sidebar-element
                          (string-append
                           "/dont-hang/index-"
                           current-lingua
                           ".html")
                          (_ "Don’t Hang"))
                        ,(a-href-sidebar-element
                          (string-append
                           "/theater/index-"
                           current-lingua
                           ".html")
                          (_ "Theater für Kappler Grundschulkinder"))
                        ,(a-href-sidebar-element
                          (string-append
                           "/old-stuff-"
                           current-lingua
                           ".html")
                          (_ "Old stuff"))
                        ,(a-href-sidebar-element
                          (string-append
                           "/gui-prog-gtk-2017/index-"
                           current-lingua
                           ".html")
                          (_ "GTK+ Workshop 2017"))
                        ,(a-href-sidebar-element
                          (string-append
                           "/gui-prog-gtk-2016/index-"
                           current-lingua
                           ".html")
                          (_ "GTK+ Workshop 2016"))
                        ,(a-href-sidebar-element
                          (build-url feeds-dir current-lingua "feed.xml")
                          (_ "Subscribe to Atom feed")))))
             (div (@ (id "content"))
                  ,body
                  (footer
                   (div (@ (id "contact"))
                        (h1
                         (@ (class "contact-heading"))
                         ,(_ "Contact me:"))
                        (div
                         ,(_ "Mail:")
                         " "
                         (a (@ (href "mailto:pelzflorian@pelzflorian.de"))
                            "pelzflorian@pelzflorian.de"))
                        (div
                         "XMPP:"
                         " "
                         (a
                          (@
                           (href
                            "xmpp:pelzflorian@chat.pelzflorian.de?message"))
                          "pelzflorian@chat.pelzflorian.de"))
                        (div
                         ,@(__ "GnuPG key: ||gnupglink_|| (valid until \
||gnupgexp_||)"
                               `(("gnupglink_" .
                                  ,(a-href
                                   "/files/key.asc"
                                   "0x4947055B"))
                                 ("gnupgexp_" .
                                  "01/27/2019")))))
                   (div (@ (id "source-code-link"))
                        ,@(__ "Find the source code for this website \
||link_|here||."
                              `(("link_" .
                                 ,(lambda (text)
                                    `(a (@ (href ,(build-url
                                                   "git"
                                                   "pelzfloriande-website")))
                                        ,text))))))
                   (div (@ (id "powered-by"))
                        ,@(__ "Powered by \
||link_|https://www.gnu.org/software/guile/|GNU Guile|| and \
||link_|https://haunt.dthompson.us/|Haunt||."
                              `(("link_" . ,a-href))))))))))))

(define (pelzflorian-blue-theme current-lingua)
  "Returns the blog’s theme for the lingua."
  (theme #:name "Pelzflorian Blue"
         #:layout
         (pelzflorian-blue-layout current-lingua)
         #:post-template
         (lambda (post)
           `(div
             (h1 ,(post-ref post 'title))
             (h2 ,(date->string-for-lingua (post-date post) current-lingua))
             (div ,(post-sxml post))
             ,(tags-for-post-for-lingua post current-lingua)
             (div (@ (class "vertically-padded"))
                  ,(recent-post-link-for-lingua current-lingua))
             (div (@ (class "vertically-padded"))
                  ,(back-button-for-lingua current-lingua))))
         #:collection-template
         (lambda (site title posts prefix)
           `(div
             (h1 ,(_ "Recent posts"))
             (ol
              ,@(map (lambda (post)
                       `(li
                         (a (@ (href
                                ,(build-url posts-dir
                                            current-lingua
                                            (string-append
                                             (post-slug post)
                                             ".html")))
                               (class "full-width-link"))
                            ,(string-append
                              (post-ref post 'title)
                              " ("
                              (date->string-for-lingua
                               (post-date post)
                               current-lingua)
                              ")"))))
                     (posts/reverse-chronological posts)))
             ,(back-button-for-lingua current-lingua)))))

(define (old-stuff-page-for-lingua lingua)
  (let* ((current-lingua lingua)
         (body
          `(div
            (h1 ,(_ "Lecture notes"))
            (div ,(_ "Some German lecture summaries I made for lectures I \
heard in 2013:"))
            (ul
             ,(a-href-multi-list-element
               '(("Pdf" . "/uni/fp_zusammenfassung.pdf")
                 ("Tex" . "/uni/fp_zusammenfassung.tex"))
               "Logik")
             ,(a-href-multi-list-element
               '(("Pdf" . "/uni/insy_noticen.pdf")
                 ("Tex" . "/uni/insy_noticen.tex"))
               "Insy"))
            (h1 ,(_ "C exercises (German)"))
            (p ,(_ "Includes a cheat sheet for working with C."))
            (ul
             ,(a-href-list-element
               "/c_exercises.htm"
               (_ "C Exercises")))
            ,(back-button-for-lingua lingua))))
    (lambda (site posts)
      (make-page (string-append "old-stuff" "-" lingua ".html")
                 (with-layout
                  (pelzflorian-blue-theme lingua)
                  site
                  (_ "Old stuff")
                  body)
                 sxml->html))))

(define (dont-hang-page-for-lingua lingua)
  (let ((current-lingua lingua))
    (lambda (site posts)
      (let ((body
             `(div
               (h1 ,(_ "Don’t Hang"))

               (div (@ (class "app-logo"))
                    (img (@ (src "dont-hang.svg")
                            (alt "Don’t Hang logo"))))

               (p ,(_ "A simple GTK+ hangman game inspired by bsd-games’ \
hangman."))
               (p ,(_ "“Don’t Hang” is a simple hangman game for acquiring \
and consolidating a basic vocabulary in a foreign language. It supports \
loading custom word lists and works with Unicode and bidirectional text. It \
also supports pasting characters from the clipboard."))
               (p ,(_ "It is free software and also publicly available at no \
cost."))

               (h1 ,(_ "Screenshots"))
               (div (@ (class "centered"))
                    ,(screenshot "screenshots/01.png" (_ "Guessing an \
expression") "screenshots/01-thumb.png" 224 126)
                    ,(screenshot "screenshots/02.png" (_ "Right-to-left \
support") "screenshots/02-thumb.png" 224 126))

               ,(let* ((posts-about-dont-hang
                        (assoc-ref
                         (posts/group-by-tag posts) "dont-hang")))
                  (if (and posts-about-dont-hang
                           (not (null? posts-about-dont-hang)))
                      (let ((most-recent-post-about-dont-hang
                             (car
                              (posts/reverse-chronological
                               posts-about-dont-hang))))
                        `(div
                          (h1 ,(_ "News"))
                          ,(format-post-for-lingua
                            most-recent-post-about-dont-hang
                            current-lingua)
                          ,(recent-post-link-for-tag-for-lingua
                            "dont-hang"
                            (_ "“Don’t Hang”")
                            current-lingua)))
                      ""))

               (h1 ,(_ "Downloads"))
               (ul
                ,(a-href-list-element
                  "dont-hang-1.1.tar.gz"
                  (_ "“Don’t Hang” version 1.1 Source code."))
                ,(a-href-list-element
                  "/git/dont-hang/"
                  (_ "Current development version."))
                (li ,@(__ "aurlink_|“Don’t Hang” for Arch Linux|| and \
derivative GNU distributions such as \
||parabolalink_|Parabola GNU/Linux-libre||."
                          `(("aurlink_" .
                             ,(lambda (text)
                                (a-href
                                 "https://aur.archlinux.org/packages/dont-hang"
                                 text)))
                            ("parabolalink_" .
                             ,(lambda (text)
                                (a-href
                                 "https://www.parabola.nu"
                                 text))))))
                (li
                    ;; (a (@ (href
                    ;;        "binaries/windows/dont-hang-1.1.msi"))
                    ;;    ,(_ "Windows installer (x86)"))
                    ;; ,(_ " as well as ")
                    (a (@ (href
                           "binaries/windows/dont-hang-1.1.zip"))
                       ,(_ "“portable” binaries without installer"))
                    ,(_ " if you are still using Windows, all built using ")
                    (a (@ (href "http://www.msys2.org")) "MSYS2")
                    ,(_ " for which the source files are available at their
home page."))
;;                 (li ,(_ "Unsigned ")
;;                     (a (@ (href
;;                            "binaries/macos/dont-hang-1.1.dmg"))
;;                        ,(_ "macOS binaries (10.10 Yosemite or newer)"))
;;                     ,(_ " if you are still using macOS (you may need to \
;; follow the instructions from the macOS error messages on how to make \
;; macOS trust the binaries)."))
                )
               (h1 ,(_ "Word lists"))
               (p ,@(__ "“Don’t Hang” by default uses the words from \
the ||ic_|/usr/share/dict|| directory, but it can deal with any list of \
expressions in a text file with one expression per line. ||samplelink_|Here|| \
is an example word list file compiled with words from \
||wiktionarylink_|Wiktionary’s list of 1000 basic English words|| which you \
can use if you want simpler words. This sample word list is available under \
the terms of ||ccbysalink_|the CC-BY-SA 3.0 Unported license||, because \
Wiktionary uses this license and the words are taken from there."
                        `(("ic_" .
                           ,(lambda (text)
                              `(span (@ (class "inline-code"))
                                     ,text)))
                          ("samplelink_" .
                           ,(lambda (text)
                              (a-href
                               "sample-word-lists/english-words.txt"
                               text)))
                          ("wiktionarylink_" .
                           ,(lambda (text)
                              (a-href
                               "https://en.wiktionary.org/wiki/Appendix: 1000_b\
asic_English_words"
                               text)))
                          ("ccbysalink_" .
                           ,(lambda (text)
                              (a-href
                               "sample-word-lists/CCBYSA-3.0-UNPORTED.txt"
                               text))))))
               (p ,(_ "Please note that all words in the sample word list have \
been deliberately converted to upper case. The reason is that “Don’t Hang” \
displays words in upper case and storing the words in lower case would lead to \
errors in some locales, e.g. the English word “is” would become “İS” in a \
Turkish locale."))
               ,(back-button-for-lingua lingua))))
        (make-page (string-append "dont-hang/index" "-" lingua ".html")
                   (with-layout
                    (pelzflorian-blue-theme lingua)
                    site
                    (_ "Don’t Hang")
                    body)
                   sxml->html)))))

(define (schulstücke-page-for-lingua lingua)
  (let ((current-lingua lingua))
    (lambda (site posts)
      (let ((body
             `(div
               (h1 ,(_ "Theater for elementary school kids from Kappel"))
               (p ,(_ "This is a collection of theater plays by my \
grandmother Elfriede Pelz.  She was an elementary school teacher in Kappel in \
the German city of Freiburg im Breisgau and not only taught her students how \
to read but also valued a clear pronunciation."))
               (p ,@(__ "You may want to take a look at the plays if you \
speak German or want to learn German.  They are available under a free \
license (||ccbysalink_||)."
                        `(("ccbysalink_" .
                           ,(lambda ()
                              (a-href
                               "https://creativecommons.org/licenses/by-sa/\
4.0/legalcode.de"
                               "CC-BY-SA 4.0")))))
                  (div (@ (class "vertically-padded centered"))
                       ,(a-href "theater-fuer-kappler-grundschulkinder.pdf"
                                (_ "Download")))
                  ,(sortable-table-for-lingua
                    `((,(_ "Play no.") ,(_ "Title"))
                      ("1" "Kasperlespiel zum Schulanfang 1989")
                      ("2" "Kasperle und der Zauberer vom Kybfelsen")
                      ("3" "Dornröschen")
                      ("4" "Mondfahrt in geheimer Mission")
                      ("5" "Das tapfere Schneiderlein")
                      ("6" "Der Teufel mit den drei goldenen Haaren")
                      ("7" "Wie Eulenspiegel die Kranken heilte")
                      ("8" ,(string-append
                             "Das erste Weihnachtslied"
                             (format #f (_ " (by ~A)")
                                     "Franz Pelz"))))
                    (let ((german-string<?
                           (lambda (a b)
                             (let ((strip
                                    (lambda (string)
                                      "Strips off “Der ”, “Die ”, “Das ”,
“Eine ”, “Ein ” from the beginning of a string."
                                      (cond
                                       ((and (> (string-length string) 4)
                                             (member
                                              (string-take string 4)
                                              '("Der " "Die " "Das "
                                                "Ein ")))
                                        (string-drop string 4))
                                       ((and (> (string-length string) 5)
                                             (member
                                              (string-take string 5)
                                              '("Eine ")))
                                        (string-drop string 5))
                                       (else string)))))
                               (string-locale<?
                                (strip a)
                                (strip b)
                                (make-locale LC_ALL "de_DE.UTF-8"))))))
                      `(,german-string<? ,german-string<?))
                    (_ "Table of contents")
                    current-lingua)
                  (img (@ (src "by-sa.svg")
                          (alt "CC-BY-SA logo")))
                  (p ,@(__ "Get the source code ||gitlink_|here||."
                           `(("gitlink_" .
                              ,(lambda (text)
                                 (a-href
                                  "/git/theater-fuer-kappler-grundschulkinder/"
                                  text)))))))
               ,(back-button-for-lingua lingua))))
        (make-page (string-append "theater/index" "-" lingua ".html")
                   (with-layout
                    (pelzflorian-blue-theme lingua)
                    site
                    "Theater für Kappler Grundschulkinder"
                    body)
                   sxml->html)))))

;;; GUI Programming in GTK+ Workshop lambdas yielding bodies:

(define (gui-prog-gtk-2016-body-for-lingua lingua)
  (let ((current-lingua lingua)
        (english-links
         `(ul
           ,(a-href-list-element
             "slides-01-en.pdf"
             "Slides 1")
           ,(a-href-list-element
             "slides-02-en.pdf"
             "Slides 2")
           ,(a-href-list-element
             "handout-01-install-en.pdf"
             "Handout 1: Installing")
           ,(a-href-list-element
             "handout-02-hello-gtk-en.pdf"
             "Handout 2: Hello GTK+")
           ,(a-href-list-element
             "handout-03-glade-en.pdf"
             "Handout 3: Glade")
           ,(a-href-list-element
             "handout-04-text-editor-en.pdf"
             "Handout 4: Text Editor")
           ,(a-href-list-element
             "handout-05-hangman-en.pdf"
             "Handout 5: Hangman")
           ,(a-href-list-element
             "handout-06-autotools-en.pdf"
             "Handout 6: Autotools")
           ,(a-href-list-element
             "handout-07-translations-en.pdf"
             "Handout 7: Translations")))
        (german-links
         `(ul
           ,(a-href-list-element
             "slides-01.pdf"
             "Foliensatz 1")
           ,(a-href-list-element
             "slides-02.pdf"
             "Foliensatz 2")
           ,(a-href-list-element
             "handout-01-install.pdf"
             "Handout 1: Installieren")
           ,(a-href-list-element
             "handout-02-hello-gtk.pdf"
             "Handout 2: Hallo GTK+")
           ,(a-href-list-element
             "handout-03-glade.pdf"
             "Handout 3: Glade")
           ,(a-href-list-element
             "handout-04-text-editor.pdf"
             "Handout 4: Texteditor")
           ,(a-href-list-element
             "handout-05-hangman.pdf"
             "Handout 5: Galgenmännchen")
           ,(a-href-list-element
             "handout-06-autotools.pdf"
             "Handout 6: Autotools")
           ,(a-href-list-element
             "handout-07-translations.pdf"
             "Handout 7: Übersetzungen"))))
    `(div
      ,(if (equal? lingua "de")
           `(div
             (p ,german-links)
             (p "English:" ,english-links))
           `(div
             (p ,english-links)
             (p "Deutsch:" ,german-links)))
      (p
       (a-href
        "/git/gui-prog-gtk/tree/?id=f2fb450d34b8fd3b47420315547a61f7f7a6cd71"
        ,(_ "All source code for the workshop."))))))

(define (gui-prog-gtk-2017-body-for-lingua lingua)
  (let ((current-lingua lingua)
        (english-links
         `(ul
           ,(a-href-list-element
             "slides-01-en.pdf"
             "Slides 1")
           ,(a-href-list-element
             "slides-02-en.pdf"
             "Slides 2")
           ,(a-href-list-element
             "handout-01-install-en.pdf"
             "Handout 1: Installing")
           ,(a-href-list-element
             "handout-02-hello-gtk-en.pdf"
             "Handout 2: Hello GTK+")
           ,(a-href-list-element
             "handout-03-glade-en.pdf"
             "Handout 3: Glade")
           ,(a-href-list-element
             "handout-04-text-editor-en.pdf"
             "Handout 4: Text Editor")
           ,(a-href-list-element
             "handout-05-meson-en.pdf"
             "Handout 5: Meson")
           ,(a-href-list-element
             "handout-06-translations-en.pdf"
             "Handout 6: Translations")))
        (german-links
         `(ul
           ,(a-href-list-element
             "slides-01.pdf"
             "Foliensatz 1")
           ,(a-href-list-element
             "slides-02.pdf"
             "Foliensatz 2")
           ,(a-href-list-element
             "handout-01-install.pdf"
             "Handout 1: Installieren")
           ,(a-href-list-element
             "handout-02-hello-gtk.pdf"
             "Handout 2: Hallo GTK+")
           ,(a-href-list-element
             "handout-03-glade.pdf"
             "Handout 3: Glade")
           ,(a-href-list-element
             "handout-04-text-editor.pdf"
             "Handout 4: Texteditor")
           ,(a-href-list-element
             "handout-05-meson.pdf"
             "Handout 5: Meson")
           ,(a-href-list-element
             "handout-06-translations.pdf"
             "Handout 6: Übersetzungen"))))
    `(div
      ,(if (equal? lingua "de")
           `(div
             (p ,german-links)
             (p "English:" ,english-links))
           `(div
             (p ,english-links)
             (p "Deutsch:" ,german-links)))
      (p
       (a (@ (href
              "/git/gui-prog-gtk/"))
          ,(_ "All source code for the workshop."))))))

(define (gui-prog-gtk-page-for-lingua
         lingua
         gui-prog-gtk-body-for-lingua ; lambda yielding list of download links
         year ; workshop year for HTML title
         poster-url-for-lingua ; for link to poster
         enable-registration) ; whether to show registration link
  (let ((current-lingua lingua))
    (lambda (site posts)
      (let ((body
             `(div
               (p ,@(__ "Thank you for your interest in my workshop \
“GUI Programming with GTK+”. ||register_|To register please go |here|. ||For \
more information see ||link_|here||."
                        `(("register_" .
                           ,(lambda (before-link link-text after-link)
                              (if enable-registration
                                  `(span
                                    ,before-link
                                    ,(a-href
                                      "/gui-prog-anmelden/"
                                      link-text)
                                    ,after-link)
                                  "")))
                          ("link_" .
                           ,(lambda (text)
                              (a-href
                               (poster-url-for-lingua lingua)
                               text))))))
               ,(gui-prog-gtk-body-for-lingua current-lingua)
               ,(back-button-for-lingua current-lingua))))
        (make-page
         (string-append "gui-prog-gtk-" year "/index" "-" lingua ".html")
         (with-layout
          (pelzflorian-blue-theme lingua)
          site
          (string-append (_ "GUI Programming with GTK+ ") year)
          body)
         sxml->html)))))

(define (homepage-for-lingua lingua)
  (let ((current-lingua lingua))
    (lambda (site posts)
      (let ((most-recent-post
             (if (null? posts)
                 #f
                 (car (posts/reverse-chronological posts)))))
        (make-page (string-append "index" "-" lingua ".html")
                   ((pelzflorian-blue-layout lingua #t) ; #t means
                                                        ; “use layout
                                                        ; variant for
                                                        ; homepage”
                    site
                    (_ "Home page")
                    `(div
                      (div
                       (h1 ,(_ "Welcome"))
                       (p ,(_ "Welcome to my personal web site. My name is \
Florian Pelz and I live in Kaiserslautern in Germany. When I have \
interesting things to share, I’ll put them up here.")))
                      ,(if (not (null? posts))
                           `(div
                             ,(format-post-for-lingua
                               most-recent-post
                               current-lingua)
                             (div
                              ,(tags-for-post-for-lingua
                                most-recent-post
                                current-lingua)
                              ,(recent-post-link-for-lingua current-lingua)))
                           ""))) ; don’t print any posts if there are
                                 ; no posts yet
                   sxml->html)))))

(define (builders-for-lingua lingua)
  "Returns all the site builders specific to lingua."
  (let* ((current-lingua lingua)
         (posts-relative-dirname
          (string-join (list posts-dir lingua) "/"))
         (feeds-relative-dirname
          (string-join (list feeds-dir lingua) "/"))
         (lingua-filter-regexp
          (make-regexp
           (string-append "^" posts-relative-dirname)))
         (lingua-filter
          (lambda (post)
            (let ((file-path (post-file-name post)))
              (regexp-match?
               (regexp-exec lingua-filter-regexp file-path))))))
    (lambda (site posts)
      (let ((posts-for-lingua (filter lingua-filter posts))
            (blog-for-lingua
             (blog
              #:theme (pelzflorian-blue-theme lingua)
              #:prefix posts-relative-dirname
              #:collections `((,(_ "Recent posts")
                               "index.html"
                               ,posts/reverse-chronological))))
            (atom-feed-for-lingua
             (atom-feed
              #:file-name (string-join
                           (list feeds-relative-dirname "feed.xml")
                           "/")
              #:subtitle (_ "Recent posts")
              #:blog-prefix (string-append "/" posts-relative-dirname)))
            (atom-feeds-by-tag-for-lingua
             (atom-feeds-by-tag
              #:prefix feeds-relative-dirname
              #:blog-prefix (string-append "/" posts-relative-dirname))))
        (flatten ; flatten the resulting list, i.e. no nested elements
         (append ; ensure every argument is a list:
          (list (blog-for-lingua site posts-for-lingua))
          (list (atom-feed-for-lingua site posts-for-lingua))
          (list (atom-feeds-by-tag-for-lingua site posts-for-lingua))
          (list (make-asset "c_exercises.htm" "c_exercises.htm"))
          (list (make-asset "c_exercises.htm" "c_exercises.css"))
          (list ((dont-hang-page-for-lingua lingua) site posts-for-lingua))
          (list ((schulstücke-page-for-lingua lingua) site posts-for-lingua))
          (list ((old-stuff-page-for-lingua lingua) site posts-for-lingua))
          (list ((gui-prog-gtk-page-for-lingua
                  lingua
                  gui-prog-gtk-2016-body-for-lingua
                  "2016"
                  (lambda (lingua) "gui-prog-poster.pdf")
                  #f) ; #f means registration is disabled
                 site
                 posts-for-lingua))
          (list ((gui-prog-gtk-page-for-lingua
                  lingua
                  gui-prog-gtk-2017-body-for-lingua
                  "2017"
                  (lambda (lingua)
                    (string-append "gui-prog-poster-" lingua ".pdf"))
                  #f)
                 site
                 posts-for-lingua))
          (list ((homepage-for-lingua lingua) site posts-for-lingua))))))))

(site #:title "pelzflorian.de"
      #:domain "pelzflorian.de"
      #:file-filter (make-file-filter
                     (list "^\\." ; no hidden files
                           "^#" ; no emacs temporary files
                           "~$")) ; no auto-saved files
;;;   #:default-metadata
;;;   (list (author . "Florian Pelz")
;;;         (email  . "pelzflorian@pelzflorian.de"))
      #:readers (list sxml-reader)
      #:builders
      (cons*
       (static-directory css-dir)
       (static-directory files-dir)
       (static-directory image-dir)
       (static-directory uni-dir)
       (static-directory "c")
       (static-directory "dont-hang")
       (static-directory "gui-prog-gtk-2016")
       (static-directory "gui-prog-gtk-2017")
       (static-directory "maumau")
       (static-directory "theater")
       (map ; list of other pages and assets
        (lambda (lingua)
          (builders-for-lingua lingua))
        linguas)))