theme.scm 3.55 KB
Newer Older
Philip Kaludercic's avatar
Philip Kaludercic committed
1
2
3
4
5
6
7
8
9
10
11
12
13
(add-to-load-path "..")
(define-module (local theme)
  #:use-module (ice-9 format)
  #:use-module (srfi srfi-1)
  #:use-module (srfi srfi-19)
  #:use-module (haunt builder blog)
  #:use-module (haunt post)
  #:use-module (haunt site)
  #:use-module (local common)
  #:export (local-site-theme))

(define (intersperse lst x)
  (append (apply append (map (lambda (item) (list item x))
14
15
                             (drop-right lst 1)))
          (last-pair lst)))
Philip Kaludercic's avatar
Philip Kaludercic committed
16
17
18

(define* (make-post-generator #:key site prefix)
  (lambda (post)
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
    `(article
      ,(post-sxml post)
      (nav (span "Beigetragen am "
                 (time (@ (datetime ,(date->string (post-date post) "~4")))
                       ,(date->string (post-date post)
                                      "~Y-~m-~d")))
           ,@(if (post-ref post 'author)
                 `((span "Verfasst von " (em ,(post-ref post 'author))))
                 '())
           ,@(if (post-ref post 'tags)
                 `((span "Tags: "
                         ,(intersperse
                           (map (lambda (tag)
                                  (link tag (format #f "/tags/~a.xml" tag)))
                                (post-ref post 'tags))
                           ", ")))
                 '())
           (span ,@(if (and site prefix)
                       `(" "
                         ,(link "Permalink"
                                (format #f "/~a/~a.html"
                                        prefix (site-post-slug site post)))
                         " | ")
                       '(""))
                 ,(link "Source"
                        (string-append "https://gitlab.cs.fau.de/faui2k17/posts/blob/master/"
                                       (basename (post-file-name post)))))))))
Philip Kaludercic's avatar
Philip Kaludercic committed
46
47
48
49
50
51
52

(define local-site-theme
  (theme
   #:name "local"
   #:layout
   (lambda (site title body)
     `((doctype "html")
53
54
       (html (@ (lang "de"))
        (head
55
         (meta (@ (charset "utf-8")))
56
57
         (meta (@ (name "referrer") (content "none")))
         (meta (@ (name "viewport") (content "width=device-width")))
58
         (title ,title)
59
60
61
62
63
64
65
66
67
68
69
70
71
         (link (@ (rel "stylesheet") (href "/style.css")))
         (link (@ (rel "alternate") (type "application/atom+xml") (title "Atom")
                  (href ,(string-append (site-domain site) "/feed.xml"))))
         (link (@ (rel "alternate") (type "application/rss+xml") (title "RSS")
                  (href ,(string-append (site-domain site) "/rss-feed.xml")))))
        (body
         (header
          (nav ,@(list (link '(code "#faui2k17") "/") 
                       (link "IRC" "/irc.html")
                       (link "WhatsApp" "/whatsapp.html")
                       (link "Beitragen" "/meta.html")
                       (link "Atom" "/feed.xml")
                       (link "RSS" "/rss-feed.xml"))))
72
         ,body))))
Philip Kaludercic's avatar
Philip Kaludercic committed
73
74
75
   #:post-template (make-post-generator)
   #:collection-template
   (lambda (site title posts prefix number last?)
76
     (list
Philip Kaludercic's avatar
Philip Kaludercic committed
77
      (map (make-post-generator #:site site
78
                                #:prefix prefix)
Philip Kaludercic's avatar
Philip Kaludercic committed
79
           posts)
80
81
82
83
84
85
86
87
88
89
      `(footer
        ,(let ((prev (link (format #f "<< Page ~d" (1- number))
                           (if (= number 2) "/index.html"
                               (format #f "/page-~d.html" (1- number)))))
               (next (link (format #f "Page ~d >>" (1+ number))
                           (format #f "/page-~d.html" (1+ number)))))
           (cond ((and last? (= number 1)) '())
                 (last? (list prev))
                 ((= number 1) (list next))
                 (else (list prev " | " next)))))))))