Overhaul RENDER-FEEDS and associated templates.

This commit is contained in:
Brit Butler 2012-09-12 14:24:51 -04:00
parent f438f0eb89
commit 2b357db86f
5 changed files with 25 additions and 33 deletions

View file

@ -35,7 +35,7 @@ Additional args to render CONTENT can be passed via RENDER-ARGS."
(run-program "cp -R ~a ." dir)))
(render-posts)
(render-indices)
(render-feeds)))
(render-feeds (feeds *config*))))
(defgeneric deploy (staging)
(:documentation "Deploy the STAGING dir, updating the .prev and .curr symlinks.")

View file

@ -4,6 +4,7 @@
((author :initarg :author :initform "" :accessor author)
(deploy :initarg :deploy :initform nil :accessor deploy)
(domain :initarg :domain :initform "" :accessor domain)
(feeds :initarg :feeds :initform nil :accessor feeds)
(license :initarg :license :initform "CC-BY-SA" :accessor license)
(plugins :initarg :plugins :initform '() :accessor plugins)
(repo :initarg :repo :initform #p"/" :accessor repo)

View file

@ -15,20 +15,11 @@
(local-time:now))))
(local-time:format-rfc1123-timestring nil timestamp)))
(defun render-feeds ()
"Render and write the feed for the site."
(let* ((bydate (by-date (hash-table-values *posts*)))
(posts (subseq bydate 0 (min (length bydate) 10)))
(content (loop for post in posts
collect (list :title (post-title post)
:url (post-url post)
:date (make-pubdate (post-date post))
:tags (post-tags post)
: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)))
(defun render-feeds (feeds)
"Render and write the given FEEDS for the site."
(let* ((by-date (by-date (hash-table-values *posts*)))
(posts (subseq by-date 0 (min (length by-date) 10))))
(render-page (make-instance 'index :path "rss.xml" :posts posts) :rss)
(render-page (make-instance 'index :path "feed.atom" :posts posts) :atom)
(dolist (feed feeds)
(render-page feed :rss))))

View file

@ -4,23 +4,23 @@
<?xml version="1.0"?>{\n}
<feed xmlns="http://www.w3.org/2005/Atom">
<title>{$title}</title>
<link href="{$siteroot}"/>
<link type="application/atom+xml" rel="self" href="{$siteroot}/atom.xml"/>
<title>{$config.title}</title>
<link href="{$config.domain}"/>
<link type="application/atom+xml" rel="self" href="{$config.domain}/atom.xml"/>
<updated>{$pubdate}</updated>
<author>
<name>{$author}</name>
<name>{$config.author}</name>
</author>
{foreach $post in $posts}
{foreach $post in $content.posts}
<entry>
<link type="text/html" rel="alternate" href="{$post.url}"/>
<link type="text/html" rel="alternate" href="{$config.domain}/posts/{$post.slug}.html"/>
<title>{$post.title}</title>
<published>{$post.date}</published>
<updated>{$post.date}</updated>
<author>
<name>{$author}</name>
<uri>{$siteroot}</uri>
<name>{$config.author}</name>
<uri>{$config.domain}</uri>
</author>
<content type="html">{$post.content |noAutoescape}</content>
</entry>

View file

@ -4,19 +4,19 @@
<?xml version="1.0"?>{\n}
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>{$title}</title>
<link>{$siteroot}</link>
<atom:link href="{$siteroot}/rss.xml" rel="self" type="application/rss+xml" />
<title>{$config.title}</title>
<link>{$config.domain}</link>
<atom:link href="{$config.domain}/rss.xml" rel="self" type="application/rss+xml" />
<language>en-us</language>
<pubDate>{$pubdate}</pubDate>
{foreach $post in $posts}
{foreach $post in $content.posts}
<item>
<title>{$post.title}</title>
<link>{$siteroot}/posts/{$post.url}</link>
<link>{$config.domain}/posts/{$post.slug}.html</link>
<pubDate>{$post.date}</pubDate>
<author>{$author}</author>
<guid isPermaLink="true">{$siteroot}/posts/{$post.url}</guid>
<author>{$config.author}</author>
<guid isPermaLink="true">{$config.domain}/posts/{$post.slug}.html</guid>
{foreach $tag in $post.tags}
<category><![CDATA[ {$tag} ]]></category>
{/foreach}