Improve the atom and rss templates: fix bugs in link attirbutes, simplify code, and include html posts in rss feeds instead of raw markdown.

This commit is contained in:
Uriel 2009-02-18 09:28:20 +00:00
parent ac18ad7f4e
commit bab24f9cdf
2 changed files with 38 additions and 47 deletions

View file

@ -24,8 +24,8 @@ updated = `{/bin/date --rfc-3339'=seconds' |sed 's/ /T/'}
<feed xmlns="http://www.w3.org/2005/Atom" <feed xmlns="http://www.w3.org/2005/Atom"
xmlns:thr="http://purl.org/syndication/thread/1.0"> xmlns:thr="http://purl.org/syndication/thread/1.0">
<link rel="self" href="%($req_path%)"/> <link rel="self" href="%($base_url^$req_path%)"/>
<id>%($req_path%)</id> <id>%($base_url^$req_path%)</id>
<icon>/favicon.ico</icon> <icon>/favicon.ico</icon>
<title>%($siteTitle%)</title> <title>%($siteTitle%)</title>

View file

@ -15,25 +15,16 @@ fn statpost {
#mdate=`{/bin/date -Rd $stat(1)} # Not used because it is unreliable #mdate=`{/bin/date -Rd $stat(1)} # Not used because it is unreliable
post_uri=$base_url^`{cleanname `{echo -n $post_uri | sed 's/\.(md|tpl)//g'}} post_uri=$base_url^`{cleanname `{echo -n $post_uri | sed 's/\.(md|tpl)//g'}}
by=$stat(2) by=$stat(2)
ifs=() { ifs=() { summary=`{cat $f/index.md | $formatter | escape_html} }
summary=`{awk -v max'='1024 '{
nc += 1 + length;
if(nc > max) {
print substr($0, 1, nc - max) "..."
exit
}
print
}' $f/index.md |fmt -j| sed 's/\]\]>/Fucking goddamn XML garbage/g'}
}
} }
%} %}
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel> <channel>
<atom:link href="%('http://'$site^$req_path%)" rel="self" type="application/rss+xml" /> <atom:link href="%($base_url^$req_path%)" rel="self" type="application/rss+xml" />
<title>%($siteTitle%)</title> <title>%($siteTitle%)</title>
<link>%($req_path%)</link> <link>%($base_url^$req_path%)</link>
<description>%($blogDesc%)</description> <description>%($blogDesc%)</description>
<language>en-us</language> <language>en-us</language>
<generator>Tom Duff's rc, and Kris Maglione's clever hackery</generator> <generator>Tom Duff's rc, and Kris Maglione's clever hackery</generator>
@ -52,10 +43,10 @@ fn statpost {
<item> <item>
<title>%($title%)</title> <title>%($title%)</title>
<author>%($by%)@noreply.cat-v.org (%($by%))</author> <author>%($by%)@noreply.cat-v.org (%($by%))</author>
<link>%($uri%)</link> <link>%($post_uri%)</link>
<guid isPermaLink="true">%($uri%)</guid> <guid isPermaLink="true">%($post_uri%)</guid>
<pubDate>%($date%)</pubDate> <pubDate>%($date%)</pubDate>
<description><![CDATA[<pre>%($summary%)</pre>]]></description> <description>%($summary%)</description>
</item> </item>
% } % }