|
@@ -4,24 +4,16 @@
|
4
|
4
|
"Make a RFC1123 pubdate representing the current time."
|
5
|
5
|
(local-time:format-rfc1123-timestring nil (local-time:now)))
|
6
|
6
|
|
7
|
|
-(defun first-10 (list)
|
8
|
|
- "Get up to the first 10 items in LIST."
|
9
|
|
- (subseq list 0 (min (length list) 10)))
|
10
|
|
-
|
11
|
|
-(defun make-tag-feed (tag posts)
|
12
|
|
- "Make an RSS feed for the given TAG and POSTS."
|
13
|
|
- (flet ((valid-p (obj) (member tag (content-tags obj) :test #'tag-slug=)))
|
14
|
|
- (make-instance 'tag-index :id (format nil "~A-rss.xml" (tag-slug tag))
|
15
|
|
- :posts (first-10 (remove-if-not #'valid-p posts)))))
|
16
|
|
-
|
17
|
7
|
(defun render-feed (posts &key path template tag)
|
18
|
|
- "Given a PATH, TEMPLATE, and possibly a TAG, render the appropriate feed."
|
19
|
|
- (let ((template (theme-fn template "feeds"))
|
20
|
|
- (index (if tag
|
21
|
|
- (make-tag-feed tag posts)
|
22
|
|
- (make-instance 'index :id path
|
23
|
|
- :posts (first-10 posts)))))
|
24
|
|
- (write-page (page-path index) (render-page index template))))
|
|
8
|
+ (flet ((first-10 (list) (subseq list 0 (min (length list) 10)))
|
|
9
|
+ (tag-posts (list) (remove-if-not (lambda (x) (tag-p tag x)) list)))
|
|
10
|
+ (let ((template (theme-fn template "feeds"))
|
|
11
|
+ (index (if tag
|
|
12
|
+ (make-instance 'tag-index :id path
|
|
13
|
+ :posts (first-10 (tag-posts posts)))
|
|
14
|
+ (make-instance 'index :id path
|
|
15
|
+ :posts (first-10 posts)))))
|
|
16
|
+ (write-page (page-path index) (render-page index template)))))
|
25
|
17
|
|
26
|
18
|
(defun render-feeds (tag-feeds)
|
27
|
19
|
"Render the default RSS and ATOM feeds along with any TAG-FEEDS."
|
|
@@ -30,5 +22,6 @@
|
30
|
22
|
(:path "feed.atom" :template :atom-feed)))
|
31
|
23
|
(apply #'render-feed posts feed))
|
32
|
24
|
(dolist (feed tag-feeds)
|
33
|
|
- (apply #'render-feed posts (list :tag (make-tag feed)
|
|
25
|
+ (apply #'render-feed posts (list :path (format nil "~A-rss.xml" feed)
|
|
26
|
+ :tag (make-tag feed)
|
34
|
27
|
:template :rss-feed)))))
|