ref: 5cb56d26c4173088aee574f33b150c76db3ef023
parent: cdbcde74ad973c69b3348e021693c8fce83d9540
author: kris <kris@engel.se.cat-v.org>
date: Mon Jun 4 01:41:28 EDT 2007
Added rss to controller.
--- a/bin/controller.rc
+++ b/bin/controller.rc
@@ -7,7 +7,6 @@
}
cd ..
-
# default config
site=$SERVER_NAME
sitedir=sites/$site
@@ -18,8 +17,9 @@
title=''
template=_default
sidebar=sidebar
+basedir=/gsoc/www
+baseuri=http://$site
-
# Title
fn gentitle {
echo '<h1 class="headerTitle"><a href="/">' ^ $"siteTitle ^ '<span id="headerSubTitle">' ^ $"siteSubTitle ^ '</span></a></h1>'
@@ -118,7 +118,6 @@
}
template=$sitedir/$template.tpl
-echo body: $body; echo body: $sitedir/$body; ls $sitedir/$body
body=$sitedir/$body
if (! ~ $#sidebar 0)
sidebar=tpl/_inc/$sidebar.tpl
@@ -125,6 +124,57 @@
if (test -d $body)
body=$body/index
+# RSS
+fn statpost {
+ f = $1
+ uri = `{echo $f | sed 's,^'$basedir',,'}
+ title=`{basename $f | sed 's/^[0-9\-]*_(.*)\.md$/\1/; s/_/ /g' }
+ stat=`{stat -c '%Y %U' $f}
+ date=`{/bin/date -Rd @$stat(1)}
+ uri=$baseuri^`{cleanname $uri}
+ by=$stat(2)
+ ifs=() {
+ summary=`{awk -v max'='1024 '{
+ nc += 1 + length;
+ if(nc > max) {
+ print substr($0, 1, nc - max) "..."
+ exit
+ }
+ }' $f | sed 's/\]\]>/Fucking goddamn XML garbage/g'}
+ }
+}
-cat $headers $template | template.awk | rc
+if(! ~ $REQUEST_URI */index.rss) {
+ cat $headers $template | template.awk | rc
+ exit
+}
+
+uri = `{echo $uri | sed 's/indexrss$//'}
+uri=$baseuri$"uri
+
+# Should be in a separate file.
+cat <<'!' | template.awk | rc
+<?xml version="1.0"?>
+<rss version="2.0">
+ <channel>
+ <title>%($blogTitle%)</title>
+ <link>%($uri%)</link>
+ <description>%($blogDesc%)</description>
+ <language>en-us</language>
+ <generator>Tom Duff's rc, and Kris Maglione's clever hackery</generator>
+ <webMaster>Uriel %lt;uriel99@gmail.com></webMaster>
+%{
+ for(f in `{sortedBlogPostList $blogDirs}) {
+ statpost $f
+%} <item>
+ <title>%($title%)</title>
+ <author>%($by%)</author>
+ <link>%($uri%)</link>
+ <pubDate>%($date%)</pubDate>
+ <description><![CDATA[%($summary%)]]</description>
+ </item>
+% }
+ </channel>
+!