summaryrefslogtreecommitdiff
path: root/src/operationnull/theme.scm
blob: 70e81e6595300f731672b0a90139444cb785fd8d (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
(define-module (operationnull theme)
  #:use-module (haunt artifact)
  #:use-module (haunt builder blog)
  #:use-module (haunt html)
  #:use-module (haunt post)
  #:use-module (haunt site)
  #:use-module (ice-9 match)
  #:use-module (srfi srfi-19)
  #:export (main-theme))

(define %cc-by-sa-link
  '(a (@ (href "https://creativecommons.org/licenses/by-sa/4.0/"))
      "CC-BY-SA 4.0"))

(define (first-paragraph post)
  (let loop ((sxml (post-sxml post)))
    (match sxml
      (() '())
      (((and paragraph ('p . _)) . _)
       (list paragraph))
      ((head . tail)
       (cons head (loop tail))))))

(define (stylesheet name)
  `(link (@ (rel "stylesheet")
            (href ,(string-append "/assets/" name ".css")))))

(define main-theme
  (theme #:name "bdunahu"
         #:layout
         (lambda (site title body)
           `((doctype "html")
             (head
              (meta (@ (charset "utf-8")))
              (meta (@ (name "viewport")
                       (content "width=device-width, initial-scale=1")))
              (link (@ (rel "icon")
                       (type "image/x-icon")
                       (href "/assets/favicon.ico")))
              (title ,(string-append title " — " (site-title site)))
              ,(stylesheet "site")
              )
             (body
              (intro
               (br)
               '(div (@ (class "container"))
                     (img (@ (alt "raven") (class "no-border")
                             (src "/assets/raven.png")))
                     (h1 (span (@ (class "white")) bdunahu))
                     (p "cs graduate student @ "
                        (a (@ (href "https://www.cics.umass.edu/"))
                           "UMass Amherst"))))
              (nav
               '(div (@ (class "container"))
                     (ul (li (a (@ (href "gemini://porphyrion.operationnull.com/"))
                                "porphyrion"))
                         (li (a (@ (href "https://git.operationnull.com/"))
                                "git"))
                         (li (a (@ (href "/contact.html"))
                                "contact"))
                         (li (a (@ (href "/"))
                                "home")))))
              ,body
              (footer (@ (class "footer"))
                      "Copyright © 2025 bdunahu"
                      (br)
                      "Site content available under the " ,%cc-by-sa-link " license "
                      (a (@ (href "https://git.operationnull.com/operationnull.git/"))
                         "here")
                      "."
                      (br)
                      "Last updated on "
                      ,(date->string (current-date) "~b ~d, ~Y")
                      ". Generated with "
                      (a (@ (href "https://dthompson.us/projects/haunt.html"))
                         "Haunt")
                      " and "
                      (a (@ (href "https://gnu.org/software/guile"))
                         "Guile Scheme")
                      "."))))
         #:post-template
         (lambda (post)
           `((article
              (h3 (@ (class "title")),(post-ref post 'title))
              (div (@ (class "date"))
                   ,(date->string (post-date post)
                                  "created: ~B ~d, ~Y"))
              (div (@ (class "tags"))
                   "tags:"
                   (ul ,@(map (lambda (tag)
                                `(li (a (@ (href ,(string-append "/feeds/tags/"
                                                                 tag ".xml")))
                                        ,tag)))
                              (assq-ref (post-metadata post) 'tags))))
              (div (@ (class "post"))
                   ,(post-sxml post)))))
         #:collection-template
         (lambda (site title posts prefix)
           (define (post-uri post)
             (string-append prefix "/" (site-post-slug site post) ".html"))

           `(article (h2 ,title
                         (a (@ (href "/atom.xml"))
                            (img (@ (class "feed-icon") (src "/assets/feed.png")))))
                     ,(map (lambda (post)
                             (let ((uri (post-uri post)))
                               `(article (@ (class "summary"))
                                         (h3 (a (@ (href ,uri))
                                                ,(post-ref post 'title)))
                                         (div (@ (class "date"))
                                              ,(date->string (post-date post)
                                                             "~B ~d, ~Y"))
                                         (div (@ (class "post"))
                                              ,(first-paragraph post))
                                         (a (@ (href ,uri)) "more..."))))
                           posts)))
         #:pagination-template
         (lambda (site body previous-page next-page)
           `(,@body
             (div (@ (class "paginator"))
                  ,(if previous-page
                       `(a (@ (class "paginator-prev") (href ,previous-page))
                           "← Newer")
                       '())
                  ,(if next-page
                       `(a (@ (class "paginator-next") (href ,next-page))
                           "Older →")
                       '()))))
         ))