Преглед изворни кода

Use write-document throughout. Render-function cleanup done.

Brit Butler пре 11 година
родитељ
комит
7e028d354e
3 измењених фајлова са 8 додато и 25 уклоњено
  1. 0 8
      docs/hacking.md
  2. 7 15
      src/indexes.lisp
  3. 1 2
      src/posts.lisp

+ 0 - 8
docs/hacking.md

184
 function. There may be other areas where it was assumed tags/dates
184
 function. There may be other areas where it was assumed tags/dates
185
 will always be present.
185
 will always be present.
186
 
186
 
187
-### Render Function Cleanup
188
-
189
-There are currently 3 render-foo* functions and 3 implementations of the
190
-render method. Only the render-foo* functions call `write-file` so there
191
-should be some room for cleanup here. The render method implementations
192
-are probably necessary unless we want to start storing their arguments
193
-on the models. There may be a different way to abstract the data flow.
194
-
195
 ### User-Defined Routing
187
 ### User-Defined Routing
196
 
188
 
197
 There is no reason *coleslaw* should be in charge of the site layout or
189
 There is no reason *coleslaw* should be in charge of the site layout or

+ 7 - 15
src/indexes.lisp

33
 
33
 
34
 (defmethod publish ((doc-type (eql (find-class 'tag-index))))
34
 (defmethod publish ((doc-type (eql (find-class 'tag-index))))
35
   (dolist (index (find-all 'tag-index))
35
   (dolist (index (find-all 'tag-index))
36
-    (render-index index)))
36
+    (write-document index)))
37
 
37
 
38
 ;;; Index by Month
38
 ;;; Index by Month
39
 
39
 
55
 
55
 
56
 (defmethod publish ((doc-type (eql (find-class 'month-index))))
56
 (defmethod publish ((doc-type (eql (find-class 'month-index))))
57
   (dolist (index (find-all 'month-index))
57
   (dolist (index (find-all 'month-index))
58
-    (render-index index)))
58
+    (write-document index)))
59
 
59
 
60
 ;;; Reverse Chronological Index
60
 ;;; Reverse Chronological Index
61
 
61
 
81
     (dolist (index indexes)
81
     (dolist (index indexes)
82
       (let ((prev (1- (index-slug index)))
82
       (let ((prev (1- (index-slug index)))
83
             (next (1+ (index-slug index))))
83
             (next (1+ (index-slug index))))
84
-        (render-index index :prev (when (plusp prev) prev)
85
-                            :next (when (<= next (length indexes)) next))))))
84
+        (write-document index nil
85
+                        :prev (when (plusp prev) prev)
86
+                        :next (when (<= next (length indexes)) next))))))
86
 
87
 
87
 ;;; Atom and RSS Feeds
88
 ;;; Atom and RSS Feeds
88
 
89
 
100
 
101
 
101
 (defmethod publish ((doc-type (eql (find-class 'feed))))
102
 (defmethod publish ((doc-type (eql (find-class 'feed))))
102
   (dolist (feed (find-all 'feed))
103
   (dolist (feed (find-all 'feed))
103
-    (render-feed feed)))
104
+    (write-document feed (theme-fn (feed-format feed) "feeds"))))
104
 
105
 
105
 ;;; Tag Feeds
106
 ;;; Tag Feeds
106
 
107
 
121
 
122
 
122
 (defmethod publish ((doc-type (eql (find-class 'tag-feed))))
123
 (defmethod publish ((doc-type (eql (find-class 'tag-feed))))
123
   (dolist (feed (find-all 'tag-feed))
124
   (dolist (feed (find-all 'tag-feed))
124
-    (render-feed feed)))
125
+    (write-document feed (theme-fn (feed-format feed) "feeds"))))
125
 
126
 
126
 ;;; Helper Functions
127
 ;;; Helper Functions
127
 
128
 
136
   (let* ((dupes (mappend #'content-tags (find-all 'post)))
137
   (let* ((dupes (mappend #'content-tags (find-all 'post)))
137
          (tags (remove-duplicates dupes :test #'string= :key #'tag-slug)))
138
          (tags (remove-duplicates dupes :test #'string= :key #'tag-slug)))
138
     (sort tags #'string< :key #'tag-name)))
139
     (sort tags #'string< :key #'tag-name)))
139
-
140
-(defun render-feed (feed)
141
-  "Render the given FEED to both RSS and ATOM."
142
-  (let ((theme-fn (theme-fn (feed-format feed) "feeds")))
143
-    (write-file (page-path feed) (render-page feed theme-fn))))
144
-
145
-(defun render-index (index &rest render-args)
146
-  "Render the given INDEX using RENDER-ARGS if provided."
147
-  (write-file (page-path index) (apply #'render-page index nil render-args)))

+ 1 - 2
src/posts.lisp

26
 
26
 
27
 (defmethod publish ((doc-type (eql (find-class 'post))))
27
 (defmethod publish ((doc-type (eql (find-class 'post))))
28
   (loop for (next post prev) on (append '(nil) (by-date (find-all 'post)))
28
   (loop for (next post prev) on (append '(nil) (by-date (find-all 'post)))
29
-     while post do (write-file (page-path post)
30
-                               (render-page post nil :prev prev :next next))))
29
+     while post do (write-document post nil :prev prev :next next)))