source: project/gazette/hyde.scm @ 20543

Last change on this file since 20543 was 20543, checked in by Moritz Heidkamp, 10 years ago

gazette: add dates and authors to archive and reverse its ordering; fix a bug in the default-page-vars regexp for issue layouts

File size: 1.2 KB
Line 
1(use hyde hyde-atom environments)
2
3(default-page-vars '(((: bos "/issues/" (+ any) ".html")
4                      (layouts "article.sxml" "default.sxml"))))
5
6(define $ (environment-ref (page-eval-env) '$))
7
8(define (page-updated page)
9  (or ($ 'updated page) ($ 'date page)))
10
11(define (sort-by pages accessor)
12  (sort pages (lambda (p1 p2) (> (accessor p1) (accessor p2)))))
13
14(define (pages-matching regex)
15  (map cdr (filter (lambda (p) (string-match regex (car p)))
16                   (environment-ref (page-eval-env) 'pages))))
17
18(define (format-seconds seconds)
19  (time->string (seconds->utc-time seconds) "%Y-%m-%d %z"))
20
21(define (authors->sxml authors)
22  `(,(car authors)
23    ,@(if (null? (cdr authors)) 
24          '()
25          (map (lambda (author)
26                 `(,(car author) (span (@ (class "author")) ,(cdr author))))
27               (append (map (cut cons ", " <>) (butlast (cdr authors)))
28                       `((" and " . ,(last authors))))))))
29
30(for-each (lambda (binding)
31            (apply environment-extend! (cons (page-eval-env) binding)))
32          `((page-updated ,page-updated)
33            (format-seconds ,format-seconds)
34            (authors->sxml ,authors->sxml)
35            (all-issues ,(lambda () 
36                           (sort-by (pages-matching "issues/.+") page-updated)))))
Note: See TracBrowser for help on using the repository browser.