--H6o9R95t2FPeZmf3
Content-Type: multipart/mixed; boundary="2+N3zU4ZlskbnZaJ"
Content-Disposition: inline
--2+N3zU4ZlskbnZaJ
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
I made the attached patch so that we generate an events.ics that people
can subscribe to. It's based on a quick run through of RFC 2445 and may
not be immensely robust, but Mozilla Sunbird, Microsoft Entourage and
Apple's iCal all seem to dig it.
Comments?
Ceri
--=20
Only two things are infinite, the universe and human stupidity, and I'm
not sure about the former. -- Einstein (attrib.)
--2+N3zU4ZlskbnZaJ
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="events.ical.diff"
Content-Transfer-Encoding: quoted-printable
Index: Makefile
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /home/dcvs/www/en/events/Makefile,v
retrieving revision 1.7
diff -u -r1.7 Makefile
--- Makefile 6 Apr 2004 11:36:12 -0000 1.7
+++ Makefile 16 Aug 2005 21:31:45 -0000
@@ -12,8 +12,10 @@
=20
DATA=3D events.css
DATA+=3D events.html
+DATA+=3D events.ics
=20
CLEANFILES+=3D events.html
+CLEANFILES+=3D events.ics
CLEANFILES+=3D curdate.xml
=20
INDEXLINK=3D events.html
@@ -29,6 +31,10 @@
-${TIDY} ${TIDYOPTS} ${.TARGET}
.endif
=20
+events.ics: events.xml
+ ${XSLTPROC} ${XSLTPROCOPTS} -o ${.TARGET} \
+ ${.CURDIR}/events2ics.xsl ${.CURDIR}/events.xml
+
lint:
${XMLLINT} --valid -o /dev/null ${.CURDIR}/events.xml
=20
Index: events2ics.xsl
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: events2ics.xsl
diff -N events2ics.xsl
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ events2ics.xsl 16 Aug 2005 21:31:45 -0000
@@ -0,0 +1,112 @@
+<?xml version=3D"1.0" encoding=3D"ISO-8859-1" ?>
+
+<!-- Copyright (c) 2005 Ceri Davies <ceri@FreeBSD.org>
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PU=
RPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIAB=
LE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUE=
NTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOO=
DS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, S=
TRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY=
WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+
+ $FreeBSD$
+-->
+
+<xsl:stylesheet xmlns:xsl=3D"http://www.w3.org/1999/XSL/Transform" version=
=3D"1.0"
+ xmlns:cvs=3D"http://www.FreeBSD.org/XML/CVS"
+ exclude-result-prefixes=3D"cvs">
+
+ <xsl:variable name=3D"freebsd-web-base" select=3D"'http://www.FreeBSD.or=
g'"/>
+
+ <xsl:output method=3D"text" encoding=3D"iso-8859-1"/>
+ <xsl:strip-space elements=3D"*"/>
+
+ <!-- Template: events -->
+ <xsl:template match=3D"events">BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:$FreeBSD$
+ <xsl:apply-templates select=3D"event"/>
+END:VCALENDAR</xsl:template>
+
+ <!-- Template: event -->
+ <xsl:template match=3D"event">
+BEGIN:VEVENT
+SEQUENCE:<xsl:value-of select=3D"position()" />
+SUMMARY:<xsl:value-of select=3D"name"/>
+ <xsl:if test=3D"url">
+ <xsl:apply-templates select=3D"url"/>
+ </xsl:if>
+LOCATION:<xsl:if test=3D"location/site!=3D''">
+ <xsl:value-of select=3D"location/site"/>
+ </xsl:if>
+ <xsl:if test=3D"location/city!=3D''">
+ <xsl:text>, </xsl:text>
+ <xsl:value-of select=3D"location/city"/>
+ </xsl:if>
+ <xsl:if test=3D"location/state!=3D''">
+ <xsl:text>, </xsl:text>
+ <xsl:value-of select=3D"location/state"/>
+ </xsl:if>
+ <xsl:if test=3D"location/country!=3D''">
+ <xsl:text>, </xsl:text>
+ <xsl:value-of select=3D"location/country"/>
+ </xsl:if>
+ <xsl:call-template name=3D"gen-ical-date-interval">
+ <xsl:with-param name=3D"startdate" select=3D"startdate" />
+ <xsl:with-param name=3D"enddate" select=3D"enddate" />
+ </xsl:call-template>
+DESCRIPTION:<xsl:copy-of select=3D"description/child::node()"/>
+ <xsl:if test=3D"link">
+ <xsl:apply-templates select=3D"link"/>
+ </xsl:if>
+END:VEVENT</xsl:template>
+
+ <!-- Template: link -->
+ <xsl:template match=3D"link">
+ <xsl:apply-templates select=3D"url"/>
+ </xsl:template>
+
+ <!-- Template: url -->
+ <xsl:template match=3D"url">
+URL;VALUE=3DURI:<xsl:choose>
+ <xsl:when test=3D"@type=3D'freebsd-website'">
+ <xsl:value-of select=3D"$freebsd-web-base"/>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:value-of select=3D"."/>
+ </xsl:template>
+
+ <!-- Generate iCal DTSTART and DTEND entries -->
+ <xsl:template name=3D"gen-ical-date-interval">
+ <xsl:param name=3D"startdate"/>
+ <xsl:param name=3D"enddate"/>
+
+DTSTART;VALUE=3DDATE:<xsl:value-of select=3D"concat(startdate/year,
+ format-number(startdate/month, '00'),
+ format-number(startdate/day, '00'))"/>
+
+ <xsl:if test=3D"number(startdate/month) !=3D number(enddate/month) or
+ number(startdate/day) !=3D number(enddate/day) or
+ number(startdate/year) !=3D number(enddate/year)">
+DTEND;VALUE=3DDATE:<xsl:value-of select=3D"concat(enddate/year,
+ format-number(enddate/month, '00'),
+ format-number(enddate/day, '00'))"/>
+
+ </xsl:if>
+ </xsl:template>
+</xsl:stylesheet>
--2+N3zU4ZlskbnZaJ--
--H6o9R95t2FPeZmf3
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (FreeBSD)
iD8DBQFDAlvyocfcwTS3JF8RAjAdAKCwJ3ignloAKIe5DP1zkIyDQbvevACgnoDg
tkSwqlyf+b2AiC9Zsw4xbk0=
=Ab2A
-----END PGP SIGNATURE-----
--H6o9R95t2FPeZmf3--