summaryrefslogtreecommitdiff
path: root/dnw/theme.scm
blob: 69688bc7541a2ec8fa369625fd6fe94ef38340f0 (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
(define-module (dnw theme)
  #:use-module (ice-9 match)
  #:use-module (srfi srfi-19)
  #:use-module (haunt site)
  #:use-module (haunt post)
  #:use-module (haunt utils)
  #:use-module (dnw utils)
  #:use-module (dnw tags)
  #:use-module (haunt builder blog)
  #:export (dnw-haunt-theme
	    base-template
	    post-header
	    tags-template))

(define stylesheets '("style.css"))

(define nav-bar-tabs '(("Me" "/pages/me.html")
		       ("Friends" "/pages/friends.html")
		       ("Influences" "/pages/influences.html")
		       ("Projects" "/posts/tag/Project.html")))

(define dnw-title "Through the Heart of Every Man")

(define header
  `(header
    ,(hyperlink "/" (image "combgeo.png" "home"))
    (h1 ,dnw-title)
    (nav (ul
	  ,@(map (lambda (tuple)
		   `(li ,(apply hyperlink (reverse tuple))))
		 nav-bar-tabs)))))

(define footer
  `(footer
    (div
     (p "© 2023 Duncan Wilkie")
     ,(image "by-sa.svg"
	     "Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) Logo"))
    (p "Unless otherwise specified, the text and images on this site are free culture works available under the "
       ,(hyperlink "https://creativecommons.org/licenses/by-sa/4.0/"
                   "Creative Commons Attribution Share-Alike 4.0 International")
       " license.")
    (p "This website is built with "
       ,(hyperlink "http://haunt.dthompson.us/" "Haunt")
       ", a static site generator written in "
       ,(hyperlink "https://gnu.org/software/guile" "Guile Scheme")
       ". The source code is available "
       ,(hyperlink "https://github.com/Antigravityd/functorial.xyz" "here")
       ".")))

(define* (base-template site body #:key title)
  `((doctype html)
    (html (@ (lang "en")))
    (head
     ,(if (null? title)
          `(title title)
          `(title ,(string-join (list title dnw-title) " — ")))
     (meta (@ (charset "utf-8")))
     (meta (@ (name "viewport")
	      (content "width=device-width, initial_scale=1")))
     ,@(map (lambda (file-name) (stylesheet file-name)) stylesheets)
     (meta (@ (name "HandheldFriendly") (content "True")))
     (meta (@ (name "author") (content "Duncan Wilkie")))
     (meta (@ (name "subject") (content "Ravings of a Madman")))
     (meta (@ (name "medium") (content "blog")))
     (meta (@ (name "og:title") (content ,title))))
    (body (@ (class ""))
	  ,header
	  ,body
	  ,footer)))

(define (post-meta post)
  `(p ,(let ((tgs (post-ref post 'tags))
	     (datestr (date->string (post-date post) "~e ~B ~Y")))
	 (if tgs
	     `(,(string-append datestr " | ")
	       (span (@ (class "tags"))
		     ,(map (lambda (tag)
			     `(span
			       ,(hyperlink (tag-uri tag) tag)
			       " "))
			   tgs)))
	     datestr))))

(define (post-header site post)
  `(div (@ (id "post"))
	(div (@ (class "title"))
	     (h2 ,(hyperlink (post-uri site post)
			     (post-ref post 'title))))
	(div  (@ (class "subtitle"))
	      ,(post-meta post))))

(define (post-template post)
  `((h1 ,(post-ref post 'title))
    ,(post-meta post)
    ,(post-sxml post)))

(define* (tags-template site posts #:key title)
  `((section (@ (id "posts"))
	     (div (@ (class "container"))
		  (h1 "Tagged #" ,title)
		  ,(tag-description title desc-alist)
 		  (div (@ (class "post-listing"))
		       ,(map (lambda (post)
			       (post-header site post))
			     (posts/reverse-chronological posts)))))))

(define (collection-template site title posts prefix)
  `((section (@ (id "posts"))
	     (div (@ (class "container"))
		  (h1 "All Posts"
		      ,(hyperlink "/feed.xml" (image "rss.png" "RSS Feed Icon" "rss-icon")))
		  (div (@ (class "post-listing"))
		       ,(map (lambda (post) (post-header site post))
			     (posts/reverse-chronological posts)))))))

(define dnw-haunt-theme
  (theme #:name "Through the Heart of Every Man"
	 #:layout
	 (lambda (site title body)
	   (base-template
	    site body
	    #:title dnw-title))
	 #:post-template post-template
	 #:collection-template collection-template))