c3d2-web/xsl/podcast.xsl

319 lines
13 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- Spezifikation:
http://www.apple.com/itunes/store/podcaststechspecs.html
-->
<xsl:stylesheet version="1.0"
xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:date="http://exslt.org/dates-and-times"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:atom="http://www.w3.org/2005/Atom"
exclude-result-prefixes="xsl date">
<xsl:output method="xml"
version="1.0"
encoding="utf-8"
indent="yes"/>
<xsl:include href="common.xsl" />
<xsl:variable name="baseurl">http://www.c3d2.de/</xsl:variable>
<xsl:param name="selection" select="''"/>
<xsl:param name="format"/>
<xsl:param name="archivefeed"/>
<xsl:template match="news">
<rss version="2.0">
<channel>
<xsl:choose>
<xsl:when test="$selection = 'pentamedia'">
<title>Penta*</title>
<link><xsl:value-of select="$baseurl"/></link>
<description>Pentaradio, Pentacast, Pentamusic</description>
<language>de</language>
<copyright>http://creativecommons.org/licenses/by-sa/2.0/de/</copyright>
<image>
<title>Pentaradio</title>
<url><xsl:value-of select="$baseurl"/>images/pentaradio-quadratic.png</url>
<link><xsl:value-of select="$baseurl"/>radio.html</link>
</image>
<itunes:subtitle>Die drei Podcasts vom CCC Dresden</itunes:subtitle>
<itunes:summary>
Enthält Podcasts von Pentaradio, Pentacast und Pentamusic
</itunes:summary>
<itunes:image href="{$baseurl}images/pentaradio-quadratic.png" />
<itunes:category text="Society &amp; Culture"/>
<itunes:category text="Technology">
<itunes:category text="Tech News"/>
</itunes:category>
<atom:link rel="payment" href="https://flattr.com/thing/51034/Pentaradio-24" type="text/html"/>
</xsl:when>
<xsl:when test="$selection = 'pentaradio'">
<title>Pentaradio</title>
<link><xsl:value-of select="$baseurl"/>radio.html</link>
<description>C3D2 Pentaradio</description>
<language>de</language>
<copyright>http://creativecommons.org/licenses/by-sa/2.0/de/</copyright>
<image>
<title>Pentaradio</title>
<url><xsl:value-of select="$baseurl"/>images/pentaradio-quadratic.png</url>
<link><xsl:value-of select="$baseurl"/>radio.html</link>
</image>
<itunes:subtitle>Radio vom CCC Dresden</itunes:subtitle>
<itunes:summary>
Pentaradio sind die Sendungen des Chaos Computer Club Dresden auf coloRadio, bestehend aus einem informativen Rahmenprogramm und Beiträgen zu einem sendungsspezifischen Thema.
</itunes:summary>
<itunes:image href="{$baseurl}images/pentaradio-quadratic.png" />
<itunes:category text="Society &amp; Culture"/>
<itunes:category text="Technology">
<itunes:category text="Tech News"/>
</itunes:category>
<atom:link rel="payment" href="https://flattr.com/thing/51034/Pentaradio-24" type="text/html"/>
</xsl:when>
<xsl:when test="$selection = 'pentacast'">
<title>Pentacast</title>
<link><xsl:value-of select="$baseurl"/>podcast.html</link>
<description>C3D2 Pentacast</description>
<language>de</language>
<copyright>http://creativecommons.org/licenses/by-sa/2.0/de/</copyright>
<image>
<title>Pentacast</title>
<url><xsl:value-of select="$baseurl"/>images/pentacast-quadratic.png</url>
<link><xsl:value-of select="$baseurl"/>podcast.html</link>
</image>
<itunes:subtitle>Podcasts vom CCC Dresden</itunes:subtitle>
<itunes:summary>
Pentacast sind themenspezifische Sendungen des Chaos
Computer Club Dresden.
</itunes:summary>
<itunes:image href="{$baseurl}images/pentacast-quadratic.png" />
<itunes:category text="Society &amp; Culture"/>
<itunes:category text="Technology"/>
<atom:link rel="payment" href="https://flattr.com/thing/51037/Pentacast" type="text/html"/>
</xsl:when>
<xsl:when test="$selection = 'pentamusic'">
<title>Pentamusic</title>
<link><xsl:value-of select="$baseurl"/>pentamusic.html</link>
<description>C3D2 Pentamusic</description>
<language>de</language>
<copyright>http://creativecommons.org/licenses/by-sa/2.0/de/</copyright>
<image>
<title>Pentamusic</title>
<url><xsl:value-of select="$baseurl"/>images/pentamusic-quadratic.png</url>
<link><xsl:value-of select="$baseurl"/>pentamusic.html</link>
</image>
<itunes:subtitle>Musikvorstellungen vom CCC Dresden</itunes:subtitle>
<itunes:summary>
Versuch, Künstler, Bands und Labels der CC-Szene vors
Mikro zu holen um diese einer breiteren Öffentlichkeit
bekannt zu machen.
</itunes:summary>
<itunes:image href="{$baseurl}images/pentamusic-quadratic.png" />
<itunes:category text="Society &amp; Culture"/>
<itunes:category text="Music"/>
<atom:link rel="payment" href="https://flattr.com/thing/51039/Pentamusic" type="text/html"/>
</xsl:when>
<xsl:otherwise>
<title>C3D2 Podcast</title>
<link><xsl:value-of select="$baseurl"/></link>
<description>C3D2 Podcast</description>
<language>de</language>
<copyright>http://creativecommons.org/licenses/by-sa/2.0/de/</copyright>
<image>
<title>C3D2</title>
<url><xsl:value-of select="$baseurl"/>images/ck.png</url>
<link><xsl:value-of select="$baseurl"/></link>
</image>
<itunes:subtitle>Radio &amp; Podcasts vom CCC Dresden</itunes:subtitle>
<itunes:summary>
Pentaradio, Pentacast &amp; Pentamusic vom Chaos Computer Club Dresden.
</itunes:summary>
<itunes:image href="{$baseurl}images/ck.png" />
<itunes:category text="Society &amp; Culture"/>
<itunes:category text="Technology"/>
<atom:link rel="payment" href="https://flattr.com/thing/51034/Pentaradio-24" type="text/html"/>
</xsl:otherwise>
</xsl:choose>
<itunes:author>Chaos Computer Club Dresden</itunes:author>
<itunes:owner>
<itunes:name>C3D2</itunes:name>
<itunes:email>mail@c3d2.de</itunes:email>
</itunes:owner>
<xsl:if test="$archivefeed">
<atom:link rel="prev-archive" href="{$archivefeed}"/>
</xsl:if>
<xsl:for-each select="newsfile">
<xsl:sort select="date:seconds(document(.)/item/@date)" data-type="number" order="descending" />
<xsl:if test="position() &lt;= $maxitems">
<xsl:choose>
<xsl:when test="($selection = 'pentaradio' or $selection = 'pentamedia') and
starts-with(., 'content/news/pentaradio') and
count(document(.)/item//resource) &gt; 0">
<xsl:apply-templates select="document(.)/item//resource" mode="preselect">
<xsl:with-param name="newsfile" select="."/>
</xsl:apply-templates>
</xsl:when>
<xsl:when test="($selection = 'pentacast' or $selection = 'pentamedia') and
starts-with(., 'content/news/pentacast') and
count(document(.)/item//resource) &gt; 0">
<xsl:apply-templates select="document(.)/item//resource" mode="preselect">
<xsl:with-param name="newsfile" select="."/>
</xsl:apply-templates>
</xsl:when>
<xsl:when test="($selection = 'pentamusic' or $selection = 'pentamedia') and
starts-with(., 'content/news/pentamusic') and
count(document(.)/item//resource) &gt; 0">
<xsl:apply-templates select="document(.)/item//resource" mode="preselect">
<xsl:with-param name="newsfile" select="."/>
</xsl:apply-templates>
</xsl:when>
<xsl:when test="$selection = '' and count(document(.)/item//resource) &gt; 0">
<xsl:apply-templates select="document(.)/item//resource" mode="preselect">
<xsl:with-param name="newsfile" select="."/>
</xsl:apply-templates>
</xsl:when>
</xsl:choose>
</xsl:if>
</xsl:for-each>
</channel>
</rss>
</xsl:template>
<!-- Preselect heißt:
* Gucken, ob es in der Resource nicht ein Alternative gibt, welches $format ist
* Dann dieses nehmen
* Ansonsten die Resource nehmen
-->
<xsl:template match="resource" mode="preselect">
<xsl:param name="newsfile"/>
<xsl:choose>
<!-- Gibts ein $format? -->
<xsl:when test="count(alternative[contains($format, @type)]) &gt; 0">
<xsl:apply-templates select="alternative[contains($format, @type)]">
<xsl:with-param name="newsfile" select="$newsfile"/>
</xsl:apply-templates>
</xsl:when>
<!-- Nimm was da ist -->
<xsl:otherwise>
<xsl:apply-templates select=".">
<xsl:with-param name="newsfile" select="$newsfile"/>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="*[name() = 'resource' or name() = 'alternative']">
<xsl:param name="newsfile"/>
<xsl:variable name="href">
<xsl:call-template name="make-href">
<xsl:with-param name="href" select="@url"/>
</xsl:call-template>
</xsl:variable>
<xsl:call-template name="generate-item">
<xsl:with-param name="newsfile" select="$newsfile"/>
<xsl:with-param name="item_title">
<xsl:value-of select="document($newsfile)/item/@title"/>
<xsl:if test="count(document($newsfile)//resource) &gt; 1 and @title">
<!-- Multiple resources in this item? -->
<xsl:text>: </xsl:text>
<xsl:value-of select="@title"/>
</xsl:if>
</xsl:with-param>
<xsl:with-param name="resource_title">
<xsl:choose>
<xsl:when test="@title"><xsl:value-of select="@title"/></xsl:when>
<xsl:otherwise><xsl:value-of select="../@title"/></xsl:otherwise>
</xsl:choose>
</xsl:with-param>
<xsl:with-param name="date" select="document($newsfile)/item/@date"/>
<xsl:with-param name="resource_url" select="$href"/>
<xsl:with-param name="resource_size" select="@size"/>
<xsl:with-param name="resource_type" select="@type"/>
<xsl:with-param name="chapters" select="sc:chapters"
xmlns:sc="http://podlove.de/simple-chapters"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="generate-item">
<xsl:param name="newsfile"/>
<xsl:param name="item_title"/>
<xsl:param name="resource_title"/>
<xsl:param name="date"/>
<xsl:param name="resource_url"/>
<xsl:param name="resource_size"/>
<xsl:param name="resource_type"/>
<xsl:param name="chapters"/>
<item>
<xsl:variable name="href">
<xsl:value-of select="$baseurl"/>
<xsl:value-of select="substring-before(substring-after($newsfile, 'content/'), '.xml')"/>
<xsl:text>.html</xsl:text>
</xsl:variable>
<title><xsl:value-of select="$item_title"/></title>
<description>
<xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
<div xmlns="http://www.w3.org/1999/xhtml">
<xsl:apply-templates select="document($newsfile)/item/*[name() != 'resource']"/>
</div>
<xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
</description>
<link><xsl:value-of select="$href"/></link>
<enclosure
url="{$resource_url}"
length="{$resource_size}"
type="{$resource_type}"
/>
<guid isPermaLink="false"><xsl:value-of select="concat($href, '+++', $resource_url)"/></guid>
<pubDate>
<xsl:call-template name="date-to-rfc822">
<xsl:with-param name="date" select="$date"/>
</xsl:call-template>
</pubDate>
<content:encoded>
<xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
<div xmlns="http://www.w3.org/1999/xhtml">
<xsl:apply-templates select="document($newsfile)/item/*[name() != 'resource']"/>
</div>
<xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
</content:encoded>
<!-- iTunes-Extensions zum Schluss, sonst validiert es nicht -->
<itunes:subtitle><xsl:value-of select="$resource_title"/></itunes:subtitle>
<itunes:author>CCC Dresden</itunes:author>
<xsl:variable name="flattr_link">
<xsl:call-template name="make-flattr-link">
<xsl:with-param name="newsfile" select="$newsfile"/>
</xsl:call-template>
</xsl:variable>
<xsl:if test="string-length($flattr_link) &gt; 0">
<atom:link rel="payment" href="{$flattr_link}" type="text/html"/>
</xsl:if>
<xsl:copy-of select="$chapters"/>
</item>
</xsl:template>
<xsl:template match="addendum">
<xsl:apply-templates select="*[name() != 'resource']"/>
</xsl:template>
</xsl:stylesheet>