Split feeds back out into their own file.
This commit is contained in:
parent
b703477ed8
commit
f602c371ea
3 changed files with 37 additions and 35 deletions
|
@ -23,6 +23,7 @@
|
||||||
(:file "content")
|
(:file "content")
|
||||||
(:file "posts")
|
(:file "posts")
|
||||||
(:file "indexes")
|
(:file "indexes")
|
||||||
|
(:file "feeds")
|
||||||
(:file "coleslaw"))
|
(:file "coleslaw"))
|
||||||
:in-order-to ((test-op (load-op coleslaw-tests)))
|
:in-order-to ((test-op (load-op coleslaw-tests)))
|
||||||
:perform (test-op :after (op c)
|
:perform (test-op :after (op c)
|
||||||
|
|
36
src/feeds.lisp
Normal file
36
src/feeds.lisp
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
(in-package :coleslaw)
|
||||||
|
|
||||||
|
;;; Atom and RSS Feeds
|
||||||
|
|
||||||
|
(defclass feed (index)
|
||||||
|
((format :initform nil :initarg :format :accessor feed-format)))
|
||||||
|
|
||||||
|
(defmethod discover ((doc-type (eql (find-class 'feed))))
|
||||||
|
(let ((content (by-date (find-all 'post))))
|
||||||
|
(dolist (format '(rss atom))
|
||||||
|
(let ((feed (make-instance 'feed :format format
|
||||||
|
:content (take-up-to 10 content)
|
||||||
|
:slug (format nil "~(~a~)" format))))
|
||||||
|
(add-document feed)))))
|
||||||
|
|
||||||
|
(defmethod publish ((doc-type (eql (find-class 'feed))))
|
||||||
|
(dolist (feed (find-all 'feed))
|
||||||
|
(write-document feed (theme-fn (feed-format feed) "feeds"))))
|
||||||
|
|
||||||
|
;;; Tag Feeds
|
||||||
|
|
||||||
|
(defclass tag-feed (feed) ())
|
||||||
|
|
||||||
|
(defmethod discover ((doc-type (eql (find-class 'tag-feed))))
|
||||||
|
(let ((content (by-date (find-all 'post))))
|
||||||
|
(dolist (tag (feeds *config*))
|
||||||
|
(let ((tagged (remove-if-not (lambda (x) (tag-p tag x)) content)))
|
||||||
|
(dolist (format '(rss atom))
|
||||||
|
(let ((feed (make-instance 'tag-feed :format format
|
||||||
|
:content (take-up-to 10 tagged)
|
||||||
|
:slug (format nil "~a-~(~a~)" tag format))))
|
||||||
|
(add-document feed)))))))
|
||||||
|
|
||||||
|
(defmethod publish ((doc-type (eql (find-class 'tag-feed))))
|
||||||
|
(dolist (feed (find-all 'tag-feed))
|
||||||
|
(write-document feed (theme-fn (feed-format feed) "feeds"))))
|
|
@ -76,41 +76,6 @@
|
||||||
:prev (when (plusp prev) prev)
|
:prev (when (plusp prev) prev)
|
||||||
:next (when (<= next (length indexes)) next))))))
|
:next (when (<= next (length indexes)) next))))))
|
||||||
|
|
||||||
;;; Atom and RSS Feeds
|
|
||||||
|
|
||||||
(defclass feed (index)
|
|
||||||
((format :initform nil :initarg :format :accessor feed-format)))
|
|
||||||
|
|
||||||
(defmethod discover ((doc-type (eql (find-class 'feed))))
|
|
||||||
(let ((content (by-date (find-all 'post))))
|
|
||||||
(dolist (format '(rss atom))
|
|
||||||
(let ((feed (make-instance 'feed :format format
|
|
||||||
:content (take-up-to 10 content)
|
|
||||||
:slug (format nil "~(~a~)" format))))
|
|
||||||
(add-document feed)))))
|
|
||||||
|
|
||||||
(defmethod publish ((doc-type (eql (find-class 'feed))))
|
|
||||||
(dolist (feed (find-all 'feed))
|
|
||||||
(write-document feed (theme-fn (feed-format feed) "feeds"))))
|
|
||||||
|
|
||||||
;;; Tag Feeds
|
|
||||||
|
|
||||||
(defclass tag-feed (feed) ())
|
|
||||||
|
|
||||||
(defmethod discover ((doc-type (eql (find-class 'tag-feed))))
|
|
||||||
(let ((content (by-date (find-all 'post))))
|
|
||||||
(dolist (tag (feeds *config*))
|
|
||||||
(let ((tagged (remove-if-not (lambda (x) (tag-p tag x)) content)))
|
|
||||||
(dolist (format '(rss atom))
|
|
||||||
(let ((feed (make-instance 'tag-feed :format format
|
|
||||||
:content (take-up-to 10 tagged)
|
|
||||||
:slug (format nil "~a-~(~a~)" tag format))))
|
|
||||||
(add-document feed)))))))
|
|
||||||
|
|
||||||
(defmethod publish ((doc-type (eql (find-class 'tag-feed))))
|
|
||||||
(dolist (feed (find-all 'tag-feed))
|
|
||||||
(write-document feed (theme-fn (feed-format feed) "feeds"))))
|
|
||||||
|
|
||||||
;;; Helper Functions
|
;;; Helper Functions
|
||||||
|
|
||||||
(defun all-months ()
|
(defun all-months ()
|
||||||
|
|
Loading…
Add table
Reference in a new issue