Source files of fsfe.org, pdfreaders.org, freeyourandroid.org, ilovefs.org, drm.info, and test.fsfe.org. Contribute: https://fsfe.org/contribute/web/ https://fsfe.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

329 lines
11 KiB

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dt="http://xsltsl.org/date-time">
<xsl:import href="date-time.xsl" />
<xsl:import href="feeds.xsl" />
<xsl:import href="events-utils.xsl" />
<xsl:output method="xml" encoding="UTF-8" indent="yes" />
<!--display dynamic list of tagged news items-->
<xsl:template name="fetch-news">
<xsl:param name="tag" select="''"/>
<xsl:param name="today" select="/html/@date" />
<xsl:param name="nb-items" select="''" />
<xsl:for-each select="/html/set/news[ translate (@date, '-', '') &lt;= translate ($today, '-', '')
and (tags/tag = $tag or $tag='')
and tags/tag != 'newsletter'
and not( @type = 'newsletter' ) ]">
<!-- @type != 'newsletter' is for legacy -->
<xsl:sort select="@date" order="descending" />
<xsl:if test="position() &lt;= $nb-items or $nb-items=''">
<xsl:call-template name="news" />
</xsl:if>
</xsl:for-each>
</xsl:template>
<!--display dynamic list of (not yet tagged) newsletters items-->
<xsl:template name="fetch-newsletters">
<xsl:param name="today" select="/html/@date" />
<xsl:param name="nb-items" select="''" />
<xsl:for-each select="/html/set/news [translate(@date, '-', '') &lt;= translate($today, '-', '')
and (tags/tag = 'newsletter'
or @type = 'newsletter' ) ]"> <!-- @type = 'newsletter' is for legacy -->
<xsl:sort select="@date" order="descending" />
<xsl:if test="position()&lt;= $nb-items or $nb-items=''">
<xsl:call-template name="newsletter" />
</xsl:if>
</xsl:for-each>
</xsl:template>
<!--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-items" select="''" />
<xsl:param name="display-details" select="'no'" />
<xsl:choose>
<xsl:when test="$wanted-time = 'past'">
<!-- Past events -->
<xsl:for-each select="/html/set/event [translate (@end, '-', '') &lt; translate ($today, '-', '') and (tags/tag = $tag or $tag='') ]">
<xsl:sort select="@end" order="descending" />
<xsl:if test="position() &lt;= $nb-items or $nb-items=''">
<xsl:call-template name="event">
<xsl:with-param name="header">
<xsl:value-of select="$header" />
</xsl:with-param>
<xsl:with-param name="display-details" select="$display-details" />
</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, '-', '') and
(tags/tag = $tag or $tag='') ]">
<xsl:sort select="@start" order="descending" />
<xsl:if test="position() &lt;= $nb-items or $nb-items=''">
<xsl:call-template name="event">
<xsl:with-param name="header">
<xsl:value-of select="$header" />
</xsl:with-param>
<xsl:with-param name="display-details" select="$display-details" />
</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, '-', '') and (tags/tag = $tag or $tag='') ]">
<xsl:sort select="@start" />
<xsl:if test="position() &lt;= $nb-items or $nb-items=''">
<xsl:call-template name="event">
<xsl:with-param name="header">
<xsl:value-of select="$header" />
</xsl:with-param>
<xsl:with-param name="display-details" select="$display-details" />
</xsl:call-template>
</xsl:if>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:key name="news-tags-by-value" match="news/tags/tag" use="."/>
<!--display dynamic list of tags used in news-->
<xsl:template name="all-tags-news">
<!-- <xsl:variable name="nbtags" select="count(
/html/set/news/tags/tag[
count( . | key( 'news-tags-by-value', . )[1] ) = 1
])" />
<xsl:variable name="average" select="count(/html/set/news/tags/tag) div $nbtags" />
##<xsl:value-of select="$nbtags" />##<xsl:value-of select="$average" />## -->
<xsl:element name="ul">
<xsl:attribute name="class">taglist</xsl:attribute>
<xsl:for-each select="/html/set/news/tags/tag">
<xsl:sort select="." order="ascending" />
<xsl:variable name="thistag" select="node()" />
<xsl:variable name="nb" select="count( /html/set/news/tags/tag[text() = $thistag]) " />
<!-- fontsize = (MAXFONT-MINFONT) * (count-MINCOUNT) / (MAXCOUNT-MINCOUNT) + MINFONT
→ to finish this calculation, we need to find out how many min and max tag occurrences there are -->
<!-- <xsl:variable name="font" select="(40-16) * ($nb-16) / (MAXCOUNT-MINCOUNT) + 16" /> -->
<xsl:if test="generate-id() = generate-id(key('news-tags-by-value', normalize-space(.)))">
<xsl:element name="li">
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:text>/tags/tagged.</xsl:text>
<xsl:value-of select="/html/@lang" />
<xsl:text>.html#n</xsl:text>
<xsl:value-of select="translate($thistag,' ','')" />
</xsl:attribute>
<xsl:value-of select="."/>
</xsl:element>
</xsl:element>
</xsl:if>
</xsl:for-each>
</xsl:element>
</xsl:template>
<xsl:key name="events-tags-by-value" match="event/tags/tag" use="."/>
<!--display dynamic list of tags used in events-->
<xsl:template name="all-tags-events">
<xsl:element name="ul">
<xsl:attribute name="class">taglist</xsl:attribute>
<xsl:for-each select="/html/set/event/tags/tag">
<xsl:sort select="." order="ascending" />
<xsl:variable name="thistag" select="node()" />
<xsl:if test="generate-id() = generate-id(key('events-tags-by-value', normalize-space(.)))">
<xsl:element name="li">
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:text>/tags/tagged.</xsl:text>
<xsl:value-of select="/html/@lang" />
<xsl:text>.html#e</xsl:text>
<xsl:value-of select="translate($thistag,' ','')" />
</xsl:attribute>
<xsl:value-of select="."/>
</xsl:element>
</xsl:element>
</xsl:if>
</xsl:for-each>
</xsl:element>
</xsl:template>
<xsl:template name="fetch-links">
<xsl:element name="ul">
<xsl:for-each select="/html/set/link">
<xsl:element name="li">
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="href" />
</xsl:attribute>
<xsl:value-of select="title"/>
</xsl:element>
<xsl:if test="description">
<xsl:element name="p">
<xsl:value-of select="description"/>
</xsl:element>
</xsl:if>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>
<!--display dynamic list of tagged news, sorted by tag -->
<xsl:template name="tagged-news">
<!-- loop through all tags (this complex expression loops over each tag once) -->
<xsl:for-each select="/html/set/news/tags/tag[ count( . | key( 'news-tags-by-value', . )[1] ) = 1 ]">
<xsl:sort select="." order="ascending" />
<xsl:variable name="tag" select="." />
<xsl:element name="a">
<xsl:attribute name="name">
<xsl:text>n</xsl:text>
<xsl:value-of select="translate($tag, ' ', '')" />
</xsl:attribute>
<xsl:element name="h3"><xsl:value-of select="$tag" /></xsl:element>
</xsl:element>
<xsl:element name="ul">
<!-- loop through all news having this tag -->
<xsl:for-each select="/html/set/news[tags/tag = $tag]">
<xsl:element name="li">
<xsl:element name="a">
<xsl:attribute name="href"><xsl:value-of select="link" /></xsl:attribute>
<xsl:value-of select="title" />
</xsl:element>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:for-each>
</xsl:template>
<!--display dynamic list of tagged events, sorted by tag -->
<xsl:template name="tagged-events">
<xsl:param name="absolute-fsfe-links" />
<!-- loop through all tags (this complex expression loops over each tag once) -->
<xsl:for-each select="/html/set/event/tags/tag[ count( . | key( 'events-tags-by-value', . )[1] ) = 1 ]">
<xsl:sort select="." order="ascending" />
<xsl:variable name="tag" select="." />
<xsl:element name="a">
<xsl:attribute name="name">
<xsl:text>e</xsl:text>
<xsl:value-of select="translate($tag, ' ', '')" />
</xsl:attribute>
<xsl:element name="h3"><xsl:value-of select="$tag" /></xsl:element>
</xsl:element>
<xsl:element name="ul">
<!-- loop through all events having this tag -->
<xsl:for-each select="/html/set/event[tags/tag = $tag]">
<xsl:element name="li">
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:call-template name="event-link">
<xsl:with-param name="absolute-fsfe-links" select="$absolute-fsfe-links" />
</xsl:call-template>
</xsl:attribute>
<xsl:value-of select="title" />
</xsl:element><!--a-->
</xsl:element><!--li-->
</xsl:for-each>
</xsl:element>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>