Bladeren bron

Split feeds back out into their own file.

Brit Butler 11 jaren geleden
bovenliggende
commit
f602c371ea
3 gewijzigde bestanden met toevoegingen van 37 en 35 verwijderingen
  1. 1 0
      coleslaw.asd
  2. 36 0
      src/feeds.lisp
  3. 0 35
      src/indexes.lisp

+ 1 - 0
coleslaw.asd

@@ -23,6 +23,7 @@
23 23
                (:file "content")
24 24
                (:file "posts")
25 25
                (:file "indexes")
26
+               (:file "feeds")
26 27
                (:file "coleslaw"))
27 28
   :in-order-to ((test-op (load-op coleslaw-tests)))
28 29
   :perform (test-op :after (op c)

+ 36 - 0
src/feeds.lisp

@@ -0,0 +1,36 @@
1
+(in-package :coleslaw)
2
+
3
+;;; Atom and RSS Feeds
4
+
5
+(defclass feed (index)
6
+  ((format :initform nil :initarg :format :accessor feed-format)))
7
+
8
+(defmethod discover ((doc-type (eql (find-class 'feed))))
9
+  (let ((content (by-date (find-all 'post))))
10
+    (dolist (format '(rss atom))
11
+      (let ((feed (make-instance 'feed :format format
12
+                                 :content (take-up-to 10 content)
13
+                                 :slug (format nil "~(~a~)" format))))
14
+        (add-document feed)))))
15
+
16
+(defmethod publish ((doc-type (eql (find-class 'feed))))
17
+  (dolist (feed (find-all 'feed))
18
+    (write-document feed (theme-fn (feed-format feed) "feeds"))))
19
+
20
+;;; Tag Feeds
21
+
22
+(defclass tag-feed (feed) ())
23
+
24
+(defmethod discover ((doc-type (eql (find-class 'tag-feed))))
25
+  (let ((content (by-date (find-all 'post))))
26
+    (dolist (tag (feeds *config*))
27
+      (let ((tagged (remove-if-not (lambda (x) (tag-p tag x)) content)))
28
+        (dolist (format '(rss atom))
29
+          (let ((feed (make-instance 'tag-feed :format format
30
+                                     :content (take-up-to 10 tagged)
31
+                                     :slug (format nil "~a-~(~a~)" tag format))))
32
+            (add-document feed)))))))
33
+
34
+(defmethod publish ((doc-type (eql (find-class 'tag-feed))))
35
+  (dolist (feed (find-all 'tag-feed))
36
+    (write-document feed (theme-fn (feed-format feed) "feeds"))))

+ 0 - 35
src/indexes.lisp

@@ -76,41 +76,6 @@
76 76
                         :prev (when (plusp prev) prev)
77 77
                         :next (when (<= next (length indexes)) next))))))
78 78
 
79
-;;; Atom and RSS Feeds
80
-
81
-(defclass feed (index)
82
-  ((format :initform nil :initarg :format :accessor feed-format)))
83
-
84
-(defmethod discover ((doc-type (eql (find-class 'feed))))
85
-  (let ((content (by-date (find-all 'post))))
86
-    (dolist (format '(rss atom))
87
-      (let ((feed (make-instance 'feed :format format
88
-                                 :content (take-up-to 10 content)
89
-                                 :slug (format nil "~(~a~)" format))))
90
-        (add-document feed)))))
91
-
92
-(defmethod publish ((doc-type (eql (find-class 'feed))))
93
-  (dolist (feed (find-all 'feed))
94
-    (write-document feed (theme-fn (feed-format feed) "feeds"))))
95
-
96
-;;; Tag Feeds
97
-
98
-(defclass tag-feed (feed) ())
99
-
100
-(defmethod discover ((doc-type (eql (find-class 'tag-feed))))
101
-  (let ((content (by-date (find-all 'post))))
102
-    (dolist (tag (feeds *config*))
103
-      (let ((tagged (remove-if-not (lambda (x) (tag-p tag x)) content)))
104
-        (dolist (format '(rss atom))
105
-          (let ((feed (make-instance 'tag-feed :format format
106
-                                     :content (take-up-to 10 tagged)
107
-                                     :slug (format nil "~a-~(~a~)" tag format))))
108
-            (add-document feed)))))))
109
-
110
-(defmethod publish ((doc-type (eql (find-class 'tag-feed))))
111
-  (dolist (feed (find-all 'tag-feed))
112
-    (write-document feed (theme-fn (feed-format feed) "feeds"))))
113
-
114 79
 ;;; Helper Functions
115 80
 
116 81
 (defun all-months ()