Datenquelle für xCal & iCal ist nun calendar-summary.xml, enthält alle Events

git-svn-id: svn://svn.c3d2.de/c3d2-web/trunk@1046 31f61c52-7bfb-0310-b897-fc00f8a278f0
This commit is contained in:
astro 2007-11-18 13:22:53 +00:00
parent 55083164a7
commit 4ade65f772
3 changed files with 171 additions and 117 deletions

View File

@ -51,7 +51,7 @@ PAGES:=$(patsubst content/pages/%.xml, build/%.html, $(wildcard content/pages/*.
# Seiten zu einzelnen News-Items:
NEWS_PAGES:=$(patsubst content/news/%.xml, build/news/%.html, $(wildcard content/news/*.xml))
# News-Index und Feeds:
NEWSFILES:=build/news.html build/news-rss.xml build/news-atom.xml build/xcal.xml build/ical.ics build/podcast.xml
NEWSFILES:=build/news.html build/news-rss.xml build/news-atom.xml build/podcast.xml
# Datenspuren-Seiten:
DS_PAGES:=$(patsubst content/datenspuren/%.xml, build/datenspuren/%.html, $(wildcard content/datenspuren/*.xml)) build/datenspuren/schedule.html
# Suchseiten-Template
@ -88,10 +88,6 @@ build/news-rss.xml : VFLAGS_OUT=--noout --schema xsd/rss20.xsd
build/news-atom.xml : STYLE=xsl/atom.xsl
build/news-atom.xml : NOVALID_IGNORE:=true
build/news-atom.xml : VFLAGS_OUT=--noout --relaxng xsd/atom.rng
build/xcal.xml : STYLE=xsl/xcal.xsl
build/ical.ics : STYLE=xsl/ical.xsl
build/ical.ics : NOVALID_IGNORE:=true
build/ical.ics : VFLAGS_OUT=--noout
build/podcast.xml : STYLE=xsl/podcast.xsl
build/podcast.xml : NOVALID_IGNORE:=true
build/podcast.xml : VFLAGS_OUT=--noout --schema xsd/rss20.xsd
@ -115,6 +111,20 @@ build/calendar.html : VFLAGS_IN=--noout
build/calendar.html: $(CALENDAR_SUMMARY) $(STYLE) $(NAVIGATION) $(WWW_CCC_DE_UPDATES)
$(call xml_process)
# XCal
build/xcal.xml : STYLE=xsl/xcal.xsl
build/xcal.xml : VFLAGS_IN=--noout
build/xcal.xml: $(CALENDAR_SUMMARY) $(STYLE)
$(call xml_process)
# iCal
build/ical.ics : STYLE=xsl/ical.xsl
build/ical.ics : NOVALID_IGNORE:=true
build/ical.ics : VFLAGS_IN=--noout
build/ical.ics : VFLAGS_OUT=--noout
build/ical.ics: $(CALENDAR_SUMMARY) $(STYLE)
$(call xml_process)
# Pages:
build/%.html: content/pages/%.xml $(STYLE) $(NAVIGATION) $(WWW_CCC_DE_UPDATES) $(CALENDAR_SUMMARY) news.xml
$(call xml_process)

View File

@ -2,16 +2,20 @@
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:date="http://exslt.org/dates-and-times"
xmlns:crypto="http://exslt.org/crypto"
>
xmlns:crypto="http://exslt.org/crypto">
<xsl:output method="text" encoding="utf-8"/>
<xsl:include href="date.xsl"/>
<xsl:include href="common.xsl"/>
<xsl:variable name="baseurl">https://www.c3d2.de/</xsl:variable>
<xsl:template match="news"><xsl:text>BEGIN:VCALENDAR</xsl:text>
<xsl:template match="/page">
<xsl:apply-templates select="calendar-summary"/>
</xsl:template>
<xsl:template match="calendar-summary">
<xsl:text>BEGIN:VCALENDAR</xsl:text>
<xsl:text>&#13;&#10;</xsl:text>
<xsl:text>VERSION:2.0</xsl:text>
@ -32,16 +36,32 @@
<xsl:text>X-WR-CALNAME;VALUE=TEXT:C3D2-Events</xsl:text>
<xsl:text>&#13;&#10;</xsl:text>
<xsl:text>X-WR-TIMEZONE;VALUE=TEXT:Europe/Berlin</xsl:text>
<xsl:text>X-WR-TIMEZONE;VALUE=TEXT:Europe/Prague</xsl:text>
<xsl:text>&#13;&#10;</xsl:text>
<xsl:for-each select="event">
<xsl:sort select="date:seconds(@start)" data-type="number" order="descending" />
<xsl:text>&#13;&#10;</xsl:text>
<xsl:text>BEGIN:VEVENT</xsl:text>
<xsl:text>&#13;&#10;</xsl:text>
<xsl:text>METHOD:PUBLISH</xsl:text>
<xsl:text>&#13;&#10;</xsl:text>
<xsl:call-template name="uid"/>
<xsl:apply-templates select="start"/>
<xsl:apply-templates select="end"/>
<xsl:apply-templates select="title"/>
<xsl:text>CLASS:PUBLIC</xsl:text>
<xsl:text>&#13;&#10;</xsl:text>
<xsl:call-template name="category"/>
<xsl:apply-templates select="link"/>
<xsl:apply-templates select="location"/>
<xsl:text>END:VEVENT</xsl:text>
<xsl:text>&#13;&#10;</xsl:text>
<xsl:for-each select="newsfile">
<xsl:sort select="date:seconds(document(.)/item/@date)" data-type="number" order="descending" />
<xsl:if test="document(.)/item/event">
<xsl:apply-templates select="document(.)/item">
<xsl:with-param name="newsfile" select="."/>
</xsl:apply-templates>
</xsl:if>
</xsl:for-each>
<xsl:text>&#13;&#10;</xsl:text>
@ -49,76 +69,73 @@
<xsl:text>&#13;&#10;</xsl:text>
</xsl:template>
<xsl:template match="item">
<xsl:param name="newsfile"/>
<xsl:text>BEGIN:VEVENT</xsl:text>
<xsl:text>&#13;&#10;</xsl:text>
<xsl:text>METHOD:PUBLISH</xsl:text>
<xsl:text>&#13;&#10;</xsl:text>
<xsl:text>UID:</xsl:text><xsl:value-of select="crypto:sha1(concat(@title,@date))"/><xsl:text>@www.c3d2.de</xsl:text>
<xsl:text>&#13;&#10;</xsl:text>
<xsl:text>DTSTAMP:</xsl:text>
<xsl:call-template name="date-to-hevent">
<xsl:with-param name="date" select="@date"/>
</xsl:call-template>
<xsl:template name="uid">
<xsl:text>UID:</xsl:text><xsl:value-of select="crypto:sha1(concat(title,start))"/><xsl:text>@www.c3d2.de</xsl:text>
<xsl:text>&#13;&#10;</xsl:text>
</xsl:template>
<xsl:template match="start">
<xsl:text>DTSTART:</xsl:text>
<xsl:call-template name="date-to-hevent">
<xsl:with-param name="date" select="event/start"/>
<xsl:with-param name="date" select="string(.)"/>
</xsl:call-template>
<xsl:text>&#13;&#10;</xsl:text>
</xsl:template>
<xsl:if test="event/end">
<xsl:template match="end">
<xsl:if test="not(string(.) = string(../start))">
<xsl:text>DTEND:</xsl:text>
<xsl:call-template name="date-to-hevent">
<xsl:with-param name="date" select="event/end"/>
<xsl:with-param name="date" select="string(.)"/>
</xsl:call-template>
<xsl:text>&#13;&#10;</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template match="title">
<xsl:call-template name="wrap-text">
<xsl:with-param name="text">SUMMARY:<xsl:value-of select="@title"/></xsl:with-param>
<xsl:with-param name="text">SUMMARY:<xsl:value-of select="."/></xsl:with-param>
<xsl:with-param name="length" select="70"/>
</xsl:call-template>
<xsl:text>&#13;&#10;</xsl:text>
</xsl:template>
<xsl:text>CLASS:PUBLIC</xsl:text>
<xsl:text>&#13;&#10;</xsl:text>
<xsl:template name="category">
<xsl:text>CATEGORY:</xsl:text>
<xsl:choose>
<xsl:when test="starts-with($newsfile, 'content/news/ta-')">
<item>Themenabend</item>
<xsl:when test="starts-with(link, 'news/ta-')">
<xsl:text>Themenabend</xsl:text>
</xsl:when>
<xsl:when test="starts-with($newsfile, 'content/news/event-')">
<item>Event</item>
<xsl:when test="starts-with(link, 'news/event-')">
<xsl:text>Event</xsl:text>
</xsl:when>
<xsl:when test="starts-with(link, 'news/pentaradio')">
<xsl:text>Radio</xsl:text>
</xsl:when>
<xsl:when test="link = 'radio.html'">
<xsl:text>Radio</xsl:text>
</xsl:when>
<xsl:otherwise>
<item>Misc</item>
<xsl:text>Misc</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text>&#13;&#10;</xsl:text>
</xsl:template>
<xsl:template match="link">
<xsl:text>URL:</xsl:text>
<xsl:value-of select="$baseurl"/>
<xsl:value-of select="substring-after(substring-before($newsfile, '.xml'), 'content/')"/>
<xsl:text>.html</xsl:text>
<xsl:call-template name="make-href">
<xsl:with-param name="href" select="string(.)"/>
</xsl:call-template>
<xsl:text>&#13;&#10;</xsl:text>
</xsl:template>
<xsl:template match="location">
<xsl:call-template name="wrap-text">
<xsl:with-param name="text">LOCATION:<xsl:value-of select="event/location"/></xsl:with-param>
<xsl:with-param name="text">LOCATION:<xsl:value-of select="string(.)"/></xsl:with-param>
<xsl:with-param name="length" select="70"/>
</xsl:call-template>
<xsl:text>&#13;&#10;</xsl:text>
<xsl:text>END:VEVENT</xsl:text>
<xsl:text>&#13;&#10;</xsl:text>
</xsl:template>
<!-- Copy left by Tim Pritlove -->

View File

@ -1,4 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
See: http://tools.ietf.org/html/draft-royer-calsch-xcal-03
-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:date="http://exslt.org/dates-and-times"
@ -12,76 +17,98 @@
doctype-system="DTD/xcal.dtd"
indent="yes"/>
<xsl:include href="date.xsl"/>
<xsl:include href="common.xsl"/>
<xsl:variable name="baseurl">https://www.c3d2.de/</xsl:variable>
<xsl:template match="/page">
<!--xsl:template match="/page">
<xsl:apply-templates/>
</xsl:template>
</xsl:template-->
<xsl:template match="news">
<iCalendar>
<xsl:template match="calendar-summary">
<!-- xCal namespace specified in standard but nowhere used
except for inclusion in other XML documents
-->
<iCalendar xmlns:xCal="urn:ietf:params:xml:ns:xcal">
<vcalendar method="PUBLISH" version="2.0" prodid="-//C3D2-Web//event iCal-Export//DE">
<xsl:for-each select="newsfile">
<xsl:sort select="date:seconds(document(.)/item/@date)" data-type="number" order="descending" />
<xsl:if test="document(.)/item/event">
<xsl:apply-templates select="document(.)/item">
<xsl:with-param name="newsfile" select="."/>
</xsl:apply-templates>
</xsl:if>
<xsl:for-each select="event">
<xsl:sort select="date:seconds(start)" data-type="number" order="descending" />
<vevent>
<xsl:call-template name="uid"/>
<xsl:apply-templates select="start"/>
<xsl:apply-templates select="end"/>
<xsl:apply-templates select="title"/>
<xsl:apply-templates select="link"/>
<xsl:apply-templates select="location"/>
<xsl:call-template name="categories"/>
</vevent>
</xsl:for-each>
</vcalendar>
</iCalendar>
</xsl:template>
<xsl:template match="item">
<xsl:param name="newsfile"/>
<vevent>
<uid><xsl:value-of select="crypto:sha1(concat(@title,@date))"/>@www.c3d2.de</uid>
<dtstamp>
<xsl:call-template name="date-to-hevent">
<xsl:with-param name="date" select="@date"/>
</xsl:call-template>
</dtstamp>
<xsl:template name="uid">
<uid><xsl:value-of select="crypto:sha1(concat(title,start))"/>@www.c3d2.de</uid>
</xsl:template>
<xsl:template match="start">
<dtstart>
<xsl:call-template name="date-to-hevent">
<xsl:with-param name="date" select="event/start"/>
<xsl:with-param name="date" select="string(.)"/>
</xsl:call-template>
</dtstart>
</xsl:template>
<xsl:if test="event/end">
<xsl:template match="end">
<!-- Hack? -->
<xsl:if test="not(string(.) = string(../start))">
<dtend>
<xsl:call-template name="date-to-hevent">
<xsl:with-param name="date" select="event/end"/>
<xsl:with-param name="date" select="string(.)"/>
</xsl:call-template>
</dtend>
</xsl:if>
</xsl:template>
<summary><xsl:value-of select="@title"/></summary>
<xsl:template match="title">
<summary><xsl:value-of select="."/></summary>
</xsl:template>
<location><xsl:value-of select="event/location"/></location>
<xsl:template match="link">
<url>
<xsl:call-template name="make-href">
<xsl:with-param name="href" select="string(.)"/>
</xsl:call-template>
</url>
</xsl:template>
<xsl:template match="location">
<location><xsl:value-of select="."/></location>
</xsl:template>
<xsl:template name="categories">
<categories>
<xsl:choose>
<xsl:when test="starts-with($newsfile, 'content/news/ta-')">
<xsl:when test="starts-with(link, 'news/ta-')">
<item>Themenabend</item>
</xsl:when>
<xsl:when test="starts-with($newsfile, 'content/news/event-')">
<xsl:when test="starts-with(link, 'news/event-')">
<item>Event</item>
</xsl:when>
<xsl:when test="starts-with(link, 'news/pentaradio')">
<item>Radio</item>
</xsl:when>
<xsl:when test="string(link) = 'radio.html'">
<item>Radio</item>
</xsl:when>
<xsl:otherwise>
<item>Misc</item>
</xsl:otherwise>
</xsl:choose>
</categories>
</vevent>
</xsl:template>
</xsl:stylesheet>