Mercurial > blahgd
changeset 10:3d159c650d4a
feed: atom feed
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Tue, 03 Feb 2009 14:54:30 -0500 |
parents | 24e7c7095045 |
children | 41327f4785ac |
files | common-head.sh feed.cgi templates/header.atom templates/story-bottom-desc.atom templates/story-bottom.atom templates/story-cat-item.atom templates/story-middle-desc.atom templates/story-middle.atom templates/story-top.atom |
diffstat | 9 files changed, 75 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/common-head.sh Tue Feb 03 02:33:01 2009 -0500 +++ b/common-head.sh Tue Feb 03 14:54:30 2009 -0500 @@ -16,10 +16,20 @@ date "+%H:%M" -d "`get_xattr post_time "$1"`" } -# usage: get_date <filename> +# usage: get_date <fmt> <filename> get_rss_date() { - date "+%a, %d %b %Y %H:%M:%S +0000" -d "`get_xattr post_time "$1"`" + case "$1" in + rss2) + date "+%a, %d %b %Y %H:%M:%S +0000" -d "`get_xattr post_time "$2"`" + ;; + atom) + date "+%Y-%m-%dT%H:%M:%SZ" -d "`get_xattr post_time "$2"`" + ;; + *) + echo "???" + ;; + esac } # usage: str_month <MM> @@ -75,5 +85,6 @@ cat "$1" | head -1 } -echo "Content-type: text/html" +[ -z "$CONTENT_TYPE" ] && CONTENT_TYPE="text/html" +echo "Content-type: $CONTENT_TYPE" echo ""
--- a/feed.cgi Tue Feb 03 02:33:01 2009 -0500 +++ b/feed.cgi Tue Feb 03 14:54:30 2009 -0500 @@ -1,13 +1,31 @@ #!/bin/sh +case "$PATH_INFO" in + /rss) + fmt="rss" + CONTENT_TYPE="text/xml; charset=UTF-8" + ;; + /rss2) + fmt="rss2" + CONTENT_TYPE="text/xml; charset=UTF-8" + ;; + /atom) + fmt="atom" + CONTENT_TYPE="application/atom+xml; charset=UTF-8" + ;; + *) + echo "Location: /blahg-test/" + echo "" + exit 0 + ;; +esac + . 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" +cat templates/header.$fmt | sed -e "s|@@LASTPUBDATE@@|`get_rss_date $fmt data/posts/$last/`|g" cnt=0 @@ -19,7 +37,7 @@ cat templates/story-top.$fmt | sed -e " s|@@POSTID@@|`basename $postid`|g -s|@@POSTDATE@@|`get_rss_date "$fn"`|g +s|@@POSTDATE@@|`get_rss_date $fmt "$fn"`|g s|@@TITLE@@|`get_xattr post_title "$fn"`|g " @@ -30,13 +48,14 @@ done cat templates/story-middle-desc.$fmt | sed -e " -s|@@POSTTIME@@|`get_rss_date "$fn"`|g +s|@@POSTTIME@@|`get_rss_date $fmt "$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 +s|@@POSTTIME@@|`get_rss_date $fmt "$fn"`|g +s|@@POSTID@@|`basename $postid`|g " cat_post "$fn/post.txt" cat templates/story-bottom.$fmt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/header.atom Tue Feb 03 14:54:30 2009 -0500 @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?><feed + xmlns="http://www.w3.org/2005/Atom" + xmlns:thr="http://purl.org/syndication/thread/1.0" + xml:lang="en" + xml:base="http://josefsipek.net/blahg-test/?feed=atom" + > + <title type="text">Josef "Jeff" Sipek</title> + <subtitle type="text">Wasting time effectively</subtitle> + + <generator uri="http://josefsipek.net/" version="0.10">Pile Of Shell</generator> + + <link rel="alternate" type="text/html" href="http://josefsipek.net/blahg-test/" /> + <id>http://josefsipek.net/blahg-test/?feed=atom</id> + <link rel="self" type="application/atom+xml" href="http://josefsipek.net/blahg-test/?feed=atom" /> + + <updated>@@LASTPUBDATE@@</updated>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/story-bottom-desc.atom Tue Feb 03 14:54:30 2009 -0500 @@ -0,0 +1,1 @@ + [...]]]></summary>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/story-bottom.atom Tue Feb 03 14:54:30 2009 -0500 @@ -0,0 +1,2 @@ +]]></content> + </entry>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/story-cat-item.atom Tue Feb 03 14:54:30 2009 -0500 @@ -0,0 +1,1 @@ + <category scheme="http://josefsipek.net/blahg-test/" term="@@CATNAME@@" />
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/story-middle-desc.atom Tue Feb 03 14:54:30 2009 -0500 @@ -0,0 +1,1 @@ + <summary type="html"><![CDATA[
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/story-middle.atom Tue Feb 03 14:54:30 2009 -0500 @@ -0,0 +1,1 @@ + <content type="html" xml:base="http://josefsipek.net/blahg/?p=@@POSTID@@"><![CDATA[
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/story-top.atom Tue Feb 03 14:54:30 2009 -0500 @@ -0,0 +1,14 @@ + <entry> + <author> + <name>JeffPC</name> + <uri>http://www.josefsipek.net</uri> + </author> + <title type="html"><![CDATA[@@TITLE@@]]></title> + <link rel="alternate" type="text/html" href="http://josefsipek.net/blahg-test/?p=@@POSTID@@" /> + <id>http://josefsipek.net/blahg-test/?p=@@POSTID@@</id> + <updated>@@POSTDATE@@</updated> + <published>@@POSTDATE@@</published> + + <link rel="replies" type="text/html" href="http://josefsipek.net/blahg-test/?p=@@POSTID@@#comments" thr:count="1"/> + <link rel="replies" type="application/atom+xml" href="http://josefsipek.net/blahg-test/?feed=atom&p=@@POSTID@@" thr:count="1"/> + <thr:total>1</thr:total>