1
0
mirror of https://github.com/aureliendavid/rsspreview.git synced 2025-08-22 19:28:39 +00:00

support for atom 0.3 (#15)

This commit is contained in:
Aurelien David 2019-01-12 18:16:36 +01:00
parent 87423fe45b
commit 0320efc780
3 changed files with 32 additions and 27 deletions

View File

@ -2,7 +2,7 @@
"manifest_version": 2, "manifest_version": 2,
"name": "RSSPreview", "name": "RSSPreview",
"version": "2.7", "version": "2.8",
"author": "Aurelien David", "author": "Aurelien David",
"homepage_url": "https://github.com/aureliendavid/rsspreview", "homepage_url": "https://github.com/aureliendavid/rsspreview",

43
rss.xsl
View File

@ -2,77 +2,76 @@
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:atom="http://www.w3.org/2005/Atom" xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:atom03="http://purl.org/atom/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rss1="http://purl.org/rss/1.0/" xmlns:rss1="http://purl.org/rss/1.0/"
xmlns:media="http://search.yahoo.com/mrss/" xmlns:media="http://search.yahoo.com/mrss/"
exclude-result-prefixes="atom rdf rss1 media" > exclude-result-prefixes="atom atom03 rdf rss1 media" >
<xsl:output method="html" indent="yes" encoding="utf-8" /> <xsl:output method="html" indent="yes" encoding="utf-8" />
<xsl:template match="channel | atom:feed | rss1:channel"> <xsl:template match="channel | atom:feed | atom03:feed | rss1:channel">
<div id="feedTitle"> <div id="feedTitle">
<a id="feedTitleLink"> <a id="feedTitleLink">
<img id="feedTitleImage" src="{image/url | atom:logo | rss1:image/rss1:url }" /> <img id="feedTitleImage" src="{image/url | atom:logo | atom03:logo | rss1:image/rss1:url }" />
</a> </a>
<div id="feedTitleContainer"> <div id="feedTitleContainer">
<h1 id="feedTitleText" > <h1 id="feedTitleText" >
<a href="{link | atom:link[@rel='alternate']/@href | rss1:link}" target="_blank"> <a href="{link | atom:link[@rel='alternate']/@href | atom03:link[@rel='alternate']/@href | rss1:link}" target="_blank">
<!--img data-src="icons/home.png" class="extImg headerIcon" /--> <xsl:value-of select="title | atom:title | atom03:title | rss1:title" />
<xsl:value-of select="title | atom:title | rss1:title" />
</a> </a>
</h1> </h1>
<h2 id="feedSubtitleRaw" ><xsl:value-of select="description | atom:subtitle | rss1:description" /></h2> <h2 id="feedSubtitleRaw" ><xsl:value-of select="description | atom:subtitle | atom03:subtitle | rss1:description" /></h2>
<!--div class="lastUpdated">Last updated: <xsl:value-of select="lastBuildDate | atom:updated" /></div-->
</div> </div>
</div> </div>
<div id="feedContent"> <div id="feedContent">
<xsl:apply-templates select="item | atom:entry " /> <xsl:apply-templates select="item | atom:entry | atom03:entry " />
</div> </div>
</xsl:template> </xsl:template>
<xsl:template match="item | atom:entry | rss1:item"> <xsl:template match="item | atom:entry | atom03:entry | rss1:item">
<div class="entry"> <div class="entry">
<h3> <h3>
<xsl:choose> <xsl:choose>
<xsl:when test="link | atom:link/@href | rss1:link"> <xsl:when test="link | atom:link/@href | atom03:link/@href | rss1:link">
<a href="{link | atom:link/@href | rss1:link}" target="_blank"> <a href="{link | atom:link/@href | atom03:link/@href | rss1:link}" target="_blank">
<span class="entrytitle"><xsl:value-of select="title | atom:title | rss1:title" /></span> <span class="entrytitle"><xsl:value-of select="title | atom:title | atom03:title | rss1:title" /></span>
</a> </a>
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
<span class="entrytitle"><xsl:value-of select="title | atom:title | rss1:link" /></span> <span class="entrytitle"><xsl:value-of select="title | atom:title | atom03:title | rss1:link" /></span>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
<div class="lastUpdated"><xsl:value-of select="pubDate | atom:updated | rss1:pubDate" /></div> <div class="lastUpdated"><xsl:value-of select="pubDate | atom:updated | atom03:updated | rss1:pubDate" /></div>
</h3> </h3>
<xsl:if test='.//media:thumbnail/@url'> <xsl:if test='.//media:thumbnail/@url'>
<img class="mediaThumb" src="{ .//media:thumbnail/@url }" width="{ .//media:thumbnail/@width }" height="{ .//media:thumbnail/@height }" /> <img class="mediaThumb" src="{ .//media:thumbnail/@url }" width="{ .//media:thumbnail/@width }" height="{ .//media:thumbnail/@height }" />
</xsl:if> </xsl:if>
<xsl:choose> <xsl:choose>
<xsl:when test="atom:summary"> <xsl:when test="atom:summary | atom03:summary">
<div class="feedRawContent" desctype="{atom:summary/@type}"> <div class="feedRawContent" desctype="{atom:summary/@type | atom03:summary/@type }">
<xsl:copy-of select="atom:summary" /> <xsl:copy-of select="atom:summary | atom03:summary" />
</div> </div>
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
<div class="feedRawContent" desctype="{atom:content/@type}"> <div class="feedRawContent" desctype="{atom:content/@type | atom03:content/@type }">
<xsl:copy-of select="description | atom:content | rss1:description" /> <xsl:copy-of select="description | atom:content | atom03:content | rss1:description" />
</div> </div>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
<div class="enclosures"> <div class="enclosures">
<xsl:for-each select="enclosure | atom:link[@rel='enclosure'] | rss1:enclosure"> <xsl:for-each select="enclosure | atom:link[@rel='enclosure'] | atom03:link[@rel='enclosure'] | rss1:enclosure">
<div class="enclosure"> <div class="enclosure">
<img data-src="icons/file.png" class="extImg enclosureIcon" /> <img data-src="icons/file.png" class="extImg enclosureIcon" />
@ -90,7 +89,7 @@
<xsl:template match="/"> <xsl:template match="/">
<xsl:apply-templates select="//channel | //atom:feed | //rss1:channel " /> <xsl:apply-templates select="//channel | //atom:feed | //atom03:feed | //rss1:channel " />
<xsl:apply-templates select="//rss1:item " /> <xsl:apply-templates select="//rss1:item " />
</xsl:template> </xsl:template>

View File

@ -75,10 +75,16 @@
// in case of xhtml the content is already parsed // in case of xhtml the content is already parsed
if (tohtml[i].getAttribute('desctype') != 'xhtml') { if (tohtml[i].getAttribute('desctype') != 'xhtml') {
try { try {
let html_desc = html_parser.parseFromString(
'<div class="feedEntryContent">' + tohtml[i].innerText + '</div>', let html_txt = '';
'text/html' if (tohtml[i].getAttribute('desctype') == 'text/plain') {
); html_txt = '<div class="feedEntryContent" style="white-space: pre-wrap;" >' + tohtml[i].innerHTML + '</div>';
}
else {
html_txt = '<div class="feedEntryContent">' + tohtml[i].innerText + '</div>';
}
let html_desc = html_parser.parseFromString(html_txt, 'text/html');
let xml_desc = xml_parser.serializeToString( let xml_desc = xml_parser.serializeToString(
html_desc.body.firstChild html_desc.body.firstChild
); );