mirror of
https://github.com/LightAir/turbo-rss.git
synced 2026-02-04 12:06:20 +00:00
@@ -11,6 +11,7 @@ function RSS (options, items) {
|
||||
|
||||
this.title = options.title || 'Untitled RSS Feed';
|
||||
this.description = options.description || '';
|
||||
this.generator = options.generator || 'NodeJS RSS Module';
|
||||
this.feed_url = options.feed_url;
|
||||
this.site_url = options.site_url;
|
||||
this.image_url = options.image_url;
|
||||
@@ -66,7 +67,7 @@ function generateXML (data){
|
||||
if (data.image_url) {
|
||||
channel.push({ image: [ {url: data.image_url}, {title: data.title}, {link: data.site_url} ] });
|
||||
}
|
||||
channel.push({ generator: 'NodeJS RSS Module' });
|
||||
channel.push({ generator: data.generator });
|
||||
channel.push({ lastBuildDate: new Date().toGMTString() });
|
||||
|
||||
ifTruePush(data.feed_url, channel, { 'atom:link': { _attr: { href: data.feed_url, rel: 'self', type: 'application/rss+xml' } } });
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "rss",
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.1",
|
||||
"description": "RSS feed generator. A really simple API to add RSS feeds to any project.",
|
||||
"homepage": "http://github.com/dylang/node-rss",
|
||||
"author": "Dylan Greene <dylang@gmail.com>",
|
||||
@@ -9,7 +9,8 @@
|
||||
"Xavier Damman <xdamman@gmail.com>",
|
||||
"Michael R. Lange",
|
||||
"Victor Jonsson",
|
||||
"Danny Graham"
|
||||
"Danny Graham",
|
||||
"Patrick Garman <contact@pmgarman.me>"
|
||||
],
|
||||
"repository":
|
||||
{
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
|
||||
* _title_ <string> Title of your site or feed
|
||||
* _description_ <string> Optional. Short description of the feed.
|
||||
* _generator_ <string> Optional. Feed generator.
|
||||
* _feed_url_ <url> Url to the rss feed.
|
||||
* _site_url_ <url> Url to the site that the feed is for.
|
||||
* _image_url_ <url> Optional. Small image for feed readers to use.
|
||||
|
||||
@@ -19,6 +19,7 @@ module.exports = {
|
||||
var feed = new RSS({
|
||||
title: 'title',
|
||||
description: 'description',
|
||||
generator: 'Example Generator',
|
||||
feed_url: 'http://example.com/rss.xml',
|
||||
site_url: 'http://example.com',
|
||||
image_url: 'http://example.com/icon.png',
|
||||
@@ -68,7 +69,7 @@ module.exports = {
|
||||
date: 'May 28, 2012 04:00:00 GMT'
|
||||
});
|
||||
|
||||
var expectedResult = '<?xml version="1.0" encoding="UTF-8"?>\n<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[title]]></title><description><![CDATA[description]]></description><link>http://example.com</link><image><url>http://example.com/icon.png</url><title>title</title><link>http://example.com</link></image><generator>NodeJS RSS Module</generator><lastBuildDate>' + new Date().toUTCString() +'</lastBuildDate><atom:link href="http://example.com/rss.xml" rel="self" type="application/rss+xml"/><author><![CDATA[Dylan Greene]]></author><pubDate>Sun, 20 May 2012 04:00:00 GMT</pubDate><copyright><![CDATA[2013 Dylan Green]]></copyright><language><![CDATA[en]]></language><managingEditor><![CDATA[Dylan Green]]></managingEditor><webMaster><![CDATA[Dylan Green]]></webMaster><docs>http://example.com/rss/docs.html</docs><ttl>60</ttl><category><![CDATA[Category 1]]></category><category><![CDATA[Category 2]]></category><category><![CDATA[Category 3]]></category><item><title><![CDATA[item 1]]></title><description><![CDATA[description 1]]></description><link>http://example.com/article1</link><guid isPermaLink="true">http://example.com/article1</guid><dc:creator><![CDATA[Dylan Greene]]></dc:creator><pubDate>Thu, 24 May 2012 04:00:00 GMT</pubDate></item><item><title><![CDATA[item 2]]></title><description><![CDATA[description 2]]></description><link>http://example.com/article2</link><guid isPermaLink="true">http://example.com/article2</guid><dc:creator><![CDATA[Dylan Greene]]></dc:creator><pubDate>Fri, 25 May 2012 04:00:00 GMT</pubDate></item><item><title><![CDATA[item 3]]></title><description><![CDATA[description 3]]></description><link>http://example.com/article3</link><guid isPermaLink="false">item3</guid><dc:creator><![CDATA[Dylan Greene]]></dc:creator><pubDate>Sat, 26 May 2012 04:00:00 GMT</pubDate></item><item><title><![CDATA[item 4 & html test with <strong>]]></title><description><![CDATA[description 4 uses some <strong>html</strong>]]></description><link>http://example.com/article4?this&that</link><guid isPermaLink="true">http://example.com/article4?this&that</guid><dc:creator><![CDATA[Guest Author]]></dc:creator><pubDate>Sun, 27 May 2012 04:00:00 GMT</pubDate></item><item><title><![CDATA[item 5 & test for categories]]></title><description><![CDATA[description 5]]></description><link>http://example.com/article5</link><guid isPermaLink="true">http://example.com/article5</guid><category><![CDATA[Category 1]]></category><category><![CDATA[Category 2]]></category><category><![CDATA[Category 3]]></category><category><![CDATA[Category 4]]></category><dc:creator><![CDATA[Guest Author]]></dc:creator><pubDate>Mon, 28 May 2012 04:00:00 GMT</pubDate></item></channel></rss>';
|
||||
var expectedResult = '<?xml version="1.0" encoding="UTF-8"?>\n<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[title]]></title><description><![CDATA[description]]></description><link>http://example.com</link><image><url>http://example.com/icon.png</url><title>title</title><link>http://example.com</link></image><generator>Example Generator</generator><lastBuildDate>' + new Date().toUTCString() +'</lastBuildDate><atom:link href="http://example.com/rss.xml" rel="self" type="application/rss+xml"/><author><![CDATA[Dylan Greene]]></author><pubDate>Sun, 20 May 2012 04:00:00 GMT</pubDate><copyright><![CDATA[2013 Dylan Green]]></copyright><language><![CDATA[en]]></language><managingEditor><![CDATA[Dylan Green]]></managingEditor><webMaster><![CDATA[Dylan Green]]></webMaster><docs>http://example.com/rss/docs.html</docs><ttl>60</ttl><category><![CDATA[Category 1]]></category><category><![CDATA[Category 2]]></category><category><![CDATA[Category 3]]></category><item><title><![CDATA[item 1]]></title><description><![CDATA[description 1]]></description><link>http://example.com/article1</link><guid isPermaLink="true">http://example.com/article1</guid><dc:creator><![CDATA[Dylan Greene]]></dc:creator><pubDate>Thu, 24 May 2012 04:00:00 GMT</pubDate></item><item><title><![CDATA[item 2]]></title><description><![CDATA[description 2]]></description><link>http://example.com/article2</link><guid isPermaLink="true">http://example.com/article2</guid><dc:creator><![CDATA[Dylan Greene]]></dc:creator><pubDate>Fri, 25 May 2012 04:00:00 GMT</pubDate></item><item><title><![CDATA[item 3]]></title><description><![CDATA[description 3]]></description><link>http://example.com/article3</link><guid isPermaLink="false">item3</guid><dc:creator><![CDATA[Dylan Greene]]></dc:creator><pubDate>Sat, 26 May 2012 04:00:00 GMT</pubDate></item><item><title><![CDATA[item 4 & html test with <strong>]]></title><description><![CDATA[description 4 uses some <strong>html</strong>]]></description><link>http://example.com/article4?this&that</link><guid isPermaLink="true">http://example.com/article4?this&that</guid><dc:creator><![CDATA[Guest Author]]></dc:creator><pubDate>Sun, 27 May 2012 04:00:00 GMT</pubDate></item><item><title><![CDATA[item 5 & test for categories]]></title><description><![CDATA[description 5]]></description><link>http://example.com/article5</link><guid isPermaLink="true">http://example.com/article5</guid><category><![CDATA[Category 1]]></category><category><![CDATA[Category 2]]></category><category><![CDATA[Category 3]]></category><category><![CDATA[Category 4]]></category><dc:creator><![CDATA[Guest Author]]></dc:creator><pubDate>Mon, 28 May 2012 04:00:00 GMT</pubDate></item></channel></rss>';
|
||||
var result = feed.xml();
|
||||
|
||||
test.equal(result.length, expectedResult.length);
|
||||
|
||||
Reference in New Issue
Block a user