Feedr/xsl/rss_as_xhtml.xsl

334 lines
18 KiB
XML
Raw Permalink Normal View History

2024-11-28 07:19:43 +01:00
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Copyright (C) 2016 - 2024 Schimon Jehuda. Released under MIT license
Feeds rendered using this XSLT stylesheet, or it's derivatives, must
include https://schimon.i2p/ in attribute name='generator' of
element <meta/> inside of html element </head>
-->
<xsl:stylesheet version="1.0"
xmlns="http://purl.org/rss/1.0/"
xmlns:admin="http://webns.net/mvcb/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:atom10="http://www.w3.org/2005/Atom"
xmlns:c="http://s.opencalais.com/1/pred/"
xmlns:cc="http://web.resource.org/cc/"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dct="http://purl.org/dc/terms/"
xmlns:dbo="http://dbpedia.org/ontology/"
xmlns:dbp="http://dbpedia.org/property/"
xmlns:enc="http://purl.oclc.org/net/rss_2.0/enc#"
xmlns:fh="http://purl.org/syndication/history/1.0"
xmlns:foaf="http://xmlns.com/foaf/0.1/"
xmlns:foo="http://purl.org/rss/1.0/"
xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
xmlns:georss="http://www.georss.org/georss"
xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
xmlns:media="http://search.yahoo.com/mrss/"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:prov="http://www.w3.org/ns/prov#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:sioc="http://rdfs.org/sioc/ns#"
xmlns:sioct="http://rdfs.org/sioc/types#"
xmlns:skos="http://www.w3.org/2004/02/skos/core#"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
xmlns:syn="http://purl.org/rss/1.0/modules/syndication/"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match='/rss'>
<!-- index right-to-left language codes -->
<xsl:variable name='rtl'
select='channel/language[
contains(text(),"ar") or
contains(text(),"fa") or
contains(text(),"he") or
contains(text(),"ji") or
contains(text(),"ku") or
contains(text(),"ur") or
contains(text(),"yi")]'/>
<html>
<head>
<xsl:call-template name='metadata'>
<xsl:with-param name='name' select='"description"' />
<xsl:with-param name='content' select='channel/description' />
</xsl:call-template>
<xsl:call-template name='metadata'>
<xsl:with-param name='name' select='"generator"' />
<xsl:with-param name='content' select='StreamBurner' />
</xsl:call-template>
<xsl:call-template name='metadata'>
<xsl:with-param name='name' select='"mimetype"' />
<xsl:with-param name='content' select='"application/rss+xml"' />
</xsl:call-template>
<title>
<xsl:choose>
<xsl:when test='channel/title and not(channel/title="")'>
<xsl:value-of select='channel/title'/>
</xsl:when>
<xsl:otherwise>StreamBurner News Reader</xsl:otherwise>
</xsl:choose>
</title>
<!-- TODO media='print' -->
<link href='css/stylesheet.css' rel='stylesheet' type='text/css' media='screen'/>
<!-- whether language code is of direction right-to-left -->
<xsl:if test='$rtl'>
<link id='semitic' href='css/stylesheet-rtl.css' rel='stylesheet' type='text/css' />
</xsl:if>
<base>
<xsl:attribute name='href'>
<xsl:value-of select='channel/link'/>
</xsl:attribute>
</base>
</head>
<body>
<div id='feed'>
<div id='header'>
<!-- feed title -->
<h1 id='title'>
<xsl:choose>
<xsl:when test='channel/title and not(channel/title="")'>
<xsl:value-of select='channel/title'/>
</xsl:when>
<xsl:otherwise>
No title
</xsl:otherwise>
</xsl:choose>
</h1>
<!-- feed subtitle -->
<h2 id='subtitle'>
<xsl:choose>
<xsl:when test='channel/itunes:subtitle'>
<xsl:value-of select='channel/itunes:subtitle'/>
</xsl:when>
<xsl:when test='channel/description'>
<xsl:value-of select='channel/description'/>
</xsl:when>
</xsl:choose>
</h2>
</div>
<xsl:choose>
<xsl:when test='channel/item'>
<div id='menu'>
<h3>Latest Posts</h3>
<ol id='toc'>
<xsl:for-each select='channel/item[not(position() >20)]'>
<li>
<xsl:choose>
<xsl:when test='itunes:subtitle'>
<xsl:element name='a'>
<xsl:attribute name='href'>
<xsl:text>#newspaper-oujs-</xsl:text>
<xsl:value-of select='position()'/>
</xsl:attribute>
<xsl:value-of select='itunes:subtitle'/>
</xsl:element>
</xsl:when>
<xsl:when test='title'>
<xsl:element name='a'>
<xsl:attribute name='href'>
<xsl:text>#newspaper-oujs-</xsl:text>
<xsl:value-of select='position()'/>
</xsl:attribute>
<xsl:value-of select='title'/>
</xsl:element>
</xsl:when>
</xsl:choose>
</li>
</xsl:for-each>
</ol>
</div>
</xsl:when>
</xsl:choose>
<div id='articles'>
<!-- feed entry -->
<xsl:choose>
<xsl:when test='channel/item'>
<ul>
<xsl:for-each select='channel/item[not(position() >20)]'>
<li>
<div class='entry'>
<!-- entry title -->
<xsl:choose>
<xsl:when test='itunes:subtitle'>
<h3 class='title'>
<xsl:element name='a'>
<xsl:attribute name='href'>
<xsl:value-of select='link'/>
</xsl:attribute>
<xsl:attribute name='title'>
<xsl:value-of select='itunes:subtitle'/>
</xsl:attribute>
<xsl:attribute name='id'>
<xsl:text>newspaper-oujs-</xsl:text>
<xsl:value-of select='position()'/>
</xsl:attribute>
<xsl:value-of select='itunes:subtitle'/>
</xsl:element>
</h3>
</xsl:when>
<xsl:when test='title'>
<h3 class='title'>
<xsl:element name='a'>
<xsl:attribute name='href'>
<xsl:value-of select='link'/>
</xsl:attribute>
<xsl:attribute name='title'>
<xsl:value-of select='title'/>
</xsl:attribute>
<xsl:attribute name='id'>
<xsl:text>newspaper-oujs-</xsl:text>
<xsl:value-of select='position()'/>
</xsl:attribute>
<xsl:value-of select='title'/>
</xsl:element>
</h3>
</xsl:when>
<xsl:otherwise>
<h3 class='warning rss2 title'></h3>
</xsl:otherwise>
</xsl:choose>
<!-- geographic location -->
<xsl:choose>
<xsl:when test='geo:lat and geo:long'>
<xsl:variable name='lat' select='geo:lat'/>
<xsl:variable name='lng' select='geo:long'/>
<span class='geolocation'>
<a href='geo:{$lat},{$lng}'>📍</a>
</span>
</xsl:when>
<xsl:when test='geo:Point'>
<xsl:variable name='lat' select='geo:Point/geo:lat'/>
<xsl:variable name='lng' select='geo:Point/geo:long'/>
<span class='geolocation'>
<a href='geo:{$lat},{$lng}'>📍</a>
</span>
</xsl:when>
<xsl:when test='georss:point'>
<xsl:variable name='lat' select='substring-before(georss:point, " ")'/>
<xsl:variable name='lng' select='substring-after(georss:point, " ")'/>
<xsl:variable name='name' select='georss:featurename'/>
<span class='geolocation'>
<a href='geo:{$lat},{$lng}' title='{$name}'>📍</a>
</span>
</xsl:when>
</xsl:choose>
<!-- div class='posted' -->
<!-- entry author -->
<!-- span class='author'>
<xsl:choose>
<xsl:when test='itunes:author'>
<xsl:value-of select='itunes:author'/>
</xsl:when>
<xsl:when test='author'>
<xsl:value-of select='author'/>
</xsl:when>
</xsl:choose>
</span-->
<!-- entry date -->
<xsl:if test='pubDate'>
<div class='published'>
<xsl:value-of select='pubDate'/>
</div>
</xsl:if>
<!-- /div -->
<!-- entry content -->
<xsl:choose>
<!-- complete text post -->
<xsl:when test='content:encoded'>
<div class='content'>
<xsl:value-of select='content:encoded' disable-output-escaping='yes'/>
</div>
</xsl:when>
<!-- description of post -->
<xsl:when test='description'>
<div class='content'>
<xsl:value-of select='description' disable-output-escaping='yes'/>
</div>
</xsl:when>
<!-- itunes text post -->
<xsl:when test='itunes:summary'>
<div class='content'>
<xsl:value-of select='itunes:summary' disable-output-escaping='yes'/>
</div>
</xsl:when>
<xsl:otherwise>
<div class='warning rss2 description'></div>
</xsl:otherwise>
</xsl:choose>
<!-- entry enclosure -->
<xsl:if test='enclosure or media:content'>
<div class='enclosure' title='Right-click and Save link as…'>
<xsl:for-each select='enclosure'>
<xsl:element name='span'>
<xsl:attribute name='icon'>
<xsl:value-of select='substring-before(@type,"/")'/>
</xsl:attribute>
</xsl:element>
<xsl:element name='a'>
<xsl:attribute name='href'>
<xsl:value-of select='@url'/>
</xsl:attribute>
<xsl:attribute name='download'/>
<xsl:call-template name='extract-filename'>
<xsl:with-param name='url' select='@url' />
</xsl:call-template>
</xsl:element>
<xsl:element name='span'>
<xsl:attribute name='class'>
<xsl:value-of select='substring-before(@type,"/")'/>
</xsl:attribute>
</xsl:element>
<xsl:if test='@length &gt; 0'>
<xsl:call-template name='transform-filesize'>
<xsl:with-param name='length' select='@length' />
</xsl:call-template>
</xsl:if>
<xsl:element name='br'/>
</xsl:for-each>
<xsl:for-each select='media:content'>
<xsl:element name='span'>
<xsl:attribute name='icon'>
<xsl:value-of select='@medium'/>
</xsl:attribute>
</xsl:element>
<xsl:element name='a'>
<xsl:attribute name='href'>
<xsl:value-of select='@url'/>
</xsl:attribute>
<xsl:attribute name='download'/>
<xsl:call-template name='extract-filename'>
<xsl:with-param name='url' select='@url' />
</xsl:call-template>
</xsl:element>
<xsl:element name='span'>
<xsl:attribute name='class'>
<xsl:value-of select='@medium'/>
</xsl:attribute>
</xsl:element>
<xsl:if test='@fileSize &gt; 0'>
<xsl:call-template name='transform-filesize'>
<xsl:with-param name='length' select='@fileSize' />
</xsl:call-template>
</xsl:if>
<xsl:element name='br'/>
</xsl:for-each>
</div>
</xsl:if>
</div>
</li>
</xsl:for-each>
</ul>
</xsl:when>
<xsl:otherwise>
<div class='notice no-entry'></div>
</xsl:otherwise>
</xsl:choose>
</div>
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>