mirror of
https://github.com/aureliendavid/rsspreview.git
synced 2025-08-22 19:28:39 +00:00
added feed url + support of rss 1.0
This commit is contained in:
parent
8a66512945
commit
17bfb2058d
BIN
icons/home.png
Normal file
BIN
icons/home.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 875 B |
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "RSSPreview",
|
"name": "RSSPreview",
|
||||||
"version": "1.1",
|
"version": "1.2",
|
||||||
"author": "Aurelien David",
|
"author": "Aurelien David",
|
||||||
"homepage_url": "https://github.com/aureliendavid/rsspreview",
|
"homepage_url": "https://github.com/aureliendavid/rsspreview",
|
||||||
|
|
||||||
@ -29,7 +29,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
"web_accessible_resources": ["preview.html", "preview.js", "preview.css", "rss.xsl", "icons/file.png"],
|
"web_accessible_resources": ["preview.html", "preview.js", "preview.css", "rss.xsl", "icons/*.png"],
|
||||||
|
|
||||||
"permissions": ["<all_urls>", "webRequest", "webRequestBlocking"]
|
"permissions": ["<all_urls>", "webRequest", "webRequestBlocking"]
|
||||||
|
|
||||||
|
@ -114,3 +114,10 @@ a[href] img {
|
|||||||
width: 16px;
|
width: 16px;
|
||||||
margin-right: 3px;
|
margin-right: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.headerIcon {
|
||||||
|
vertical-align: bottom;
|
||||||
|
height: 25px;
|
||||||
|
width: 25px;
|
||||||
|
margin-right: 2px;
|
||||||
|
}
|
@ -106,6 +106,13 @@ function formatfilesizes() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function addfeedurl(url) {
|
||||||
|
|
||||||
|
var h1 = document.getElementById("feedTitleText");
|
||||||
|
h1.innerHTML += ' :: <a href="'+url+'"><img src="icons/rss-32.png" class="headerIcon" />Feed URL</a>';
|
||||||
|
}
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
|
|
||||||
var query_string = location.search.substring(1).split("&");
|
var query_string = location.search.substring(1).split("&");
|
||||||
@ -122,6 +129,7 @@ function main() {
|
|||||||
formatdescriptions();
|
formatdescriptions();
|
||||||
formatfilenames();
|
formatfilenames();
|
||||||
formatfilesizes();
|
formatfilesizes();
|
||||||
|
addfeedurl(feed_url);
|
||||||
|
|
||||||
document.title = "RSSPreview: " + document.getElementById("feedTitleText").innerText;
|
document.title = "RSSPreview: " + document.getElementById("feedTitleText").innerText;
|
||||||
|
|
||||||
|
97
rss.xsl
97
rss.xsl
@ -1,77 +1,82 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<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" exclude-result-prefixes="atom" >
|
xmlns:atom="http://www.w3.org/2005/Atom"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:rss1="http://purl.org/rss/1.0/"
|
||||||
|
exclude-result-prefixes="atom rdf" >
|
||||||
|
|
||||||
<xsl:output method="html" indent="yes" encoding="utf-8" />
|
<xsl:output method="html" indent="yes" encoding="utf-8" />
|
||||||
|
|
||||||
|
|
||||||
<xsl:template match="channel | atom:feed">
|
<xsl:template match="channel | atom:feed | rss1:channel">
|
||||||
|
|
||||||
|
|
||||||
<div id="feedTitle">
|
<div id="feedTitle">
|
||||||
<a id="feedTitleLink">
|
<a id="feedTitleLink">
|
||||||
<img id="feedTitleImage" src="{image/url | atom:logo}" />
|
<img id="feedTitleImage" src="{image/url | atom: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}" target="_blank">
|
<a href="{link | atom:link[@rel='alternate']/@href | rss1:link}" target="_blank">
|
||||||
<xsl:value-of select="title | atom:title" />
|
<img src="icons/home.png" class="headerIcon" />
|
||||||
|
<xsl:value-of select="title | atom:title | rss1:title" />
|
||||||
</a>
|
</a>
|
||||||
</h1>
|
</h1>
|
||||||
<h2 id="feedSubtitleText" ><xsl:value-of select="description | atom:subtitle" /></h2>
|
<h2 id="feedSubtitleText" ><xsl:value-of select="description | atom:subtitle | rss1:description" /></h2>
|
||||||
<!--div class="lastUpdated">Last updated: <xsl:value-of select="lastBuildDate | atom:updated" /></div-->
|
<!--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:for-each select="item | atom:entry">
|
|
||||||
|
|
||||||
<div class="entry">
|
|
||||||
|
|
||||||
<h3>
|
|
||||||
<xsl:choose>
|
|
||||||
<xsl:when test="link | atom:link[@rel='alternate']/@href">
|
|
||||||
<a href="{link | atom:link[@rel='alternate']/@href}" target="_blank">
|
|
||||||
<span><xsl:value-of select="title | atom:title" /></span>
|
|
||||||
</a>
|
|
||||||
</xsl:when>
|
|
||||||
<xsl:otherwise>
|
|
||||||
<span><xsl:value-of select="title | atom:title" /></span>
|
|
||||||
</xsl:otherwise>
|
|
||||||
</xsl:choose>
|
|
||||||
|
|
||||||
<div class="lastUpdated"><xsl:value-of select="pubDate | atom:updated" /></div>
|
|
||||||
</h3>
|
|
||||||
<div class="feedEntryContent">
|
|
||||||
<xsl:value-of select="description | atom:summary" disable-output-escaping="yes" />
|
|
||||||
</div>
|
|
||||||
<div class="enclosures">
|
|
||||||
<xsl:for-each select="enclosure | atom:link[@rel='enclosure']">
|
|
||||||
|
|
||||||
<div class="enclosure">
|
|
||||||
<img src="icons/file.png" class="enclosureIcon" />
|
|
||||||
<a href="{@url | @href}" target="_blank" class="enclosureFilename"><xsl:value-of select="@url | @href" /></a>
|
|
||||||
(<xsl:value-of select="@type" />, <span class="enclosureSize"><xsl:value-of select="@length" /></span>)
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</xsl:for-each>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div style="clear: both;"></div>
|
|
||||||
|
|
||||||
</xsl:for-each>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
|
<xsl:template match="item | atom:entry | rss1:item">
|
||||||
|
|
||||||
|
<div class="entry">
|
||||||
|
|
||||||
|
<h3>
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="link | atom:link[@rel='alternate']/@href | rss1:link">
|
||||||
|
<a href="{link | atom:link[@rel='alternate']/@href | rss1:link}" target="_blank">
|
||||||
|
<span><xsl:value-of select="title | atom:title | rss1:title" /></span>
|
||||||
|
</a>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
<span><xsl:value-of select="title | atom:title | rss1:link" /></span>
|
||||||
|
</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
|
||||||
|
<div class="lastUpdated"><xsl:value-of select="pubDate | atom:updated | rss1:pubDate" /></div>
|
||||||
|
</h3>
|
||||||
|
<div class="feedEntryContent">
|
||||||
|
<xsl:value-of select="description | atom:summary | rss1:description" disable-output-escaping="yes" />
|
||||||
|
</div>
|
||||||
|
<div class="enclosures">
|
||||||
|
<xsl:for-each select="enclosure | atom:link[@rel='enclosure'] | rss1:enclosure">
|
||||||
|
|
||||||
|
<div class="enclosure">
|
||||||
|
<img src="icons/file.png" class="enclosureIcon" />
|
||||||
|
<a href="{@url | @href}" target="_blank" class="enclosureFilename"><xsl:value-of select="@url | @href" /></a>
|
||||||
|
(<xsl:value-of select="@type" />, <span class="enclosureSize"><xsl:value-of select="@length" /></span>)
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</xsl:for-each>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div style="clear: both;"></div>
|
||||||
|
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
|
||||||
<xsl:template match="/">
|
<xsl:template match="/">
|
||||||
<xsl:apply-templates select="//channel | //atom:feed" />
|
<xsl:apply-templates select="//channel | //atom:feed | //rss1:channel " />
|
||||||
|
<xsl:apply-templates select="//rss1:item " />
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
</xsl:stylesheet>
|
</xsl:stylesheet>
|
||||||
|
@ -10,10 +10,20 @@
|
|||||||
}
|
}
|
||||||
window.hasRun = true;
|
window.hasRun = true;
|
||||||
|
|
||||||
const rootName = document.getRootNode().documentElement.nodeName;
|
const rootName = document.getRootNode().documentElement.nodeName.toLowerCase();
|
||||||
|
|
||||||
|
|
||||||
if (rootName == "rss" || rootName == "channel" || rootName == "feed") {
|
var isRSS1 = false;
|
||||||
|
if (rootName == "rdf" || rootName == "rdf:rdf") {
|
||||||
|
if (document.getRootNode().documentElement.attributes['xmlns']) {
|
||||||
|
isRSS1 = (document.getRootNode().documentElement.attributes['xmlns'].nodeValue.search('rss') > 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ( rootName == "rss" || rootName == "channel" // rss2
|
||||||
|
|| rootName == "feed" // atom
|
||||||
|
|| isRSS1 ) {
|
||||||
|
|
||||||
var feed_url = window.location.href;
|
var feed_url = window.location.href;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user