swerc

anselm's simpler werc fork
git clone git://git.suckless.org/swerc
Log | Files | Refs | README

commit b88e8453567e66bb45439f7ba9ddaee016c202ba
parent 4c4ceb367524f162943c67631dbbb12aecda5fa2
Author: uriel@soma <unknown>
Date:   Wed, 18 Feb 2009 09:28:20 +0000

Improve the atom and rss templates: fix bugs in link attirbutes, simplify code, and include html posts in rss feeds instead of raw markdown.
Diffstat:
Mapps/blagh/atom.tpl | 4++--
Mapps/blagh/rss20.tpl | 81+++++++++++++++++++++++++++++++++++--------------------------------------------
2 files changed, 38 insertions(+), 47 deletions(-)

diff --git a/apps/blagh/atom.tpl b/apps/blagh/atom.tpl @@ -24,8 +24,8 @@ updated = `{/bin/date --rfc-3339'=seconds' |sed 's/ /T/'} <feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0"> - <link rel="self" href="%($req_path%)"/> - <id>%($req_path%)</id> + <link rel="self" href="%($base_url^$req_path%)"/> + <id>%($base_url^$req_path%)</id> <icon>/favicon.ico</icon> <title>%($siteTitle%)</title> diff --git a/apps/blagh/rss20.tpl b/apps/blagh/rss20.tpl @@ -4,60 +4,51 @@ Content-Type: text/xml; charset=utf-8 %{ fn statpost { - f = $1 + f = $1 - post_uri = `{echo $f | sed 's,^'$sitedir',,'} - #title=`{basename $f | sed 's/^[0-9\-]*_(.*)\.md$/\1/; s/_/ /g' } + post_uri = `{echo $f | sed 's,^'$sitedir',,'} + #title=`{basename $f | sed 's/^[0-9\-]*_(.*)\.md$/\1/; s/_/ /g' } title=`{read $f/index.md} - date=`{/bin/date -Rd `{echo $f|sed 's,.*/([0-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9])/.*,\1,'}} - # TODO: use mtime(1) and ls(1) instead of lunix's stat(1) - stat=`{stat -c '%Y %U' $f} - #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'}} - by=$stat(2) - ifs=() { - 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'} - } + date=`{/bin/date -Rd `{echo $f|sed 's,.*/([0-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9])/.*,\1,'}} + # TODO: use mtime(1) and ls(1) instead of lunix's stat(1) + stat=`{stat -c '%Y %U' $f} + #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'}} + by=$stat(2) + ifs=() { summary=`{cat $f/index.md | $formatter | escape_html} } } %} <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> - <channel> - <atom:link href="%('http://'$site^$req_path%)" rel="self" type="application/rss+xml" /> - <title>%($siteTitle%)</title> - <link>%($req_path%)</link> - <description>%($blogDesc%)</description> - <language>en-us</language> - <generator>Tom Duff's rc, and Kris Maglione's clever hackery</generator> + <channel> + <atom:link href="%($base_url^$req_path%)" rel="self" type="application/rss+xml" /> + <title>%($siteTitle%)</title> + <link>%($base_url^$req_path%)</link> + <description>%($blogDesc%)</description> + <language>en-us</language> + <generator>Tom Duff's rc, and Kris Maglione's clever hackery</generator> %{ - # <webMaster>uriel99+rss@gmail.com (Uriel)</webMaster> + # <webMaster>uriel99+rss@gmail.com (Uriel)</webMaster> for(f in `{get_post_list $blagh_root$blagh_dirs}) { - statpost $f - # Hack to aproximate the last build date - #(use the mdate from last posted item) - # Commented out for now because maybe a wrong value is worse than no value - #if(~ $#last_build_date 0) { - #last_build_date='<lastBuildDate>'^$"mdate'</lastBuildDate>' - #echo $last_build_date - #} + statpost $f + # Hack to aproximate the last build date + #(use the mdate from last posted item) + # Commented out for now because maybe a wrong value is worse than no value + #if(~ $#last_build_date 0) { + #last_build_date='<lastBuildDate>'^$"mdate'</lastBuildDate>' + #echo $last_build_date + #} %} - <item> - <title>%($title%)</title> - <author>%($by%)@noreply.cat-v.org (%($by%))</author> - <link>%($uri%)</link> - <guid isPermaLink="true">%($uri%)</guid> - <pubDate>%($date%)</pubDate> - <description><![CDATA[<pre>%($summary%)</pre>]]></description> - </item> -% } + <item> + <title>%($title%)</title> + <author>%($by%)@noreply.cat-v.org (%($by%))</author> + <link>%($post_uri%)</link> + <guid isPermaLink="true">%($post_uri%)</guid> + <pubDate>%($date%)</pubDate> + <description>%($summary%)</description> + </item> +% } - </channel> + </channel> </rss>