[Basic RSS feed support for weblog clinton@unknownlamer.org**20091209190252 Ignore-this: a3881b7a4b8195270b04775e8094e07e ] hunk ./beesknees.asd 27 - (:file "markdown-editor")) + (:file "markdown-editor") + (:file "rss")) hunk ./beesknees.asd 44 - :cl-markdown)) + :cl-markdown :xml-emitter)) hunk ./src/core/site-control.lisp 61 + + (let ((rss-cache nil)) + (defentry-point "^feeds/weblog.rss$" (:application (find-site-application site :frontend) + :class regexp-dispatcher + :with-call/cc nil) + () + (unless (and rss-cache (= (car rss-cache) + (beesknees.weblog::entry-posted (car (golgonooza-db:get-instances-limit 'beesknees.weblog:weblog-entry 'beesknees.weblog::posted nil nil :limit 1 :from-end t))))) + (let ((entries (golgonooza-db:get-instances-limit 'beesknees.weblog:weblog-entry 'beesknees.weblog::posted nil nil :limit 10 :from-end t))) + (setf rss-cache (cons (beesknees.weblog:entry-posted (car entries)) + (with-output-to-string (string) + (beesknees.weblog::generate-feed + entries + string)))))) + (serve-sequence (cdr rss-cache) + :content-type "application/rss+xml" + :last-modified (car rss-cache)))) + addfile ./src/weblog/rss.lisp hunk ./src/weblog/rss.lisp 1 - +(in-package :beesknees.weblog) + +(defun generate-feed (entries stream) + (xml-emitter:with-rss2 (stream :encoding "UTF-8") + (xml-emitter:rss-channel-header "Bees Knees Films" + "http://bees-kneesfilms.com" + :description "The Bees Knees Film") + (dolist (entry entries) + (xml-emitter:rss-item (entry-title entry) + :description (multiple-value-bind (doc string) + (cl-markdown:markdown (entry-body entry) + :stream nil) + (declare (ignore doc)) + string) + ;; fixme: should not be hardcoded/duplicated + :guid (format nil "http://bees-kneesfilms.com/pages/blog/entry/~D" + (entry-posted entry)) + :pubdate (local-time:format-timestring + nil (local-time:universal-to-timestamp + (entry-posted entry)) + :format '(:short-weekday ", " + (:day 2) #\space :short-month #\space (:year 4) #\space + (:hour 2) #\: (:min 2) #\: (:sec 2) #\space :timezone))))))