html.xsl raus!

XPath-Klarifikationen
Jeder News noch eine eigene HTML-Seite
<addendum/> für Newstext, der nicht in der Übersicht stehen soll
Weiterlesen-Link in der Newsübersicht (TODO: muss auch in RSS & ATOM!)


git-svn-id: svn://svn.c3d2.de/c3d2-web/trunk@324 31f61c52-7bfb-0310-b897-fc00f8a278f0
This commit is contained in:
astro 2006-05-24 00:19:45 +00:00
parent c38ecd1271
commit bb29db45ad
7 changed files with 101 additions and 208 deletions

View File

@ -32,11 +32,12 @@ SKEL=empty
# Zu verwendendes Skeleton # Zu verwendendes Skeleton
SKELFILE=content/skel-$(SKEL).xml SKELFILE=content/skel-$(SKEL).xml
# Dateinamen der Inhalte: # Dateinamen der Inhalte:
CONTENT=$(PAGES) $(DS_PAGES) $(NEWSFILES) CONTENT=$(PAGES) $(NEWS_PAGES) $(DS_PAGES) $(NEWSFILES)
# Chaosupdates # Chaosupdates
WWW_CCC_DE_UPDATES=chaosupdates.rdf WWW_CCC_DE_UPDATES=chaosupdates.rdf
PAGES:=$(patsubst content/%.xml, www/%.html, $(filter-out $(NAVIGATION) $(SKELETONS), $(wildcard content/*.xml))) PAGES:=$(patsubst content/%.xml, www/%.html, $(filter-out $(NAVIGATION) $(SKELETONS), $(wildcard content/*.xml)))
NEWS_PAGES:=$(patsubst content/news/%.xml, www/news/%.html, $(wildcard content/news/*.xml))
DS_PAGES:=$(patsubst content/datenspuren/%.xml, www/datenspuren/%.html, $(wildcard content/datenspuren/*.xml)) www/datenspuren/schedule.html DS_PAGES:=$(patsubst content/datenspuren/%.xml, www/datenspuren/%.html, $(wildcard content/datenspuren/*.xml)) www/datenspuren/schedule.html
NEWSINDEX:=content/news.xml NEWSINDEX:=content/news.xml
NEWSITEMS:=$(filter-out $(NEWSINDEX), $(wildcard content/news/*.xml)) NEWSITEMS:=$(filter-out $(NEWSINDEX), $(wildcard content/news/*.xml))
@ -105,6 +106,10 @@ www/%.html: content/%.xml $(STYLE) $(NAVIGATION) $(WWW_CCC_DE_UPDATES)
$(VALIDATOR) $(VFLAGS) $< $(VALIDATOR) $(VFLAGS) $<
$(PROCESSOR) $(PFLAGS) -o $@ $(STYLE) $< $(PROCESSOR) $(PFLAGS) -o $@ $(STYLE) $<
#www/news/%.html: content/news/%.xml $(STYLE) $(NAVIGATION) $(WWW_CCC_DE_UPDATES)
# $(VALIDATOR) $(VFLAGS) $<
# $(PROCESSOR) $(PFLAGS) -o $@ $(STYLE) $<
### Hilfsregeln zum Editieren ### ### Hilfsregeln zum Editieren ###
edit/%: edit/%:
@if [ ! -e content/$(@F).xml ] ; then \ @if [ ! -e content/$(@F).xml ] ; then \

View File

@ -6,4 +6,10 @@
<p> <p>
Der jährlich ausgetragene Chaos Communication Congress beginnt seine Magie auszustreuen. Pflicht! Der jährlich ausgetragene Chaos Communication Congress beginnt seine Magie auszustreuen. Pflicht!
</p> </p>
<addendum>
<p>
Unter <link>http://media.ccc.de/filez/congress/2005/lectures/video/mp4/</link> gibts die Mitschnitte.
</p>
</addendum>
</item> </item>

View File

@ -12,6 +12,8 @@
encoding="utf-8" encoding="utf-8"
indent="yes"/> indent="yes"/>
<xsl:variable name="baseurl"/>
<xsl:template match="news"> <xsl:template match="news">
<xsl:element name="feed"> <xsl:element name="feed">
<xsl:attribute name="xmlns">http://www.w3.org/2005/Atom</xsl:attribute> <xsl:attribute name="xmlns">http://www.w3.org/2005/Atom</xsl:attribute>

View File

@ -76,11 +76,22 @@
</xsl:element> </xsl:element>
</xsl:template> </xsl:template>
<xsl:template match="addendum">
<!--
Wenn wir nicht in news/ oder anderem sind, dann
zeige nicht vollen Newstext (<addendum/>)
-->
<xsl:if test="string-length($baseurl) &gt; 0">
<xsl:apply-templates/>
</xsl:if>
</xsl:template>
<xsl:template name="navitem"> <xsl:template name="navitem">
<xsl:param name="file"/> <xsl:param name="file"/>
<xsl:param name="baseurl"/>
<li> <li>
<xsl:element name="a"> <xsl:element name="a">
<xsl:attribute name="href"><xsl:value-of select="$file"/>.html</xsl:attribute> <xsl:attribute name="href"><xsl:value-of select="concat($baseurl, $file, '.html')"/></xsl:attribute>
<xsl:if test="document(concat('../content/', $file, '.xml'))/page/@pagetitle"> <xsl:if test="document(concat('../content/', $file, '.xml'))/page/@pagetitle">
<xsl:attribute name="title"><xsl:value-of select="document(concat('../content/', $file, '.xml'))/page/@pagetitle"/></xsl:attribute> <xsl:attribute name="title"><xsl:value-of select="document(concat('../content/', $file, '.xml'))/page/@pagetitle"/></xsl:attribute>
</xsl:if> </xsl:if>
@ -92,11 +103,12 @@
<xsl:template name="navitems"> <xsl:template name="navitems">
<ul> <ul>
<li> <li>
<a href="news.html" title="News">News</a> <a href="{$baseurl}news.html" title="News">News</a>
</li> </li>
<xsl:for-each select="document('../content/navigation.xml')/navigation/file"> <xsl:for-each select="document('../content/navigation.xml')/navigation/file">
<xsl:call-template name="navitem"> <xsl:call-template name="navitem">
<xsl:with-param name="file" select="."/> <xsl:with-param name="file" select="."/>
<xsl:with-param name="baseurl" select="$baseurl"/>
</xsl:call-template> </xsl:call-template>
</xsl:for-each> </xsl:for-each>
</ul> </ul>

View File

@ -5,9 +5,6 @@
xmlns:date="http://exslt.org/dates-and-times" exclude-result-prefixes="xsl rss rdf date"> xmlns:date="http://exslt.org/dates-and-times" exclude-result-prefixes="xsl rss rdf date">
<xsl:template name="links"> <xsl:template name="links">
<xsl:variable name="baseurl">
<xsl:call-template name="getbaseurl" />
</xsl:variable>
<link rel="icon" type="image/png" href="{$baseurl}images/favicon.png" /> <link rel="icon" type="image/png" href="{$baseurl}images/favicon.png" />
<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="{$baseurl}news-rss.xml" /> <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="{$baseurl}news-rss.xml" />

View File

@ -1,149 +0,0 @@
<?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:import href="xhtml.xsl" />
<xsl:output method="html"
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 name="getbaseurl">
<xsl:choose>
<xsl:when test="/item">
<xsl:text>../../</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>../</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="navitem">
<xsl:param name="file"/>
<xsl:variable name="baseurl">
<xsl:if test="/item">
<xsl:text>../</xsl:text>
</xsl:if>
</xsl:variable>
<li>
<xsl:element name="a">
<xsl:attribute name="href"><xsl:value-of select="concat($baseurl,$file)"/>.xml</xsl:attribute>
<xsl:if test="document(concat('../content/', $file, '.xml'))/page/@pagetitle">
<xsl:attribute name="title"><xsl:value-of select="document(concat('../content/', $file, '.xml'))/page/@pagetitle"/></xsl:attribute>
</xsl:if>
<xsl:value-of select="document(concat('../content/', $file, '.xml'))/page/@title"/>
</xsl:element>
</li>
</xsl:template>
<xsl:template name="navitems">
<xsl:variable name="baseurl">
<xsl:if test="/item">
<xsl:text>../</xsl:text>
</xsl:if>
</xsl:variable>
<ul>
<li>
<a href="{$baseurl}news.xml" title="News">News</a>
</li>
<xsl:for-each select="document('../content/navigation.xml')/navigation/file">
<xsl:call-template name="navitem">
<xsl:with-param name="file" select="."/>
</xsl:call-template>
</xsl:for-each>
</ul>
</xsl:template>
<xsl:template match="news">
<xsl:for-each select="document(newsfile, ..)/item">
<xsl:sort select="@date" data-type="text" order="descending" />
<xsl:variable name="current">
<xsl:value-of select="." />
</xsl:variable>
<xsl:variable name="newsfile">
<xsl:for-each select="document('../content/news.xml')/page/news/newsfile">
<xsl:if test="document(current()) = $current">
<xsl:value-of select="current()" />
</xsl:if>
</xsl:for-each>
</xsl:variable>
<h3 class="news">
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="$newsfile" />
</xsl:attribute>
<xsl:attribute name="title">
<xsl:value-of select="@title" />
</xsl:attribute>
<xsl:value-of select="@title"/>
</xsl:element>
</h3>
<small class="news_author">
<xsl:value-of select="@author"/>
</small>
<xsl:variable name="datestring">
<xsl:value-of select="@date" />
</xsl:variable>
<xsl:element name="small">
<xsl:attribute name="class">news_date</xsl:attribute>
<xsl:value-of select="concat(' @ ', $datestring)"/>
</xsl:element>
<div class="news">
<xsl:choose>
<!--- <XXX> Kann das hier in ein Template? -->
<xsl:when test="image">
<xsl:element name="img">
<xsl:attribute name="src"><xsl:value-of select="image"/></xsl:attribute>
<xsl:attribute name="title"><xsl:value-of select="image/@title"/></xsl:attribute>
<xsl:attribute name="alt"><xsl:value-of select="image/@title"/></xsl:attribute>
<!-- News-Items haben ihre Bilder abwechselnd rechts und links... -->
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="position() mod 2 = 1">
<xsl:text>left</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>right</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<!-- TODO:
<xsl:call-template name="getimage">
<xsl:with-param name="category" select="@category" />
</xsl:call-template>
-->
</xsl:otherwise>
</xsl:choose>
<!-- </XXX> -->
<xsl:apply-templates/>
</div>
<hr class="news"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

View File

@ -19,10 +19,11 @@
doctype-system="DTD/xhtml1-strict.dtd" doctype-system="DTD/xhtml1-strict.dtd"
indent="yes"/> indent="yes"/>
<xsl:template name="getbaseurl"> <xsl:variable name="baseurl">
</xsl:template> <xsl:if test="name(/*)='item'">../</xsl:if>
</xsl:variable>
<xsl:template match="/page">
<xsl:template match="/page|/news">
<xsl:variable name="title"> <xsl:variable name="title">
<xsl:choose> <xsl:choose>
<xsl:when test="/page/@pagetitle"> <xsl:when test="/page/@pagetitle">
@ -141,64 +142,83 @@
</xsl:element> <!-- name="html" --> </xsl:element> <!-- name="html" -->
</xsl:template> </xsl:template>
<xsl:template match="news"> <xsl:template match="/page/news">
<xsl:for-each select="document(newsfile)/item"> <xsl:for-each select="newsfile">
<xsl:sort select="date:seconds(@date)" data-type="number" order="descending" /> <xsl:variable name="newsfile"><xsl:value-of select="."/></xsl:variable>
<h3 class="news"><xsl:value-of select="@title"/></h3> <xsl:for-each select="document(concat('../content/', $newsfile))/item">
<xsl:sort select="date:seconds(@date)" data-type="number" order="descending" />
<small class="news_author"> <h3 class="news">
<xsl:value-of select="@author"/> <a>
</small> <xsl:attribute name="href">
<xsl:value-of select="substring-before($newsfile, '.xml')"/>.html
</xsl:attribute>
<xsl:value-of select="@title"/>
</a>
</h3>
<xsl:variable name="datestring"> <small class="news_author">
<xsl:call-template name="get-datestring"> <xsl:value-of select="@author"/>
<xsl:with-param name="date" select="@date" /> </small>
</xsl:call-template>
</xsl:variable>
<xsl:element name="small"> <xsl:variable name="datestring">
<xsl:attribute name="class">news_date</xsl:attribute> <xsl:call-template name="get-datestring">
<xsl:value-of select="concat(' @ ', $datestring)"/> <xsl:with-param name="date" select="@date" />
</xsl:element> </xsl:call-template>
</xsl:variable>
<div class="news"> <xsl:element name="small">
<xsl:choose> <xsl:attribute name="class">news_date</xsl:attribute>
<xsl:value-of select="concat(' @ ', $datestring)"/>
</xsl:element>
<!--- <XXX> Kann das hier in ein Template? --> <div class="news">
<xsl:when test="image"> <xsl:choose>
<xsl:element name="img">
<xsl:attribute name="src"><xsl:value-of select="image"/></xsl:attribute>
<xsl:attribute name="title"><xsl:value-of select="image/@title"/></xsl:attribute>
<xsl:attribute name="alt"><xsl:value-of select="image/@title"/></xsl:attribute>
<!-- News-Items haben ihre Bilder abwechselnd rechts und links... -->
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="position() mod 2 = 1">
<xsl:text>left</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>right</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<!-- TODO:
<xsl:call-template name="getimage">
<xsl:with-param name="category" select="@category" />
</xsl:call-template>
-->
</xsl:otherwise>
</xsl:choose>
<!-- </XXX> -->
<xsl:apply-templates/> <!--- <XXX> Kann das hier in ein Template? -->
</div> <xsl:when test="image">
<xsl:element name="img">
<xsl:attribute name="src"><xsl:value-of select="image"/></xsl:attribute>
<xsl:attribute name="title"><xsl:value-of select="image/@title"/></xsl:attribute>
<xsl:attribute name="alt"><xsl:value-of select="image/@title"/></xsl:attribute>
<!-- News-Items haben ihre Bilder abwechselnd rechts und links... -->
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="position() mod 2 = 1">
<xsl:text>left</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>right</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<!-- TODO:
<xsl:call-template name="getimage">
<xsl:with-param name="category" select="@category" />
</xsl:call-template>
-->
</xsl:otherwise>
</xsl:choose>
<!-- </XXX> -->
<hr class="news"/> <xsl:apply-templates/>
<xsl:if test="//addendum">
<p>
<a href="{baseurl}{substring-before($newsfile, '.xml')}.html">
Weiterlesen...
</a>
</p>
</xsl:if>
</div>
<hr class="news"/>
</xsl:for-each>
</xsl:for-each> </xsl:for-each>
</xsl:template> </xsl:template>