c3d2-web/xsl/xhtml.xsl

253 lines
7.8 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:rss="http://purl.org/rss/1.0/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:date="http://exslt.org/dates-and-times"
exclude-result-prefixes="xsl rss rdf">
<xsl:include href="common.xsl" />
<xsl:include href="date.xsl" />
<xsl:include href="header.xsl" />
<xsl:include href="footer.xsl" />
<xsl:output method="xml"
version="1.0"
encoding="utf-8"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system="DTD/xhtml1-strict.dtd"
indent="yes"/>
<xsl:template match="/page">
<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: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="$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:variable name="issearchpage" select="$title = 'Suche'" />
<xsl:element name="html">
<!--xsl:attribute name="xmlns">http://www.w3.org/1999/xhtml</xsl:attribute-->
<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:value-of select="$title" />
</title>
</xsl:element>
<xsl:element name="body">
<div id="page">
<!-- ### Logo ### -->
<xsl:comment>
<xsl:text> ### Logo ### </xsl:text>
</xsl:comment>
<div id="logo">
<h1>&lt;&lt;&lt;/&gt;&gt; Chaos Computer Club Dresden | c3d2</h1>
</div>
<div id="body">
<!-- ### Navigation ### -->
<xsl:comment>
<xsl:text> ### Navigation ### </xsl:text>
</xsl:comment>
<div id="navigation">
<xsl:if test="not($issearchpage)">
<!-- ### Search ### -->
<xsl:comment>
<xsl:text> ### Search ### </xsl:text>
</xsl:comment>
<form action="/cgi-bin/estseek.cgi" method="get">
<p>
<input type="text" name="phrase" size="20" value="c3d2" />
<input type="submit" name="submit" value="Suchen!" />
<a href="{$baseurl}cgi-bin/estseek.cgi"><small>Hilfe</small></a>
</p>
</form>
</xsl:if>
<xsl:call-template name="navitems" />
</div> <!-- id="navigation" -->
<!-- ### Content ### -->
<xsl:comment>
<xsl:text> ### Content ### </xsl:text>
</xsl:comment>
<xsl:choose>
<xsl:when test="$issearchpage">
<div id="search">
<xsl:comment>ESTFORM</xsl:comment>
<xsl:comment>ESTRESULT</xsl:comment>
<xsl:comment>ESTINFO</xsl:comment>
</div> <!-- id="search" -->
</xsl:when>
<xsl:otherwise> <!-- normale Seite -->
<div id="content">
<h2>
<xsl:if test="name(.) = 'item'">
<xsl:attribute name="class">news</xsl:attribute>
</xsl:if>
<xsl:value-of select="$title" />
</h2>
<!-- 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/>
</div> <!-- id="content" -->
<!-- ### News ### -->
<xsl:comment>
<xsl:text> ### News ### </xsl:text>
</xsl:comment>
<xsl:call-template name="chaosupdates" />
</xsl:otherwise>
</xsl:choose>
</div> <!-- id="body" -->
<!-- ### Footer ### -->
<xsl:comment>
<xsl:text> ### Footer ### </xsl:text>
</xsl:comment>
<div id="footer">
<xsl:call-template name="footer" />
<!-- <p id="update">
<strong>last update:</strong> 02/08/2005 15:15 CEST
</p> -->
</div> <!-- id="footer" -->
<small class="hidden">
Cover, Concealment, Camouflage, Denial and Deception
</small>
</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:variable name="newsfile"><xsl:value-of select="."/></xsl:variable>
<xsl:variable name="itemposition" select="position()"/>
<xsl:for-each select="document(concat('../', $newsfile))/item">
<h3 class="news">
<a href="{substring-before(substring-after($newsfile, 'content/'), '.xml')}.html">
<xsl:value-of select="@title"/>
</a>
</h3>
<xsl:call-template name="news-meta"/>
<div class="news">
<xsl:apply-templates>
<xsl:with-param name="itemposition" select="$itemposition"/>
</xsl:apply-templates>
<xsl:if test="//addendum">
<p>
<a href="{substring-before(substring-after($newsfile, 'content/'), '.xml')}.html">
Weiterlesen...
</a>
</p>
</xsl:if>
</div>
<hr class="news"/>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
<xsl:template name="news-meta">
<small class="news_author">
<xsl:value-of select="@author"/>
</small>
<xsl:variable name="datestring">
<xsl:call-template name="get-datestring">
<xsl:with-param name="date" select="@date" />
</xsl:call-template>
</xsl:variable>
<xsl:element name="small">
<xsl:attribute name="class">news_date</xsl:attribute>
<xsl:value-of select="concat(' @ ', $datestring)"/>
</xsl:element>
</xsl:template>
<xsl:template match="item/image">
<xsl:param name="itemposition"/>
<img>
<xsl:choose>
<xsl:when test="contains(., '://')">
<xsl:attribute name="src"><xsl:value-of select="."/></xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="src"><xsl:value-of select="concat($baseurl, 'images/news/', .)"/></xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<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:stylesheet>