From d3dc6f0c5ca8f7a2bc53f24009523a20d91a8043 Mon Sep 17 00:00:00 2001 From: Brit Butler Date: Wed, 29 Aug 2012 23:25:41 -0400 Subject: [PATCH] Add ATOM feed support. --- src/coleslaw.lisp | 2 +- src/feeds.lisp | 18 +++++++++--------- themes/hyde/atom.tmpl | 31 +++++++++++++++++++++++++++++++ themes/hyde/base.tmpl | 1 + 4 files changed, 42 insertions(+), 10 deletions(-) create mode 100644 themes/hyde/atom.tmpl diff --git a/src/coleslaw.lisp b/src/coleslaw.lisp index 2768fe2..458a74c 100644 --- a/src/coleslaw.lisp +++ b/src/coleslaw.lisp @@ -34,7 +34,7 @@ If RAW is non-nil, write the content without wrapping it in the base template." (run-program "cp -R ~a ." dir))) (render-posts) (render-indices) - (render-feed))) + (render-feeds))) (defgeneric deploy (staging) (:documentation "Deploy the STAGING dir, updating the .prev and .curr symlinks.") diff --git a/src/feeds.lisp b/src/feeds.lisp index 3598439..7d785f7 100644 --- a/src/feeds.lisp +++ b/src/feeds.lisp @@ -15,7 +15,7 @@ (local-time:now)))) (local-time:format-rfc1123-timestring nil timestamp))) -(defun render-feed () +(defun render-feeds () "Render and write the feed for the site." (let* ((posts (subseq (by-date (hash-table-values *posts*)) 0 10)) (content (loop for post in posts @@ -23,11 +23,11 @@ :url (post-url post) :date (make-pubdate (post-date post)) :tags (post-tags post) - :content (post-content post))))) - (render-page "rss.xml" - (funcall (theme-fn 'rss) - (list :pubdate (make-pubdate) - :title (title *config*) - :siteroot (domain *config*) - :author (author *config*) - :posts content)) :raw t))) + :content (post-content post)))) + (tmpl-args (list :pubdate (make-pubdate) + :title (title *config*) + :siteroot (domain *config*) + :author (author *config*) + :posts content))) + (render-page "rss.xml" (funcall (theme-fn 'rss) tmpl-args) :raw t) + (render-page "feed.atom" (funcall (theme-fn 'atom) tmpl-args) :raw t))) diff --git a/themes/hyde/atom.tmpl b/themes/hyde/atom.tmpl new file mode 100644 index 0000000..d0b0623 --- /dev/null +++ b/themes/hyde/atom.tmpl @@ -0,0 +1,31 @@ +{namespace coleslaw.theme.hyde} + +{template atom} +{\n} + + + {$title} + + + {$pubdate} + {$siteroot}@{$pubdate} + + {$author} + + + {foreach $post in $posts} + + + {$post.title} + {$post.date} + {$post.date} + + {$author} + {$siteroot} + + {$post.content} + + {/foreach} + + +{/template} diff --git a/themes/hyde/base.tmpl b/themes/hyde/base.tmpl index b4c90b7..b1f3529 100644 --- a/themes/hyde/base.tmpl +++ b/themes/hyde/base.tmpl @@ -10,6 +10,7 @@ + {if $headInject} {$headInject |noAutoescape} {/if}