-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathhtml-gen.lisp
More file actions
35 lines (32 loc) · 1.51 KB
/
html-gen.lisp
File metadata and controls
35 lines (32 loc) · 1.51 KB
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
(in-package :millipode)
(defun generate-post-index-html (pode)
"The post index HTML returned as a string."
(with-existing-pode-slots pode
(flet ((webpage (post)
(file-namestring (corresponding-webpage-file pode post))))
(let* ((template-file (merge-pathnames +index-template-file+ template-dir))
(posts (ls content-dir))
(sstream (make-string-output-stream))
(values (list :posts
(loop for post in (reverse posts) collect
(list :link-href (webpage post)
:link-name (get-post-title post))))))
(fill-and-print-template template-file values :stream sstream)
(get-output-stream-string sstream)))))
(defun markdown-to-html (file)
(check-type file pathname)
(let ((sstream (make-string-output-stream)))
(parse-string-and-print-to-stream
(read-file-into-string file) sstream)
(get-output-stream-string sstream)))
(defun generate-post-html (pode file)
"A post's HTML returned as a string."
(check-type file pathname)
(with-existing-pode-slots pode
(let* ((template-file (merge-pathnames +post-template-file+ template-dir))
(sstream (make-string-output-stream))
(values (list :title (get-post-title file)
:post (markdown-to-html file)))
(*string-modifier* #'identity))
(fill-and-print-template template-file values :stream sstream)
(get-output-stream-string sstream))))