|
@@ -11,6 +11,13 @@
|
11
|
11
|
(format :initform nil :initarg :format :accessor post-format)
|
12
|
12
|
(content :initform nil :initarg :content :accessor post-content)))
|
13
|
13
|
|
|
14
|
+(defmethod render ((content post) &key prev next)
|
|
15
|
+ (funcall (theme-fn 'post)
|
|
16
|
+ (list :config *config*
|
|
17
|
+ :post content
|
|
18
|
+ :prev prev
|
|
19
|
+ :next next)))
|
|
20
|
+
|
14
|
21
|
(defun load-posts ()
|
15
|
22
|
"Read the stored .post files from the repo."
|
16
|
23
|
(clrhash *posts*)
|
|
@@ -22,10 +29,6 @@
|
22
|
29
|
(post-slug post))
|
23
|
30
|
(setf (gethash (post-slug post) *posts*) post))))))
|
24
|
31
|
|
25
|
|
-(defun post-url (post)
|
26
|
|
- "Return the relative URL for a given post."
|
27
|
|
- (format nil "~a.html" (post-slug post)))
|
28
|
|
-
|
29
|
32
|
(defun render-posts ()
|
30
|
33
|
"Iterate through the files in the repo to render+write the posts out to disk."
|
31
|
34
|
(load-posts)
|
|
@@ -34,8 +37,7 @@
|
34
|
37
|
for prev = nil then post
|
35
|
38
|
for post = (nth (1- i) posts)
|
36
|
39
|
for next = (nth i posts)
|
37
|
|
- do (write-post post :prev (and prev (post-url prev))
|
38
|
|
- :next (and next (post-url next)))))
|
|
40
|
+ do (render-page post nil :prev prev :next next)))
|
39
|
41
|
|
40
|
42
|
(defgeneric render-content (text format)
|
41
|
43
|
(:documentation "Compile TEXT from the given FORMAT to HTML for display.")
|
|
@@ -73,17 +75,6 @@
|
73
|
75
|
(getf args :format))
|
74
|
76
|
:slug (slugify (getf args :title))))))))
|
75
|
77
|
|
76
|
|
-(defun write-post (post &key prev next)
|
77
|
|
- "Write out the HTML for POST in SLUG.html."
|
78
|
|
- (render-page (format nil "posts/~a" (post-url post))
|
79
|
|
- (funcall (theme-fn 'post)
|
80
|
|
- (list :title (post-title post)
|
81
|
|
- :tags (taglinks (post-tags post))
|
82
|
|
- :date (post-date post)
|
83
|
|
- :content (post-content post)
|
84
|
|
- :prev prev
|
85
|
|
- :next next))))
|
86
|
|
-
|
87
|
78
|
(defun slug-char-p (char)
|
88
|
79
|
"Determine if CHAR is a valid slug (i.e. URL) character."
|
89
|
80
|
(or (char<= #\0 char #\9)
|