~elais/elais.codes

ref: e0a722cbab0ecd31a0ace29692b843313c7225ab elais.codes/haunt.scm -rw-r--r-- 6.1 KiB
e0a722cbElais Player changed css and added lite sidebar 4 months ago
                                                                                
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
(use-modules
 (haunt asset)
 (haunt builder assets)
 (haunt builder atom)
 (haunt builder blog)
 (haunt html)
 (haunt page)
 (haunt post)
 (haunt reader)
 (haunt reader commonmark)
 (haunt site)
 (haunt utils)
 (srfi srfi-1)
 (srfi srfi-19)
 (sxml match)
 (sxml transform)
 (ice-9 rdelim)
 (ice-9 regex)
 (ice-9 match))

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

(define* (anchor content #:optional (uri content))
  `(a (@ (href ,uri)) ,content))

(define %site-prefix (make-parameter ""))

(define (prefix-url url)
  (string-append (%site-prefix) url))

;; TODO Generate feeds for each tag topic
(define (tags->links tags)
  (if (null? tags) ":"
      `(":"
        (a (@ (href ,(prefix-url
                      (string-append
                       "/feeds/tags/"
                       (car tags)
                       ".xml"))))
        ,(car tags))
        ,(tags->links (cdr tags)))))

(define %cc-license
  `((p (@ (xmlns:dct "http://purl.org/dc/terms/")
          (xmlns:cc "http://creativecommons.org/ns#")
          (class "license-text"))
       "© "
       ,(date->string (current-date) "~Y")
       (a (@ (rel= "cc:attributionURL")
             (href "/about.html"))
          (span (@ (rel "cc:attributionName"))
                " Elais Player")))
    "This site and its contents are free culture works licensed under "
    (a (@ (href "https://creativecommons.org/licenses/by-sa/4.0"))
       "CC BY-SA 4.0"
       (img (@ (style "display:inline;height:22px!important;margin-left:3px;vertical-align:text-bottom;")
               (alt "creative common license")
               (src "https://search.creativecommons.org/static/img/cc_icon.svg")))
       (img (@ (style "display:inline;height:22px!important;margin-left:3px;vertical-align:text-bottom;")
               (alt "attribution to the original author must be given")
               (src "https://search.creativecommons.org/static/img/cc-by_icon.svg")))
       (img (@ (style "display:inline;height:22px!important;margin-left:3px;vertical-align:text-bottom;")
               (alt "derivative works must be shared under the same license")
               (src "https://search.creativecommons.org/static/img/cc-sa_icon.svg"))))))

(define %header-menu
  `(div (@ (class "sidebar"))
        (a (@ (href "/"))
           "(home) p493")
        (a (@ (href "https://git.sr.ht/~elais"))
           "50f7w423 (repo)")
        (a (@ (href "/feed.xml"))
           "(rss) f33d")
        (a (@ (href "/about.html"))
           "480u7 (me)")))

(define (site-layout site title body)
  `((doctype "html")
    (html (@ (lang "en"))
          (head
           (meta (@ (charset "utf-8")
                    (name "viewport")
                    (content "width=device-width, initial-scale=1.0")))
           ,(stylesheet "main")
           (title ,(string-append title " - " (site-title site))))
          (body
           (div (@ (class "preamble"))
                ,%header-menu)
           (div (@ (class "container"))
                ,body
                (footer (@ (class "text-center"))
                        (center  ,%cc-license
                                 " and built with 🖤 using "
                                 (a (@ (href "http://haunt.dthompson.us"))
                                    "Haunt")
                                 ", a static site generator written in "
                                 (a (@ (href "https://gnu.org/software/guile"))
                                    "Guile Scheme"))))))))


(define (post-template post)
  `((div (@ (class "headline"))
         (h1 (@ (class "post-title"))
             (a (@ (href ,(prefix-url "")))
                ,(post-ref post 'title)))
         (div (@ (class "taglist"))
              ,(tags->links (post-ref post 'tags))))
    (div (@ (class "post"))
         (div (@ (class "date"))
              ,(date->string (post-date post) "<~Y-~m-~d>"))
         ,(post-sxml post))
    (center "---")))

(define (collection-template site title posts prefix)
  `(,(map
      (lambda (post)
        (let ((uri
               (string-append
                "/"
                (site-post-slug site post)
                ".html")))
          `(div (@ (class "post-title"))
                (h1 (a (@ (href ,uri))
                       ,(post-ref post 'title)
                       "...")))))
      posts)
    (br)))

(define elais-theme
  (theme #:name "elais"
         #:layout site-layout
         #:post-template post-template
         #:collection-template collection-template))

(define %collections
  `(("" "index.html" ,posts/reverse-chronological)))

(define (static-page title file-name body)
  (lambda (site posts)
    (make-page file-name
               (with-layout elais-theme site title body)
               sxml->html)))

(define about-page
  (static-page
   "About Me"
   "about.html"
   `((h1 "Me.")
     (p "I am an unprofessional software developer, keyboard enthusiast, and
chronic emacsturbator from Birmingham, Alabama now living with my wife, dog,
and two cats in northern New Mexico.")
     (p "Currently I am an application developer at "
        ,(anchor "Los Alamos National Laboratory" "https://lanl.gov")
        ", and formerly a Lead Developer/Analyst at "
        ,(anchor "BBVA USA." "https://bbvausa.com"))
     (p "I am a master of Computer Science according to the "
        ,(anchor "University of Alabama at Birmingham" "https://uab.edu")
        ", and a bachelor of Political Science according to "
        ,(anchor "Tennessee State University." "https://tnstate.edu"))
     (p "You can reach me by email at `elais at fastmail dot com`."))))

(site #:title "Elais Codes"
      #:domain "elais.codes"
      #:default-metadata
      '((author . "Elais Player")
        (email  . "elais@fastmail.com"))
      #:readers (list commonmark-reader)
      #:builders (list (blog #:theme elais-theme
                             #:collections %collections)
                       (atom-feed)
                       (atom-feeds-by-tag)
                       about-page
                       (static-directory "static/fonts" "fonts")
                       (static-directory "static/css" "css")))