-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfile-gen.lisp
39 lines (34 loc) · 1.28 KB
/
file-gen.lisp
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
(in-package :millipode)
(defun generate-post (pode filepath)
(with-existing-pode-slots pode
"Generates a html file in webpage-dir."
(format t "Generating: ~a.html~%" (pathname-name filepath))
(write-string-into-file
(generate-post-html pode filepath)
(corresponding-webpage-file pode filepath)
:if-exists :supersede :if-does-not-exist :create)
nil))
(defun generate-post-index (pode)
"Indexes all the posts in webpage dir."
(with-existing-pode-slots pode
(format t "Generating the index.~%")
(write-string-into-file
(generate-post-index-html pode)
(merge-pathnames webpage-dir #P"index.html")
:if-exists :supersede :if-does-not-exist :create)
nil))
(defun generate-modified-posts (pode)
"Regenerates the html for the modified files in content-dir."
(map nil (curry #'generate-post pode)
(list-modified-content pode)))
(defun generate-new-posts (pode)
"Generates the html for the newly added files in content-dir."
(let ((new-content (list-new-content pode)))
(when new-content
(map nil (curry #'generate-post pode) new-content)
(generate-post-index pode))))
(defun generate-all-posts (pode)
(with-existing-pode-slots pode
(map nil (curry #'generate-post pode)
(ls content-dir))
(generate-post-index pode)))