Flexible Lisp Blogware. Fork for personal use. Mirrored from https://github.com/kingcons/coleslaw originally.

feeds.lisp 1.3KB

12345678910111213141516171819202122232425262728
  1. (in-package :coleslaw)
  2. (defun make-pubdate ()
  3. "Make a RFC1123 pubdate representing the current time."
  4. (local-time:format-rfc1123-timestring nil (local-time:now)))
  5. (defun render-feed (posts &key path template tag)
  6. (flet ((first-10 (list) (subseq list 0 (min (length list) 10)))
  7. (tag-posts (list) (remove-if-not (lambda (x) (tag-p tag x)) list)))
  8. (let ((template (theme-fn template "feeds"))
  9. (index (if tag
  10. (make-instance 'tag-index :id path
  11. :posts (first-10 (tag-posts posts)))
  12. (make-instance 'index :id path
  13. :posts (first-10 posts)))))
  14. (write-page (page-path index) (render-page index template)))))
  15. (defun render-feeds (tag-feeds)
  16. "Render the default RSS and ATOM feeds along with any TAG-FEEDS."
  17. (let ((posts (by-date (find-all 'post))))
  18. (dolist (feed '((:path "rss.xml" :template :rss-feed)
  19. (:path "atom.xml" :template :atom-feed)))
  20. (apply #'render-feed posts feed))
  21. (dolist (feed tag-feeds)
  22. (apply #'render-feed posts (list :path (format nil "~A-rss.xml" feed)
  23. :tag (make-tag feed)
  24. :template :rss-feed)))))