c3d2-web/xsl/xhtml5.xsl

359 lines
10 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:date="http://exslt.org/dates-and-times"
exclude-result-prefixes="xsl">
<xsl:include href="common.xsl" />
<xsl:include href="header.xsl" />
<xsl:include href="footer.xsl" />
<xsl:include href="calendar.xsl" />
<xsl:output method="xml"
version="1.0"
encoding="utf-8"
indent="yes"/>
<xsl:template match="/page">
<xsl:text disable-output-escaping="yes">&lt;!DOCTYPE html&gt;
</xsl:text>
<xsl:variable name="title">
<xsl:choose>
<xsl:when test="/page/@pagetitle">
<xsl:value-of select="/page/@pagetitle"/>
</xsl:when>
<xsl:when test="/page/@title">
<xsl:value-of select="/page/@title"/>
</xsl:when>
<xsl:when test="/page/calendar-summary">
<xsl:call-template name="calendar-title"/>
</xsl:when>
<xsl:otherwise>
<xsl:comment><xsl:text> missing title </xsl:text></xsl:comment>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:call-template name="body">
<xsl:with-param name="title" select="normalize-space($title)" />
</xsl:call-template>
</xsl:template>
<xsl:template match="/item">
<xsl:variable name="title">
<xsl:value-of select="/item/@title"/>
</xsl:variable>
<xsl:call-template name="body">
<xsl:with-param name="title" select="$title" />
</xsl:call-template>
</xsl:template>
<xsl:template name="body">
<xsl:param name="title" />
<xsl:element name="html">
<xsl:attribute name="lang">de</xsl:attribute>
<xsl:attribute name="xml:lang">de</xsl:attribute>
<xsl:element name="head">
<xsl:call-template name="header" />
<title>
<xsl:text>&lt;&lt;&lt;/&gt;&gt; Chaos Computer Club Dresden | c3d2</xsl:text>
<xsl:if test="$title != ''">
<xsl:text> - </xsl:text>
<xsl:value-of select="$title" />
</xsl:if>
</title>
</xsl:element>
<xsl:element name="body">
<div id="page">
<!-- ### Logo ### -->
<xsl:comment>
<xsl:text> ### Logo ### </xsl:text>
</xsl:comment>
<div id="logo">
<a href="http://c3d2.de"><h1>&lt;&lt;&lt;/&gt;&gt; Chaos Computer Club Dresden | c3d2</h1></a>
</div>
<div id="body">
<!-- ### Navigation ### -->
<xsl:comment>
<xsl:text> ### Navigation ### </xsl:text>
</xsl:comment>
<nav id="navigation">
<xsl:call-template name="navitems" />
</nav>
<!-- ### News ### -->
<xsl:comment>
<xsl:text> ### News ### </xsl:text>
</xsl:comment>
<aside id="rsidebar">
<xsl:call-template name="adspace" />
<xsl:call-template name="calendar-events" />
<xsl:call-template name="chaosupdates" />
</aside>
<!-- ### Content ### -->
<xsl:comment>
<xsl:text> ### Content ### </xsl:text>
</xsl:comment>
<section id="content">
<xsl:if test="event">
<xsl:attribute name="class">vevent</xsl:attribute>
</xsl:if>
<xsl:if test="$title != ''">
<h2>
<xsl:if test="name(.) = 'item'">
<xsl:attribute name="class">news</xsl:attribute>
</xsl:if>
<xsl:value-of select="$title" />
</h2>
</xsl:if>
<!-- Für Seiten, die nur ein Newsitem beinhalten,
Newsmetadaten anzeigen
-->
<xsl:if test="name(.) = 'item'">
<xsl:call-template name="news-meta"/>
</xsl:if>
<xsl:apply-templates/>
</section> <!-- id="content" -->
<xsl:call-template name="footer" />
</div> <!-- id="body" -->
</div> <!-- id="page" -->
</xsl:element> <!-- name="body" -->
</xsl:element> <!-- name="html" -->
</xsl:template>
<xsl:template match="/page/news">
<xsl:for-each select="newsfile">
<xsl:sort select="date:seconds(document(concat('../', .))/item/@date)" data-type="number" order="descending" />
<xsl:if test="position() &lt;= 10">
<xsl:variable name="newsfile"><xsl:value-of select="."/></xsl:variable>
<xsl:variable name="itemposition" select="position()"/>
<xsl:for-each select="document(concat('../', $newsfile))/item">
<article><div>
<xsl:if test="event">
<xsl:attribute name="class">vevent</xsl:attribute>
</xsl:if>
<header>
<h3 class="news summary">
<a href="{substring-before(substring-after($newsfile, 'content/'), '.xml')}.html" class="url">
<xsl:value-of select="@title"/>
</a>
</h3>
<xsl:call-template name="news-meta"/>
</header>
<div class="news">
<xsl:apply-templates select="*[name() != 'addendum']">
<xsl:with-param name="itemposition" select="$itemposition"/>
</xsl:apply-templates>
<xsl:if test="//addendum or //resource[@hide='yes']">
<footer><p class="more">
<a href="{substring-before(substring-after($newsfile, 'content/'), '.xml')}.html">
Weiterlesen…
</a>
</p></footer>
</xsl:if>
</div>
<hr class="news"/>
</div></article>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
<aside>
<p>
Die Neuigkeiten des C3D2 sind auch
als <a href="{$baseurl}news-atom.xml">ATOM</a>
und <a href="{$baseurl}news-rss.xml">RSS</a>, die
Veranstaltungen
im <a href="{$baseurl}ical.ics">iCal-</a>, <a href="{$baseurl}xcal.xml">XCal-</a>
und <a href="{$baseurl}reminders">remind-Format</a> abrufbar.
Mehr News gibts im <a href="{$baseurl}news-archiv.html" rel="archives">Archiv</a>.
</p>
</aside>
</xsl:template>
<xsl:template name="news-meta">
<small class="news_author">
<xsl:value-of select="@author"/>
</small>
<small class="news_date">
@
<time datetime="{@date}" pubdate="pubdate">
<xsl:call-template name="get-datestring">
<xsl:with-param name="date" select="@date" />
</xsl:call-template>
</time>
</small>
</xsl:template>
<xsl:template match="item/image">
<xsl:param name="itemposition"/>
<img>
<xsl:attribute name="src">
<xsl:call-template name="normalize-path">
<xsl:with-param name="path">
<xsl:choose>
<xsl:when test="contains(., '://')">
<xsl:value-of select="."/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat($baseurl, 'images/news/', .)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
</xsl:call-template>
</xsl:attribute>
<xsl:attribute name="title"><xsl:value-of select="@title"/></xsl:attribute>
<xsl:attribute name="alt"><xsl:value-of select="@title"/></xsl:attribute>
<!-- News-Items haben ihre Bilder abwechselnd rechts und links... -->
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="$itemposition mod 2 = 1">
<xsl:text>left</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>right</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</img>
</xsl:template>
<xsl:template match="news-list">
<xsl:variable name="prefix" select="@prefix"/>
<xsl:variable name="details" select="@details"/>
<xsl:for-each select="document('../news.xml')/page/news/newsfile">
<xsl:sort select="date:seconds(document(concat('../', .))/item/@date)" data-type="number" order="descending" />
<xsl:variable name="newsfile" select="."/>
<xsl:for-each select="document(concat('../', $newsfile))/item">
<xsl:if test="((string-length($prefix) = 0) or starts-with($newsfile, concat('content/news/', $prefix))) and (($details != 'resources-only') or (count(resource) &gt; 0))">
<div>
<xsl:if test="($details = 'event') and event">
<xsl:attribute name="class">vevent</xsl:attribute>
</xsl:if>
<h3 class="summary">
<a href="{substring-before(substring-after($newsfile, 'content/'), '.xml')}.html" class="url">
<xsl:value-of select="@title"/>
</a>
</h3>
<xsl:choose>
<xsl:when test="$details = 'news'">
<xsl:call-template name="news-meta"/>
</xsl:when>
<xsl:when test="$details = 'resources-only'">
<xsl:apply-templates select=".//resource"/>
</xsl:when>
<xsl:when test="($details = 'event') and event">
<ul class="details_event">
<li>
<abbr class="dtstart">
<xsl:attribute name="title">
<xsl:call-template name="date-to-hevent">
<xsl:with-param name="date" select="event/start"/>
</xsl:call-template>
</xsl:attribute>
<xsl:call-template name="get-datestring">
<xsl:with-param name="date" select="event/start"/>
</xsl:call-template>
</abbr>
</li>
<li class="location">
<xsl:value-of select="event/location"/>
</li>
</ul>
</xsl:when>
</xsl:choose>
</div>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
<xsl:template match="/page/portal">
<section id="portal">
<xsl:apply-templates select="item[position() &lt;= 24]"/>
</section>
</xsl:template>
<xsl:template match="/page/portal/item">
<article>
<xsl:if test="@class">
<xsl:attribute name="class"><xsl:value-of select="@class"/></xsl:attribute>
</xsl:if>
<a href="{link}">
<xsl:if test="content-image">
<xsl:attribute name="style">
background: url('<xsl:value-of select="content-image"/>') 50% 50% no-repeat;
</xsl:attribute>
</xsl:if>
<xsl:apply-templates select="header"/>
<xsl:apply-templates select="footer"/>
<xsl:apply-templates select="content-text"/>
</a>
</article>
</xsl:template>
<xsl:template match="portal/item/header">
<h3><xsl:value-of select="string(.)"/></h3>
</xsl:template>
<xsl:template match="portal/item/footer">
<p class="footer"><xsl:value-of select="string(.)"/></p>
</xsl:template>
<xsl:template match="portal/item/content-text">
<h4><xsl:value-of select="string(.)"/></h4>
</xsl:template>
<xsl:template match="portal/item/content-image">
<img src="{{.}}"/>
</xsl:template>
</xsl:stylesheet>