From f602c371ea38e483439f8e317aaf04043806eba9 Mon Sep 17 00:00:00 2001 From: Brit Butler Date: Thu, 1 May 2014 17:16:50 -0400 Subject: [PATCH] Split feeds back out into their own file. --- coleslaw.asd | 1 + src/feeds.lisp | 36 ++++++++++++++++++++++++++++++++++++ src/indexes.lisp | 35 ----------------------------------- 3 files changed, 37 insertions(+), 35 deletions(-) create mode 100644 src/feeds.lisp diff --git a/coleslaw.asd b/coleslaw.asd index d859b2b..c0daab3 100644 --- a/coleslaw.asd +++ b/coleslaw.asd @@ -23,6 +23,7 @@ (:file "content") (:file "posts") (:file "indexes") + (:file "feeds") (:file "coleslaw")) :in-order-to ((test-op (load-op coleslaw-tests))) :perform (test-op :after (op c) diff --git a/src/feeds.lisp b/src/feeds.lisp new file mode 100644 index 0000000..8aa5e3c --- /dev/null +++ b/src/feeds.lisp @@ -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")))) diff --git a/src/indexes.lisp b/src/indexes.lisp index 8ead77b..b3de793 100644 --- a/src/indexes.lisp +++ b/src/indexes.lisp @@ -76,41 +76,6 @@ :prev (when (plusp prev) prev) :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 (defun all-months ()