Re: Events in iCalendar format
--Z5Iw6G/4V9lVaptU
Content-Type: multipart/mixed; boundary="p19/OaUkOQckSefz"
Content-Disposition: inline
--p19/OaUkOQckSefz
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Wed, Aug 17, 2005 at 07:42:20PM +0900, Hiroki Sato wrote:
> Ceri Davies <ceri@submonkey.net> wrote
> in <20050817094746.GR55885@submonkey.net>:
>=20
> ce> On Wed, Aug 17, 2005 at 07:01:43AM +0900, Hiroki Sato wrote:
> ce> > Hmm, could you please put the XSLT stylesheet into the language-in=
dependent
> ce> > directory?
> ce>
> ce> Along this line, I don't see why we have a copy of events.dtd in every
> ce> language-dependent directory.
>=20
> Yes, it is pointless, too. I am planning to clean up this sort of
> duplicate files when I import doc.xml.mk. So when you add a new
> language-independent file, putting it into the LI directory
> from the beginning would be nice.
OK, here's the new diff.
Ceri
--=20
Only two things are infinite, the universe and human stupidity, and I'm
not sure about the former. -- Einstein (attrib.)
--p19/OaUkOQckSefz
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="events.ical.diff"
Content-Transfer-Encoding: quoted-printable
Index: share/sgml/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: share/sgml/events2ics.xsl
diff -N share/sgml/events2ics.xsl
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ share/sgml/events2ics.xsl 17 Aug 2005 11:23:06 -0000
@@ -0,0 +1,115 @@
+<?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$
+-->
+
+<!-- Generate an iCalendar file from a www/en/events/events.dtd
+ compliant events.xml -->
+
+<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 iCalendar 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>
Index: en/events/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
--- en/events/Makefile 6 Apr 2004 11:36:12 -0000 1.7
+++ en/events/Makefile 17 Aug 2005 11:23:06 -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} \
+ ${WEB_PREFIX}/share/sgml/events2ics.xsl ${.CURDIR}/events.xml
+
lint:
${XMLLINT} --valid -o /dev/null ${.CURDIR}/events.xml
=20
--p19/OaUkOQckSefz--
--Z5Iw6G/4V9lVaptU
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (FreeBSD)
iD8DBQFDAx49ocfcwTS3JF8RAqbjAKCRgtPKAf3taoIw7QekzJS99h9X9wCgwj8U
oHPAGEnyGz09tw2L8BV2Fb4=
=qGwq
-----END PGP SIGNATURE-----
--Z5Iw6G/4V9lVaptU--
討論串 (同標題文章)
完整討論串 (本文為第 11 之 13 篇):