Added atom feed generation.
authorDavid Tenty <daltenty@csclub.uwaterloo.ca>
Sat, 22 Sep 2007 01:02:46 +0000 (21:02 -0400)
committerDavid Tenty <daltenty@csclub.uwaterloo.ca>
Sat, 22 Sep 2007 01:02:46 +0000 (21:02 -0400)
Makefile
events.xml
xsl/atom.xsl [new file with mode: 0644]

index 08e9b1e..4baecd3 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 INPUTS = index.xml
 SUBDIRS = about events office news services media
 
-first: noroot events.ics members.xml all
+first: noroot events.ics members.xml events.atom news.atom all
        find ! -regex '.*/\..*' -type f ! -perm -0664 -print0 | xargs -r0 chmod u=rwX,g=rwX,o=rX || true
        find ! -regex '.*/\..*' -type d ! -perm 2775 -print0 | xargs -r0 chmod 2775 || true
        find ! -regex '.*/\..*' -type d ! -group www -print0 | xargs -r0 chgrp www || true
@@ -20,6 +20,10 @@ events.ics:
 
 include default.mk
 
+%.atom: %.xml
+       java -classpath $(CLASSPATH) net.sf.saxon.Transform -o $@  $< $(ROOT)/xsl/atom.xsl $(XSLTARGS)
+       sed -i 's| xmlns=""||' $@
+
 default.mk: default.mk.in
        echo 'ROOT = '`pwd` > $@
        cat $< >> $@
index 6dbbeae..6c62103 100644 (file)
@@ -1,3 +1,4 @@
+<?xml version='1.0'?>
 <eventdefs>
 
 
diff --git a/xsl/atom.xsl b/xsl/atom.xsl
new file mode 100644 (file)
index 0000000..a1b00a0
--- /dev/null
@@ -0,0 +1,66 @@
+<?xml version='1.0'?>
+
+<xsl:stylesheet version="2.0"
+    xmlns="http://www.w3.org/1999/xhtml"
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    xmlns:xs="http://www.w3.org/2001/XMLSchema"
+    xmlns:fn="http://www.w3.org/2005/xpath-functions"
+    xmlns:csc="http://csclub.uwaterloo.ca/xslt">
+
+<xsl:param name="g_date" required="yes" />
+<xsl:param name="g_time" required="yes" />
+<xsl:param name="g_pwd" required="yes" />
+<xsl:param name="g_root" required="yes" />
+
+<xsl:template match="//eventdefs">
+<xsl:call-template name="atom">
+<xsl:with-param name="title">Events</xsl:with-param>
+<xsl:with-param name="uuid">006f667f-ecae-483a-8cbc-f0c5084dccb1</xsl:with-param>  
+</xsl:call-template>
+</xsl:template>
+
+<xsl:template match="//newsdefs">
+<xsl:call-template name="atom">
+<xsl:with-param name="title">News</xsl:with-param>
+<xsl:with-param name="uuid">bdae3752-0cb7-4932-b176-019076389b54</xsl:with-param>  
+</xsl:call-template>
+</xsl:template>
+
+<xsl:template name="atom">
+<xsl:param name="title"/>
+<xsl:param name="uuid"/>
+<xsl:result-document method="xml" encoding="UTF-8" 
+      href="{concat($g_root, '/', $title, '.atom')}">
+</xsl:result-document>
+       <feed xmlns="http://www.w3.org/2005/Atom">
+       <title>UW Computer Science Club <xsl:value-of select="$title"/></title>
+       <link href="http://csclub.uwaterloo.ca/{$title}.atom" rel="self"/>
+       <link href="http://csclub.uwaterloo.ca/"/>
+       <updated><xsl:value-of select="$g_date"/></updated>
+       <id>
+       urn:uuid:<xsl:value-of select="$uuid"/>
+       </id>
+       <author>
+       <name>University of Waterloo Computer Science Club</name>
+       </author>
+       <xsl:apply-templates select="newsitem" />
+       <xsl:apply-templates select="eventitem" />
+       </feed>
+</xsl:template>
+
+<xsl:template match="//eventitem">
+       <entry>
+       <title><xsl:value-of select="//short"/></title>
+       <link href="http://csclub.uwaterloo.ca"/>
+       <summary><xsl:value-of select="//abstract"/></summary>
+       </entry>
+</xsl:template>
+
+<xsl:template match="//newsitem">
+       <entry>
+       <link href="http://csclub.uwaterloo.ca"/>
+       <summary><xsl:value-of select="//newsitem"/></summary>
+       </entry>
+</xsl:template>
+
+</xsl:stylesheet>