Mercurial > blahgd
changeset 9:24e7c7095045
feed: rss2 feed
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Tue, 03 Feb 2009 02:33:01 -0500 |
parents | 31eafc110fc2 |
children | 3d159c650d4a |
files | common-head.sh feed.cgi templates/footer.rss2 templates/header.rss2 templates/story-bottom-desc.rss2 templates/story-bottom.rss2 templates/story-cat-item.rss2 templates/story-middle-desc.rss2 templates/story-middle.rss2 templates/story-top.rss2 |
diffstat | 10 files changed, 93 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/common-head.sh Sat Jan 31 18:07:23 2009 -0500 +++ b/common-head.sh Tue Feb 03 02:33:01 2009 -0500 @@ -16,6 +16,12 @@ date "+%H:%M" -d "`get_xattr post_time "$1"`" } +# usage: get_date <filename> +get_rss_date() +{ + date "+%a, %d %b %Y %H:%M:%S +0000" -d "`get_xattr post_time "$1"`" +} + # usage: str_month <MM> str_month() { @@ -64,5 +70,10 @@ ' } +cat_post_preview() +{ + cat "$1" | head -1 +} + echo "Content-type: text/html" echo ""
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/feed.cgi Tue Feb 03 02:33:01 2009 -0500 @@ -0,0 +1,45 @@ +#!/bin/sh + +. common-head.sh + +########################## + +fmt="rss2" + +last=`ls data/posts/ | sort -nr | head -1` +cat templates/header.$fmt | sed -e "s|@@LASTPUBDATE@@|`get_rss_date data/posts/$last/`|g" + +cnt=0 + +for postid in `ls data/posts/ | sort -rn` ; do + cnt=$(($cnt + 1)) + [ $cnt -gt 15 ] && break + + fn="data/posts/$postid/" + + cat templates/story-top.$fmt | sed -e " +s|@@POSTID@@|`basename $postid`|g +s|@@POSTDATE@@|`get_rss_date "$fn"`|g +s|@@TITLE@@|`get_xattr post_title "$fn"`|g +" + + for catname in `get_xattr post_cats "$fn" | sed -e 's|,| |g'` ; do + cat templates/story-cat-item.rss | sed -e " +s|@@CATNAME@@|$catname|g + " + done + + cat templates/story-middle-desc.$fmt | sed -e " +s|@@POSTTIME@@|`get_rss_date "$fn"`|g + " + cat_post_preview "$fn/post.txt" + cat templates/story-bottom-desc.$fmt + + cat templates/story-middle.$fmt | sed -e " +s|@@POSTTIME@@|`get_rss_date "$fn"`|g + " + cat_post "$fn/post.txt" + cat templates/story-bottom.$fmt +done + +cat templates/footer.$fmt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/footer.rss2 Tue Feb 03 02:33:01 2009 -0500 @@ -0,0 +1,2 @@ + </channel> +</rss>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/header.rss2 Tue Feb 03 02:33:01 2009 -0500 @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<rss version="2.0" + xmlns:content="http://purl.org/rss/1.0/modules/content/" + xmlns:wfw="http://wellformedweb.org/CommentAPI/" + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:atom="http://www.w3.org/2005/Atom" + > + +<channel> + <title>Josef "Jeff" Sipek</title> + <atom:link href="http://josefsipek.net/blahg/?feed=rss2" rel="self" type="application/rss+xml" /> + <link>http://josefsipek.net/blahg</link> + <description>Wasting time effectively</description> + <generator>http://josefsipek.net/</generator> + <language>en</language> + <pubDate>@@LASTPUBDATE@@</pubDate> +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/story-bottom-desc.rss2 Tue Feb 03 02:33:01 2009 -0500 @@ -0,0 +1,1 @@ + [...]]]></description>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/story-bottom.rss2 Tue Feb 03 02:33:01 2009 -0500 @@ -0,0 +1,3 @@ +]]></content:encoded> + </item> +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/story-cat-item.rss2 Tue Feb 03 02:33:01 2009 -0500 @@ -0,0 +1,1 @@ + <category><![CDATA[@@CATNAME@@]]></category>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/story-middle-desc.rss2 Tue Feb 03 02:33:01 2009 -0500 @@ -0,0 +1,1 @@ + <description><![CDATA[
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/story-middle.rss2 Tue Feb 03 02:33:01 2009 -0500 @@ -0,0 +1,1 @@ + <content:encoded><![CDATA[
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/story-top.rss2 Tue Feb 03 02:33:01 2009 -0500 @@ -0,0 +1,11 @@ + <item> + <title>@@TITLE@@</title> + <link>http://josefsipek.net/blahg-test/?p=@@POSTID@@</link> + <comments>http://josefsipek.net/blahg-test/?p=@@POSTID@@#comments</comments> + + <pubDate>@@POSTDATE@@</pubDate> + <dc:creator>JeffPC</dc:creator> + + <guid isPermaLink="false">http://josefsipek.net/blahg-test/?p=@@POSTID@@</guid> + + <wfw:commentRss>http://josefsipek.net/blahg/?feed=rss2&p=@@POSTID@@</wfw:commentRss>