283 lines
9.5 KiB
XML
283 lines
9.5 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<xsl:stylesheet version="1.0"
|
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
|
xmlns:date="http://exslt.org/dates-and-times"
|
|
exclude-result-prefixes="xsl date">
|
|
|
|
<xsl:output method="xml"
|
|
version="1.0"
|
|
encoding="utf-8"
|
|
doctype-system="http://www.c3d2.de/dtd/c3d2web.dtd"
|
|
indent="yes"/>
|
|
|
|
<xsl:include href="include/ddate.xsl" />
|
|
|
|
<xsl:template match="/calendar">
|
|
<page id="kalender" title="Kalender">
|
|
<calendar-summary>
|
|
<!-- Events aus events.xml ziehen -->
|
|
<xsl:apply-templates select="event"/>
|
|
|
|
<!-- Events aus den News ziehen -->
|
|
<xsl:for-each select="document('news.xml')/page/news/newsfile">
|
|
<xsl:apply-templates select="document(concat('../', .))/item/event">
|
|
<xsl:with-param name="link" select="concat(substring-before(substring-after(., 'content/'), '.xml'), '.html')"/>
|
|
</xsl:apply-templates>
|
|
</xsl:for-each>
|
|
</calendar-summary>
|
|
</page>
|
|
</xsl:template>
|
|
|
|
<xsl:template match="event">
|
|
<xsl:param name="link"/>
|
|
|
|
<!-- Events must have started at least one year ago -->
|
|
<xsl:variable name="minstart" select="date:add(date:date-time(), '-P366D')"/>
|
|
<xsl:if test="starts-with(date:difference(start, $minstart), '-')">
|
|
<event>
|
|
<title>
|
|
<xsl:choose>
|
|
<xsl:when test="@title"><xsl:value-of select="@title"/></xsl:when>
|
|
<xsl:when test="../@title"><xsl:value-of select="../@title"/></xsl:when>
|
|
<xsl:otherwise>
|
|
<xsl:message terminate="yes">Event with no title!</xsl:message>
|
|
</xsl:otherwise>
|
|
</xsl:choose>
|
|
</title>
|
|
<start><xsl:value-of select="start"/></start>
|
|
<end>
|
|
<xsl:choose>
|
|
<xsl:when test="end">
|
|
<xsl:value-of select="end"/>
|
|
</xsl:when>
|
|
<xsl:otherwise>
|
|
<xsl:value-of select="start"/>
|
|
</xsl:otherwise>
|
|
</xsl:choose>
|
|
</end>
|
|
<xsl:if test="location">
|
|
<location><xsl:value-of select="location"/></location>
|
|
</xsl:if>
|
|
<link>
|
|
<xsl:choose>
|
|
<xsl:when test="link"><xsl:value-of select="link"/></xsl:when>
|
|
<xsl:otherwise><xsl:value-of select="$link"/></xsl:otherwise>
|
|
</xsl:choose>
|
|
</link>
|
|
<!-- TODO: Link -->
|
|
</event>
|
|
</xsl:if>
|
|
</xsl:template>
|
|
|
|
<xsl:template match="/page/calendar-summary">
|
|
<table class="calendar">
|
|
<tr>
|
|
<th>Montag</th>
|
|
<th>Dienstag</th>
|
|
<th>Mittwoch</th>
|
|
<th>Donnerstag</th>
|
|
<th>Freitag</th>
|
|
<th>Samstag</th>
|
|
<th>Sonntag</th>
|
|
</tr>
|
|
|
|
<xsl:call-template name="output-week">
|
|
<xsl:with-param name="date">
|
|
<xsl:call-template name="get-past-monday">
|
|
<xsl:with-param name="date" select="concat(date:year(date:date()), '-', format-number(date:month-in-year(date:date()), '00'), '-01')"/>
|
|
</xsl:call-template>
|
|
</xsl:with-param>
|
|
<xsl:with-param name="stopmonth" select="date:month-in-year(date:add(date:date(), 'P2M'))"/>
|
|
</xsl:call-template>
|
|
|
|
</table>
|
|
|
|
<p>
|
|
Der Kalender ist auch im <a href="ical.ics">iCal-</a>,
|
|
<a href="xcal.xml">XCal-</a> und <a
|
|
href="reminders">remind-Format</a> verfügbar.
|
|
</p>
|
|
</xsl:template>
|
|
|
|
<xsl:template name="output-week">
|
|
<xsl:param name="date"/>
|
|
<xsl:param name="stopmonth"/>
|
|
<tr>
|
|
<xsl:call-template name="output-day">
|
|
<xsl:with-param name="date" select="$date"/>
|
|
</xsl:call-template>
|
|
</tr>
|
|
|
|
<xsl:variable name="nextweek" select="date:add($date, 'P7D')"/>
|
|
<xsl:if test="date:month-in-year($nextweek) != $stopmonth">
|
|
<xsl:call-template name="output-week">
|
|
<xsl:with-param name="date" select="$nextweek"/>
|
|
<xsl:with-param name="stopmonth" select="$stopmonth"/>
|
|
</xsl:call-template>
|
|
</xsl:if>
|
|
</xsl:template>
|
|
|
|
<!--
|
|
td/@class ist wie folgend aufgebaut:
|
|
* Beginnt immer mit 'cal'
|
|
* Dann 'week' für Wochentage, 'sun' für Sonntage
|
|
* '1' für aktuellen Monat, '2' für folgenden Monat, '3' für sonstige Monate
|
|
-->
|
|
<xsl:template name="output-day">
|
|
<xsl:param name="date"/>
|
|
<td>
|
|
<xsl:attribute name="class">
|
|
<xsl:text>cal</xsl:text>
|
|
<xsl:choose>
|
|
<xsl:when test="date:day-in-week($date) = 1">sun</xsl:when>
|
|
<xsl:otherwise>week</xsl:otherwise>
|
|
</xsl:choose>
|
|
<xsl:choose>
|
|
<xsl:when test="date:month-in-year($date) = date:month-in-year(date:date())">1</xsl:when>
|
|
<xsl:when test="date:month-in-year($date) = date:month-in-year(date:add(date:date(), 'P1M'))">2</xsl:when>
|
|
<xsl:otherwise>3</xsl:otherwise>
|
|
</xsl:choose>
|
|
</xsl:attribute>
|
|
<!-- vv01f: added id to jump to a specific date with links and hashtag liek {$month}-{$day} //-->
|
|
<xsl:attribute name="id">
|
|
<xsl:value-of select="concat('eventday-', date:month-in-year($date), '-', date:day-in-month($date))"/>
|
|
</xsl:attribute>
|
|
|
|
<xsl:variable name="ddate">
|
|
<xsl:call-template name="ddate">
|
|
<xsl:with-param name="date" select="$date"/>
|
|
</xsl:call-template>
|
|
</xsl:variable>
|
|
<span class="day" title="{$ddate}"
|
|
id="calendar-{date:year($date)}-{date:month-in-year($date)}-{date:day-in-month($date)}"
|
|
>
|
|
<xsl:value-of select="date:day-in-month($date)"/>
|
|
</span>
|
|
|
|
<ul>
|
|
<xsl:variable name="dholiday">
|
|
<xsl:call-template name="ddate-holiday">
|
|
<xsl:with-param name="date" select="$date"/>
|
|
</xsl:call-template>
|
|
</xsl:variable>
|
|
<li><xsl:value-of select="normalize-space($dholiday)"/></li>
|
|
|
|
<xsl:for-each select="event">
|
|
<xsl:sort select="start"/>
|
|
|
|
<xsl:variable name="start">
|
|
<xsl:call-template name="strip-time-from-date">
|
|
<xsl:with-param name="date" select="start"/>
|
|
</xsl:call-template>
|
|
</xsl:variable>
|
|
<xsl:variable name="end">
|
|
<xsl:call-template name="strip-time-from-date">
|
|
<xsl:with-param name="date" select="end"/>
|
|
</xsl:call-template>
|
|
</xsl:variable>
|
|
<xsl:variable name="date">
|
|
<xsl:call-template name="strip-time-from-date">
|
|
<xsl:with-param name="date" select="$date"/>
|
|
</xsl:call-template>
|
|
</xsl:variable>
|
|
|
|
<xsl:if test="(date:seconds($start) <= date:seconds($date))
|
|
and (date:seconds($date) <= date:seconds($end))">
|
|
<li>
|
|
<a>
|
|
<!-- a/@href -->
|
|
<xsl:if test="string-length(link) > 0">
|
|
<xsl:attribute name="href">
|
|
<xsl:value-of select="link" />
|
|
</xsl:attribute>
|
|
</xsl:if>
|
|
<!-- a/@title -->
|
|
<xsl:attribute name="title">
|
|
<xsl:if test="string-length(location) > 0">
|
|
<xsl:value-of select="concat('Ort: ', location)"/>
|
|
</xsl:if>
|
|
<xsl:if test="string-length(location) = 0">
|
|
<xsl:value-of select="concat('Ort: ', 'GCHQ, Lingnerallee 3, 01069 Dresden')"/>
|
|
</xsl:if>
|
|
<xsl:if test="string-length(date:time(start)) > 0 or string-length(date:time(end)) > 0">
|
|
<xsl:if test="date:day-in-month($date) = date:day-in-month(start) or date:day-in-month($date) = date:day-in-month(end)">
|
|
<xsl:value-of select="concat('
', 'Zeit:')" disable-output-escaping="yes"/>
|
|
<xsl:if test="date:day-in-month($date) = date:day-in-month(start) and string-length(date:time(start)) > 0 and substring(date:time(start),1,5) != ''">
|
|
<xsl:value-of select="concat(' ab ', substring(date:time(start),1,5))"/>
|
|
</xsl:if>
|
|
<xsl:if test="date:day-in-month($date) = date:day-in-month(end) and string-length(date:time(end)) > 0 and substring(date:time(end),1,5) != '' and substring(date:time(end),1,5) != substring(date:time(start),1,5)">
|
|
<xsl:value-of select="concat(' bis ', substring(date:time(end),1,5))"/>
|
|
</xsl:if>
|
|
</xsl:if>
|
|
</xsl:if>
|
|
</xsl:attribute>
|
|
<!-- string(a) -->
|
|
<xsl:value-of select="title"/>
|
|
</a>
|
|
</li>
|
|
</xsl:if>
|
|
</xsl:for-each>
|
|
|
|
</ul>
|
|
</td>
|
|
<xsl:if test="date:day-in-week($date) != 1"> <!-- Sunday? Break and return to output-week... -->
|
|
<xsl:call-template name="output-day">
|
|
<xsl:with-param name="date" select="date:add($date, 'P1D')"/>
|
|
</xsl:call-template>
|
|
</xsl:if>
|
|
</xsl:template>
|
|
|
|
<xsl:template name="calendar-title">
|
|
<xsl:variable name="d1" select="date:date()"/>
|
|
<xsl:variable name="d2" select="date:add(date:date(), 'P1M')"/>
|
|
|
|
<xsl:text>Kalender: </xsl:text>
|
|
|
|
<xsl:call-template name="get-monthstring">
|
|
<xsl:with-param name="date" select="$d1"/>
|
|
</xsl:call-template>
|
|
|
|
<xsl:if test="date:year($d1) != date:year($d2)">
|
|
<xsl:text> </xsl:text>
|
|
<xsl:value-of select="date:year($d1)"/>
|
|
</xsl:if>
|
|
|
|
<xsl:text> & </xsl:text>
|
|
|
|
<xsl:call-template name="get-monthstring">
|
|
<xsl:with-param name="date" select="$d2"/>
|
|
</xsl:call-template>
|
|
|
|
<xsl:text> </xsl:text>
|
|
|
|
<xsl:value-of select="date:year($d2)"/>
|
|
</xsl:template>
|
|
|
|
<xsl:template name="get-past-monday">
|
|
<xsl:param name="date"/>
|
|
<xsl:choose>
|
|
<xsl:when test="date:day-in-week($date) = 2">
|
|
<xsl:value-of select="$date"/>
|
|
</xsl:when>
|
|
<xsl:otherwise>
|
|
<xsl:call-template name="get-past-monday">
|
|
<xsl:with-param name="date" select="date:add($date, '-P1D')"/>
|
|
</xsl:call-template>
|
|
</xsl:otherwise>
|
|
</xsl:choose>
|
|
</xsl:template>
|
|
|
|
<!--
|
|
# Identity transformation for all elements
|
|
# not handled by the templates within this file.
|
|
# Taken from
|
|
# http://stackoverflow.com/questions/10454114/xslt-template-for-any-node-not-already-handled
|
|
-->
|
|
<xsl:template match="@* | node()">
|
|
<xsl:copy>
|
|
<xsl:apply-templates select="@* | node()"/>
|
|
</xsl:copy>
|
|
</xsl:template>
|
|
|
|
</xsl:stylesheet>
|