diff options
author | Case Duckworth | 2023-09-08 08:55:10 -0500 |
---|---|---|
committer | Case Duckworth | 2023-09-08 08:55:10 -0500 |
commit | bb4091acb58f0724dca262bc137715f6ed882e5f (patch) | |
tree | 312fb06d53a51094fcdf6b900b4dc1fe327555bc /boudin.page.write.scm | |
parent | A newerer beginning (diff) | |
download | boudin-bb4091acb58f0724dca262bc137715f6ed882e5f.tar.gz boudin-bb4091acb58f0724dca262bc137715f6ed882e5f.zip |
1.0, why not
Diffstat (limited to 'boudin.page.write.scm')
-rw-r--r-- | boudin.page.write.scm | 101 |
1 files changed, 6 insertions, 95 deletions
diff --git a/boudin.page.write.scm b/boudin.page.write.scm index eb719b7..39e916c 100644 --- a/boudin.page.write.scm +++ b/boudin.page.write.scm | |||
@@ -1,20 +1,10 @@ | |||
1 | (declare (module (boudin page write)) | 1 | (declare (module (boudin page write)) |
2 | (export feed-template | 2 | (export html-head |
3 | feed-writer | ||
4 | html-head | ||
5 | index-template | ||
6 | index-writer | ||
7 | post-template | ||
8 | post-writer | ||
9 | write-page)) | 3 | write-page)) |
10 | 4 | ||
11 | (import (atom) | 5 | (import (boudin page) |
12 | (boudin page) | ||
13 | (boudin site) | ||
14 | (chicken file) | 6 | (chicken file) |
15 | (chicken pathname) | 7 | (chicken pathname)) |
16 | (html-parser) | ||
17 | (sxml-serializer)) | ||
18 | 8 | ||
19 | (define (write-page pg) | 9 | (define (write-page pg) |
20 | (let ((outfile (page-output pg))) | 10 | (let ((outfile (page-output pg))) |
@@ -22,9 +12,9 @@ | |||
22 | 'parents) | 12 | 'parents) |
23 | (with-output-to-file outfile | 13 | (with-output-to-file outfile |
24 | (lambda () | 14 | (lambda () |
25 | ((page-writer pg) | 15 | ((o (page-writer pg) |
26 | ((page-template pg) | 16 | (page-template pg)) |
27 | pg)))))) | 17 | pg))))) |
28 | 18 | ||
29 | (define html-head | 19 | (define html-head |
30 | (make-parameter | 20 | (make-parameter |
@@ -33,82 +23,3 @@ | |||
33 | (content "initial-scale=1.0"))) | 23 | (content "initial-scale=1.0"))) |
34 | (link (@ (href "/style.css") | 24 | (link (@ (href "/style.css") |
35 | (rel "stylesheet")))))) | 25 | (rel "stylesheet")))))) |
36 | |||
37 | (define post-writer | ||
38 | (make-parameter | ||
39 | sxml-display-as-html)) | ||
40 | |||
41 | (define post-template | ||
42 | (make-parameter | ||
43 | (lambda (pg) | ||
44 | (let ((title (page-ref pg "title"))) | ||
45 | `(html (@ (lang "en-us")) | ||
46 | (head ,@(html-head) | ||
47 | (title ,(or title "[untitled]"))) | ||
48 | (body ,(if title `(h1 ,title) "") | ||
49 | ,@(cdr (page-content pg)))))))) | ||
50 | |||
51 | (define index-writer | ||
52 | (make-parameter | ||
53 | sxml-display-as-html)) | ||
54 | |||
55 | (define index-template | ||
56 | (make-parameter | ||
57 | (lambda (pgs) | ||
58 | `(html (@ (lang "en-us")) | ||
59 | (head ,@(html-head) | ||
60 | (title ,(site-name))) | ||
61 | (body (h1 ,(site-name)) | ||
62 | (ul ,@(map (lambda (pg) | ||
63 | `(li (a (@ (href ,(page-slug pg))) | ||
64 | ,(or (page-ref pg "title") | ||
65 | (page-slug pg))))) | ||
66 | ((site-sort) pgs)))))))) | ||
67 | |||
68 | (define feed-writer | ||
69 | (make-parameter | ||
70 | (lambda (sxml) | ||
71 | (serialize-sxml sxml | ||
72 | output: (current-output-port) | ||
73 | cdata-section-elements: '(atom:content) | ||
74 | ns-prefixes: | ||
75 | `((*default* . "http://www.w3.org/2005/Atom") | ||
76 | (*default* . "http://www.w3.org/1999/xhtml") | ||
77 | ,@(atom-ns-prefixes)) | ||
78 | allow-prefix-redeclarations: #t)))) | ||
79 | |||
80 | (define feed-template | ||
81 | (make-parameter | ||
82 | (lambda (pgs) | ||
83 | (make-atom-doc | ||
84 | (make-feed | ||
85 | title: (make-title (site-name)) | ||
86 | id: (site-host) | ||
87 | updated: (site-build-time) | ||
88 | authors: (list (make-author name: (site-author) | ||
89 | uri: (site-host))) | ||
90 | links: (list (make-link type: 'html | ||
91 | uri-language: "en" | ||
92 | uri: (site-host)) | ||
93 | (make-link relation: "self" | ||
94 | type: "application/atom+xml" | ||
95 | uri: (make-pathname | ||
96 | (site-host) "feed" "xml"))) | ||
97 | rights: (make-rights (force (site-rights))) | ||
98 | generator: (make-generator "Boudin" | ||
99 | uri: "https://git.acdw.net/boudin" | ||
100 | version: "rice") | ||
101 | entries: (map (lambda (pg) | ||
102 | (make-entry | ||
103 | title: (make-title | ||
104 | (or (page-ref pg "title") "[untitled]")) | ||
105 | links: (list (make-link type: 'html | ||
106 | uri: (page-url pg))) | ||
107 | id: (page-url pg) | ||
108 | updated: (page-updated pg) | ||
109 | ;;published: | ||
110 | content: (make-content | ||
111 | (sxml->html | ||
112 | (page-content pg)) | ||
113 | type: 'html))) | ||
114 | ((site-sort) pgs))))))) | ||