1 | (use hyde hyde-atom environments) |
---|
2 | |
---|
3 | (define-hyde-environment live |
---|
4 | (clean-before-build #f) |
---|
5 | (output-dir "/var/www/spiffy/gazette")) |
---|
6 | |
---|
7 | (default-page-vars '(((: bos "/issues/" (+ any) ".wiki") |
---|
8 | (layouts "article.sxml" "default.sxml")))) |
---|
9 | |
---|
10 | (define $ (environment-ref (page-eval-env) '$)) |
---|
11 | |
---|
12 | (define (page-updated page) |
---|
13 | (or ($ 'updated page) ($ 'date page))) |
---|
14 | |
---|
15 | (define (sort-by pages accessor) |
---|
16 | (sort pages (lambda (p1 p2) (> (accessor p1) (accessor p2))))) |
---|
17 | |
---|
18 | (define (pages-matching regex) |
---|
19 | (map cdr (filter (lambda (p) (string-match regex (car p))) |
---|
20 | (environment-ref (page-eval-env) 'pages)))) |
---|
21 | |
---|
22 | (define (format-seconds seconds) |
---|
23 | (time->string (seconds->utc-time seconds) "%Y-%m-%d %z")) |
---|
24 | |
---|
25 | (define (authors->sxml authors) |
---|
26 | `(,(car authors) |
---|
27 | ,@(if (null? (cdr authors)) |
---|
28 | '() |
---|
29 | (map (lambda (author) |
---|
30 | `(,(car author) (span (@ (class "author")) ,(cdr author)))) |
---|
31 | (append (map (cut cons ", " <>) (butlast (cdr authors))) |
---|
32 | `((" and " . ,(last authors)))))))) |
---|
33 | |
---|
34 | (for-each (lambda (binding) |
---|
35 | (apply environment-extend! (cons (page-eval-env) binding))) |
---|
36 | `((page-updated ,page-updated) |
---|
37 | (format-seconds ,format-seconds) |
---|
38 | (authors->sxml ,authors->sxml) |
---|
39 | (all-issues ,(lambda () |
---|
40 | (sort-by (pages-matching '(: "issues/" (+ num) ".wiki")) page-updated))))) |
---|