Browse Source

made the events fetching even more generic, now used in index, events/events, about/germany/germany

svn path=/branches/design/; revision=18951
tags/stw2018
nicoulas 9 years ago
parent
commit
709223803d
5 changed files with 180 additions and 176 deletions
  1. 11
    0
      about/germany/germany.xsl
  2. 16
    138
      events/events.xsl
  3. 8
    1
      index.xsl
  4. 85
    23
      tools/xsltsl/feeds.xsl
  5. 60
    14
      tools/xsltsl/tagging.xsl

+ 11
- 0
about/germany/germany.xsl View File

@@ -27,7 +27,18 @@
<!--define dynamic list of country event items-->
<xsl:template match="country-events">
<!-- Current events -->
<xsl:call-template name="fetch-events">
<xsl:with-param name="wanted-time" select="'present'" />
<xsl:with-param name="tag">
<xsl:value-of select="$country-code" />
</xsl:with-param>
</xsl:call-template>
<!-- Future events -->
<xsl:call-template name="fetch-events">
<xsl:with-param name="wanted-time" select="'future'" />
<xsl:with-param name="nb-events" select="3" />
<xsl:with-param name="tag">
<xsl:value-of select="$country-code" />
</xsl:with-param>

+ 16
- 138
events/events.xsl View File

@@ -4,7 +4,7 @@
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dt="http://xsltsl.org/date-time">

<xsl:import href="../tools/xsltsl/date-time.xsl" />
<xsl:import href="../tools/xsltsl/tagging.xsl" />
<xsl:output method="xml" encoding="UTF-8" indent="yes" />

<!-- Basically, copy everything -->
@@ -14,151 +14,29 @@
</xsl:copy>
</xsl:template>

<!-- Show a single event -->
<xsl:template name="event">
<xsl:param name="header" />

<!-- Create variables -->
<xsl:variable name="start">
<xsl:value-of select="@start" />
</xsl:variable>
<xsl:variable name="start_day">
<xsl:value-of select="substring($start,9,2)" />
</xsl:variable>
<xsl:variable name="start_month">
<xsl:call-template name="dt:get-month-abbreviation">
<xsl:with-param name="month" select="substring($start,6,2)" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="end">
<xsl:value-of select="@end" />
</xsl:variable>
<xsl:variable name="end_day">
<xsl:value-of select="substring($end,9,2)" />
</xsl:variable>
<xsl:variable name="end_month">
<xsl:call-template name="dt:get-month-abbreviation">
<xsl:with-param name="month" select="substring($end,6,2)" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="link">
<xsl:value-of select="link" />
</xsl:variable>
<xsl:variable name="page">
<xsl:value-of select="page" />
</xsl:variable>

<!-- Before the first event, include the header -->
<xsl:if test="position() = 1">
<h2><xsl:value-of select="/html/text [@id = $header]" /></h2>
</xsl:if>

<!-- Now, the event block -->
<div class="event">
<xsl:choose>
<xsl:when test="$link != ''">
<h3><a href="{link}"><xsl:value-of select="title" /></a></h3>
</xsl:when>
<xsl:when test="$page != ''">
<h3><a href="{page}"><xsl:value-of select="title" /></a></h3>
</xsl:when>
<xsl:otherwise>
<h3><xsl:value-of select="title" /></h3>
</xsl:otherwise>
</xsl:choose>

<xsl:choose>
<xsl:when test="$start != $end">
<p class="date multiple">
<span class="n">(</span>
<span class="from">
<span class="day"><xsl:value-of select="$start_day" /> </span>
<span class="month"><xsl:value-of select="$start_month" /></span>
</span>
<span class="conjunction">↓</span>
<span class="to">
<span class="day"><xsl:value-of select="$end_day" /> </span>
<span class="month"><xsl:value-of select="$end_month" /></span>
</span>
<span class="n">)</span>
</p>
</xsl:when>
<xsl:otherwise>
<p class="date">
<span class="n">(</span>
<span class="day"><xsl:value-of select="$start_day" /> </span>
<span class="month"><xsl:value-of select="$start_month" /> </span>
<span class="n">)</span>
</p>
</xsl:otherwise>
</xsl:choose>

<div class="details">
<xsl:apply-templates select="body/node()" />
<!--<div class="cleared">&#160;</div>-->
</div>

<!--
<xsl:if test="$link != ''">
<p class="read_more">
<a href="{link}"><xsl:value-of select="/html/text [@id = 'more']" /></a>
</p>
</xsl:if>

<xsl:if test="$page != ''">
<p class="read_more">
<a href="{page}"><xsl:value-of select="/html/text [@id = 'page']" /></a>
</p>
</xsl:if>
-->
</div>
</xsl:template>

<!-- In /html/body node, append dynamic content -->
<xsl:template match="/html/body">
<body>
<!-- First, include what's in the source file -->
<xsl:apply-templates />

<!-- $today = current date (given as <html date="...">) -->
<xsl:variable name="today">
<xsl:value-of select="/html/@date" />
</xsl:variable>

<!-- Current events -->
<xsl:for-each select="/html/set/event
[translate (@start, '-', '') &lt;= translate ($today, '-', '') and
translate (@end, '-', '') &gt;= translate ($today, '-', '')]">
<xsl:sort select="@start" order="descending" />
<xsl:call-template name="event">
<xsl:with-param name="header">current</xsl:with-param>
</xsl:call-template>
</xsl:for-each>

<xsl:call-template name="fetch-events">
<xsl:with-param name="wanted-time" select="'present'" />
<xsl:with-param name="header" select="'current'" />
</xsl:call-template>
<!-- Future events -->
<xsl:for-each select="/html/set/event
[translate (@start, '-', '') &gt; translate ($today, '-', '')]">
<xsl:sort select="@start" />
<xsl:call-template name="event">
<xsl:with-param name="header">future</xsl:with-param>
</xsl:call-template>
</xsl:for-each>

<xsl:call-template name="fetch-events">
<xsl:with-param name="wanted-time" select="'future'" />
<xsl:with-param name="header" select="'future'" />
</xsl:call-template>
<!-- Past events -->
<xsl:for-each select="/html/set/event
[translate (@end, '-', '') &lt; translate ($today, '-', '')]">
<xsl:sort select="@end" order="descending" />
<xsl:call-template name="event">
<xsl:with-param name="header">past</xsl:with-param>
</xsl:call-template>
</xsl:for-each>
<xsl:call-template name="fetch-events">
<xsl:with-param name="wanted-time" select="'past'" />
<xsl:with-param name="header" select="'past'" />
</xsl:call-template>

</body>
</xsl:template>

+ 8
- 1
index.xsl View File

@@ -28,8 +28,15 @@
<!--display dynamic list of event items-->
<xsl:template match="all-events">
<!-- Current events -->
<xsl:call-template name="fetch-events">
<xsl:with-param name="tag"></xsl:with-param>
<xsl:with-param name="wanted-time" select="'present'" />
</xsl:call-template>
<!-- Future events -->
<xsl:call-template name="fetch-events">
<xsl:with-param name="wanted-time" select="'future'" />
<xsl:with-param name="nb-events" select="3" />
</xsl:call-template>
</xsl:template>

+ 85
- 23
tools/xsltsl/feeds.xsl View File

@@ -34,14 +34,23 @@
</div>
</xsl:template>
<!-- Show a single newsletter item -->
<!-- Show a single newsletter item -->
<xsl:template name="newsletter">
<xsl:variable name="link"><xsl:value-of select="link" /></xsl:variable>
<li><a href="{link}"><xsl:value-of select="title" /></a></li>
<xsl:variable name="link">
<xsl:value-of select="link" />
</xsl:variable>
<li>
<a href="{link}">
<xsl:value-of select="title" />
</a>
</li>
</xsl:template>
<!-- Show a single event -->
<xsl:template name="event">
<xsl:param name="header"
select="''" />
<!-- Create variables -->
<xsl:variable name="start">
<xsl:value-of select="@start" />
@@ -50,7 +59,7 @@
<xsl:value-of select="substring($start,9,2)" />
</xsl:variable>
<xsl:variable name="start_month">
<xsl:call-template name="dt:get-month-name">
<xsl:call-template name="dt:get-month-abbreviation">
<xsl:with-param name="month"
select="substring($start,6,2)" />
</xsl:call-template>
@@ -62,7 +71,7 @@
<xsl:value-of select="substring($end,9,2)" />
</xsl:variable>
<xsl:variable name="end_month">
<xsl:call-template name="dt:get-month-name">
<xsl:call-template name="dt:get-month-abbreviation">
<xsl:with-param name="month"
select="substring($end,6,2)" />
</xsl:call-template>
@@ -70,7 +79,19 @@
<xsl:variable name="link">
<xsl:value-of select="link" />
</xsl:variable>
<div class="entry">
<xsl:variable name="page">
<xsl:value-of select="page" />
</xsl:variable>
<!-- Before the first event, include the header -->
<xsl:if test="position() = 1 and $header != ''">
<h2>
<xsl:value-of select="/html/text [@id = $header]" />
</h2>
</xsl:if>
<!-- Now, the event block -->
<div class="event">
<xsl:choose>
<xsl:when test="$link != ''">
<h3>
@@ -79,6 +100,13 @@
</a>
</h3>
</xsl:when>
<xsl:when test="$page != ''">
<h3>
<a href="{page}">
<xsl:value-of select="title" />
</a>
</h3>
</xsl:when>
<xsl:otherwise>
<h3>
<xsl:value-of select="title" />
@@ -87,44 +115,78 @@
</xsl:choose>
<xsl:choose>
<xsl:when test="$start != $end">
<p class="date">
<xsl:value-of select="$start_day" />
<xsl:text> </xsl:text>
<xsl:value-of select="$start_month" />
<xsl:text> to </xsl:text>
<xsl:value-of select="$end_day" />
<xsl:text> </xsl:text>
<xsl:value-of select="$end_month" />
<p class="date multiple">
<span class="n">(</span>
<span class="from">
<span class="day">
<xsl:value-of select="$start_day" />
</span>
<span class="month">
<xsl:value-of select="$start_month" />
</span>
</span>
<span class="conjunction">↓</span>
<span class="to">
<span class="day">
<xsl:value-of select="$end_day" />
</span>
<span class="month">
<xsl:value-of select="$end_month" />
</span>
</span>
<span class="n">)</span>
</p>
</xsl:when>
<xsl:otherwise>
<p class="date">
<xsl:value-of select="$start_day" />
<xsl:text> </xsl:text>
<xsl:value-of select="$start_month" />
<span class="n">(</span>
<span class="day">
<xsl:value-of select="$start_day" />
</span>
<span class="month">
<xsl:value-of select="$start_month" />
</span>
<span class="n">)</span>
</p>
</xsl:otherwise>
</xsl:choose>
<div class="details">
<xsl:apply-templates select="body/node()" />
<!--<div class="cleared">&#160;</div>-->
</div>
<!--
<xsl:if test="$link != ''">
<p class="read_more">
<a href="{link}"><xsl:value-of select="/html/text [@id = 'more']" /></a>
</p>
</xsl:if>

<xsl:if test="$page != ''">
<p class="read_more">
<a href="{page}"><xsl:value-of select="/html/text [@id = 'page']" /></a>
</p>
</xsl:if>
-->
</div>
</xsl:template>
<!-- Show a person's avatar -->
<xsl:template name="avatar">
<xsl:param name="id" />
<xsl:variable name="img-path" select="concat( '/about/', $id, '/', $id, '-avatar.jpg' )" />
<xsl:variable name="img-path"
select="concat( '/about/', $id, '/', $id, '-avatar.jpg' )" />
<xsl:element name="img">
<xsl:attribute name="src">
<xsl:value-of select="$img-path" />
</xsl:attribute>
<xsl:attribute name="onerror">
<xsl:text>this.src='/graphics/default-avatar.png';</xsl:text>
<xsl:text>
this.src='/graphics/default-avatar.png';
</xsl:text>
</xsl:attribute>
<xsl:attribute name="alt"
value="No picture" />
</xsl:element>
</xsl:template>
</xsl:stylesheet>

+ 60
- 14
tools/xsltsl/tagging.xsl View File

@@ -9,7 +9,7 @@
<xsl:output method="xml" encoding="UTF-8" indent="yes" />

<!--define dynamic list of tagged news items-->
<!--display dynamic list of tagged news items-->
<xsl:template name="fetch-news">
<xsl:param name="tag" select="''"/>
<xsl:param name="today" select="/html/@date" />
@@ -30,7 +30,7 @@
</xsl:template>
<!--define dynamic list of (not yet tagged) newsletters items-->
<!--display dynamic list of (not yet tagged) newsletters items-->
<xsl:template name="fetch-newsletters">
<xsl:param name="today" select="/html/@date" />
@@ -43,26 +43,72 @@
</xsl:template>
<!--define dynamic list of tagged event items-->
<!--display dynamic list of tagged event items-->
<xsl:template name="fetch-events">
<xsl:param name="tag" select="''"/>
<xsl:param name="today" select="/html/@date" />
<xsl:param name="wanted-time" select="future" /> <!-- value in {"past", "present", "future"} -->
<xsl:param name="header" select="''" />
<xsl:param name="nb-events" select="''" />
<xsl:variable name="tagcomma"><xsl:value-of select="$tag" />,</xsl:variable>
<xsl:variable name="commatag">, <xsl:value-of select="$tag" /></xsl:variable>
<xsl:for-each select="/html/set/event [translate (@end, '-', '') &gt;= translate ($today, '-', '') and
(contains(@tags, $commatag) or
contains(@tags, $tagcomma) or
@tags=$tag or
$tag='') ]">
<xsl:sort select="@start" />
<xsl:if test="position() &lt; 5">
<xsl:call-template name="event" />
</xsl:if>
</xsl:for-each>
<xsl:choose>
<xsl:when test="$wanted-time = 'past'">
<!-- Past events -->
<xsl:for-each select="/html/set/event
[translate (@end, '-', '') &lt; translate ($today, '-', '')]">
<xsl:sort select="@end" order="descending" />
<xsl:if test="position() &lt;= $nb-events or $nb-events=''">
<xsl:call-template name="event">
<xsl:with-param name="header">
<xsl:value-of select="$header" />
</xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:for-each>
</xsl:when>
<xsl:when test="$wanted-time = 'present'">
<!-- Current events -->
<xsl:for-each select="/html/set/event
[translate (@start, '-', '') &lt;= translate ($today, '-', '') and
translate (@end, '-', '') &gt;= translate ($today, '-', '')]">
<xsl:sort select="@start" order="descending" />
<xsl:if test="position() &lt;= $nb-events or $nb-events=''">
<xsl:call-template name="event">
<xsl:with-param name="header">
<xsl:value-of select="$header" />
</xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:for-each>
</xsl:when>
<xsl:otherwise> <!-- if we were not told what to do, display future events -->
<!-- Future events -->
<xsl:for-each select="/html/set/event
[translate (@start, '-', '') &gt; translate ($today, '-', '')]">
<xsl:sort select="@start" />
<xsl:if test="position() &lt;= $nb-events or $nb-events=''">
<xsl:call-template name="event">
<xsl:with-param name="header">
<xsl:value-of select="$header" />
</xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

Loading…
Cancel
Save