Atom support, please test.

git-svn-id: svn://svn.c3d2.de/c3d2-web/branches/toidinamais_coole_scheisse@101 31f61c52-7bfb-0310-b897-fc00f8a278f0
This commit is contained in:
toidinamai 2006-01-06 18:51:03 +00:00
parent 9b7eb8f257
commit d3f3cd37aa
4 changed files with 110 additions and 53 deletions

View File

@ -23,6 +23,7 @@ DESTDIR?=www-export
STYLE=xsl/xhtml.xsl
DS_STYLE=xsl/datenspuren/xhtml.xsl
STYLE_RSS=xsl/rss.xsl
STYLE_ATOM=xsl/atom.xsl
# Navigationsleiste:
NAVIGATION=content/navigation.xml
# XML-Skeletons
@ -31,12 +32,12 @@ SKEL=empty
# Zu verwendendes Skeleton
SKELFILE=content/skel-$(SKEL).xml
# Dateinamen der Inhalte:
CONTENT=$(PAGES) $(DS_PAGES) www/news.html www/news-rss.xml
CONTENT=$(PAGES) $(DS_PAGES) $(NEWSFILES)
PAGES:=$(patsubst content/%.xml, www/%.html, $(filter-out $(NAVIGATION) $(SKELETONS), $(wildcard content/*.xml)))
DS_PAGES:=$(patsubst content/datenspuren/%.xml, www/datenspuren/%.html, $(wildcard content/datenspuren/*.xml))
NEWSITEMS:=$(wildcard content/news/*.xml)
NEWSFILES:=www/news.html www/news-rss.xml
NEWSFILES:=www/news.html www/news-rss.xml www/news-atom.xml
DTD:=dtd/c3d2web.dtd
CLEAN=$(CONTENT) $(NEWSFILES)
@ -65,6 +66,7 @@ check: $(PAGES)
### Regeln für den XSLT-Prozess ###
www/news.html: $(STYLE)
www/news-rss.xml: $(STYLE_RSS)
www/news-atom.xml: $(STYLE_ATOM)
$(NEWSFILES): $(NEWSITEMS) $(NAVIGATION)
for item in $(NEWSITEMS) ; do \

45
xsl/atom.xsl Normal file
View File

@ -0,0 +1,45 @@
<?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">
<xsl:include href="common.xsl" />
<xsl:output method="xml"
version="1.0"
encoding="utf-8"
indent="yes"/>
<xsl:template match="news">
<xsl:element name="feed">
<xsl:attribute name="xmlns">http://www.w3.org/2005/Atom</xsl:attribute>
<xsl:attribute name="xml:lang">de</xsl:attribute>
<title>www.c3d2.de Newsfeed</title>
<link rel="self" href="https://www.c3d2.de/news-atom.xml" />
<id>http://www.c3d2.de/</id>
<description>Neues aus dem Chaos Computer Club Dresden</description>
<language>de-de</language>
<!-- XXX
<pubDate><xsl:value-of select="news/item/@date"/></pubDate>
-->
<xsl:for-each select="document(newsfile)/item">
<xsl:sort select="date:seconds(@date)" data-type="number" order="descending" />
<entry>
<id><xsl:value-of select="id(current())"/></id>
<title><xsl:value-of select="@title"/></title>
<updated><xsl:value-of select="@date"/></updated>
<author>
<name><xsl:value-of select="@author"/></name>
</author>
<content><xsl:apply-templates/></content>
</entry>
</xsl:for-each>
</xsl:element>
</xsl:template>
</xsl:stylesheet>

60
xsl/common.xsl Normal file
View File

@ -0,0 +1,60 @@
<?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:template match="pre">
<xsl:copy><xsl:apply-templates/></xsl:copy>
</xsl:template>
<xsl:template match="p">
<xsl:copy><xsl:apply-templates/></xsl:copy>
</xsl:template>
<xsl:template match="dl">
<xsl:copy><xsl:apply-templates/></xsl:copy>
</xsl:template>
<xsl:template match="dh">
<dt class="main"><xsl:apply-templates/></dt>
</xsl:template>
<xsl:template match="dt">
<xsl:copy><xsl:apply-templates/></xsl:copy>
</xsl:template>
<xsl:template match="dd">
<xsl:copy><xsl:apply-templates/></xsl:copy>
</xsl:template>
<xsl:template match="image">
<xsl:element name="img">
<xsl:attribute name="src"><xsl:value-of select="."/></xsl:attribute>
<xsl:attribute name="title"><xsl:value-of select="@title"/></xsl:attribute>
<xsl:attribute name="alt"><xsl:value-of select="@title"/></xsl:attribute>
<xsl:attribute name="class"><xsl:value-of select="@class"/></xsl:attribute>
</xsl:element>
</xsl:template>
<xsl:template match="link">
<xsl:element name="a">
<xsl:choose>
<xsl:when test="@href">
<xsl:attribute name="href"><xsl:value-of select="@href"/></xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="href"><xsl:value-of select="."/></xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="em">
<xsl:value-of select="."/>
</xsl:template>
</xsl:stylesheet>

View File

@ -6,6 +6,7 @@
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" />
@ -200,61 +201,10 @@
</xsl:for-each>
</xsl:template>
<xsl:template match="pre">
<xsl:copy><xsl:apply-templates/></xsl:copy>
</xsl:template>
<xsl:template match="p">
<xsl:copy><xsl:apply-templates/></xsl:copy>
</xsl:template>
<xsl:template match="dl">
<xsl:copy><xsl:apply-templates/></xsl:copy>
</xsl:template>
<xsl:template match="dh">
<dt class="main"><xsl:apply-templates/></dt>
</xsl:template>
<xsl:template match="dt">
<xsl:copy><xsl:apply-templates/></xsl:copy>
</xsl:template>
<xsl:template match="dd">
<xsl:copy><xsl:apply-templates/></xsl:copy>
</xsl:template>
<xsl:template match="item/image">
<!-- Nothing to do here, see above... -->
</xsl:template>
<xsl:template match="image">
<xsl:element name="img">
<xsl:attribute name="src"><xsl:value-of select="."/></xsl:attribute>
<xsl:attribute name="title"><xsl:value-of select="@title"/></xsl:attribute>
<xsl:attribute name="alt"><xsl:value-of select="@title"/></xsl:attribute>
<xsl:attribute name="class"><xsl:value-of select="@class"/></xsl:attribute>
</xsl:element>
</xsl:template>
<xsl:template match="link">
<xsl:element name="a">
<xsl:choose>
<xsl:when test="@href">
<xsl:attribute name="href"><xsl:value-of select="@href"/></xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="href"><xsl:value-of select="."/></xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="em">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template name="navitem">
<xsl:param name="file"/>
<li>