From 0d89d7b3dc0fd6ca03cf24e1504475525a30a2a3 Mon Sep 17 00:00:00 2001 From: Max Nowack Date: Mon, 10 Nov 2014 23:50:20 +0100 Subject: [PATCH 01/12] added test with custom elements --- test/rss.test.js | 110 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 109 insertions(+), 1 deletion(-) diff --git a/test/rss.test.js b/test/rss.test.js index d035797a..e9636aa1 100644 --- a/test/rss.test.js +++ b/test/rss.test.js @@ -262,5 +262,113 @@ describe('rss module', function(done) { expect(result).to.equal(expectedResult); done(); }); -}); + it('should work with custom elements', function(done) { + var feed = new RSS({ + title: 'title', + description: 'description', + feed_url: 'http://example.com/rss.xml', + site_url: 'http://example.com', + author: 'Dylan Greene', + categories: ['Category 1','Category 2','Category 3'], + pubDate: 'May 20, 2012 04:00:00 GMT', + docs: 'http://example.com/rss/docs.html', + copyright: '2013 Dylan Green', + language: 'en', + managingEditor: 'Dylan Green', + webMaster: 'Dylan Green', + ttl: '60' + custom: { + 'itunes:subtitle': 'A show about everything', + 'itunes:author': 'John Doe', + 'itunes:summary': 'All About Everything is a show about everything. Each week we dive into any subject known to man and talk about it as much as we can. Look for our podcast in the Podcasts app or in the iTunes Store', + 'itunes:owner': { + 'itunes:name': 'John Doe', + 'itunes:email': 'john.doe@example.com' + }, + 'itunes:image': { + _attr: { + href: 'http://example.com/podcasts/everything/AllAboutEverything.jpg' + } + }, + 'itunes:category': { + _attr: { + text: 'Technology' + } + 'itunes:category': { + _attr: { + text: 'Gadgets' + } + } + } + } + }); + + feed.item({ + title: 'item 1', + description: 'description 1', + url: 'http://example.com/article1', + date: 'May 24, 2012 04:00:00 GMT', + custom: { + 'itunes:author': 'John Doe', + 'itunes:subtitle': 'A short primer on table spices', + 'itunes:image': { + _attr: { + href: 'http://example.com/podcasts/everything/AllAboutEverything/Episode1.jpg' + } + }, + 'itunes:duration': '7:04' + } + }); + + var expectedResult ='\n' + + '' + + '' + + 'title' + + 'description' + + 'http://example.com' + + 'RSS for Node' + + '' + new Date().toUTCString() +'' + + '' + + 'Dylan Greene' + + 'Sun, 20 May 2012 04:00:00 GMT' + + '2013 Dylan Green' + + 'en' + + 'Dylan Green' + + 'Dylan Green' + + 'http://example.com/rss/docs.html' + + '60' + + 'Category 1' + + 'Category 2' + + 'Category 3' + + 'A show about everything' + + 'John Doe' + + 'All About Everything is a show about everything. Each week we dive into any subject known to man and talk about it as much as we can. Look for our podcast in the Podcasts app or in the iTunes Store' + + '' + + 'John Doe' + + 'john.doe@example.com' + + '' + + '' + + '' + + '' + + '' + + '' + + 'item 1' + + 'description 1' + + 'http://example.com/article1' + + 'http://example.com/article1' + + 'Dylan Greene' + + 'Thu, 24 May 2012 04:00:00 GMT' + + 'John Doe' + + 'A short primer on table spices' + + '' + + '7:04' + + '' + + '' + + ''; + var result = feed.xml(); + + expect(result).to.equal(expectedResult); + done(); + }); +}); From 0661501bc4b9720a41df7fd880900a1ce8709c12 Mon Sep 17 00:00:00 2001 From: Max Nowack Date: Tue, 11 Nov 2014 12:09:49 +0100 Subject: [PATCH 02/12] fixed test --- test/rss.test.js | 50 ++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/test/rss.test.js b/test/rss.test.js index e9636aa1..1e3377a1 100644 --- a/test/rss.test.js +++ b/test/rss.test.js @@ -277,31 +277,31 @@ describe('rss module', function(done) { language: 'en', managingEditor: 'Dylan Green', webMaster: 'Dylan Green', - ttl: '60' - custom: { - 'itunes:subtitle': 'A show about everything', - 'itunes:author': 'John Doe', - 'itunes:summary': 'All About Everything is a show about everything. Each week we dive into any subject known to man and talk about it as much as we can. Look for our podcast in the Podcasts app or in the iTunes Store', - 'itunes:owner': { - 'itunes:name': 'John Doe', - 'itunes:email': 'john.doe@example.com' - }, - 'itunes:image': { + ttl: '60', + custom: [ + {'itunes:subtitle': 'A show about everything'}, + {'itunes:author': 'John Doe'}, + {'itunes:summary': 'All About Everything is a show about everything. Each week we dive into any subject known to man and talk about it as much as we can. Look for our podcast in the Podcasts app or in the iTunes Store'}, + {'itunes:owner': [ + {'itunes:name': 'John Doe'}, + {'itunes:email': 'john.doe@example.com'} + ]}, + {'itunes:image': { _attr: { href: 'http://example.com/podcasts/everything/AllAboutEverything.jpg' } - }, - 'itunes:category': { - _attr: { + }}, + {'itunes:category': [ + {_attr: { text: 'Technology' - } - 'itunes:category': { + }}, + {'itunes:category': { _attr: { text: 'Gadgets' } - } - } - } + }} + ]} + ] }); feed.item({ @@ -309,16 +309,16 @@ describe('rss module', function(done) { description: 'description 1', url: 'http://example.com/article1', date: 'May 24, 2012 04:00:00 GMT', - custom: { - 'itunes:author': 'John Doe', - 'itunes:subtitle': 'A short primer on table spices', - 'itunes:image': { + custom: [ + {'itunes:author': 'John Doe'}, + {'itunes:subtitle': 'A short primer on table spices'}, + {'itunes:image': { _attr: { href: 'http://example.com/podcasts/everything/AllAboutEverything/Episode1.jpg' } - }, - 'itunes:duration': '7:04' - } + }}, + {'itunes:duration': '7:04'} + ] }); var expectedResult ='\n' + From f475832cd33e4565e79ea4525a76297c66202bc4 Mon Sep 17 00:00:00 2001 From: Max Nowack Date: Tue, 11 Nov 2014 13:48:51 +0100 Subject: [PATCH 03/12] fixed test for custom elements --- test/rss.test.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/test/rss.test.js b/test/rss.test.js index 1e3377a1..a7df4d19 100644 --- a/test/rss.test.js +++ b/test/rss.test.js @@ -321,22 +321,22 @@ describe('rss module', function(done) { ] }); - var expectedResult ='\n' + - '' + + var expectedResult ='\n'+ + ''+ '' + - 'title' + - 'description' + + '<![CDATA[title]]>' + + '' + 'http://example.com' + 'RSS for Node' + '' + new Date().toUTCString() +'' + - '' + - 'Dylan Greene' + + '' + + '' + 'Sun, 20 May 2012 04:00:00 GMT' + '2013 Dylan Green' + - 'en' + 'Dylan Green' + 'Dylan Green' + 'http://example.com/rss/docs.html' + + '' + '60' + 'Category 1' + 'Category 2' + @@ -348,20 +348,20 @@ describe('rss module', function(done) { 'John Doe' + 'john.doe@example.com' + '' + - '' + + '' + '' + '' + '' + '' + - 'item 1' + - 'description 1' + + '<![CDATA[item 1]]>' + + '' + 'http://example.com/article1' + 'http://example.com/article1' + - 'Dylan Greene' + + '' + 'Thu, 24 May 2012 04:00:00 GMT' + 'John Doe' + 'A short primer on table spices' + - '' + + '' + '7:04' + '' + '' + From 491340b91e00156b176702b49a4ba09d1eb295c8 Mon Sep 17 00:00:00 2001 From: Max Nowack Date: Tue, 11 Nov 2014 13:49:15 +0100 Subject: [PATCH 04/12] simplified test for custom elements --- test/rss.test.js | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/test/rss.test.js b/test/rss.test.js index a7df4d19..520441ee 100644 --- a/test/rss.test.js +++ b/test/rss.test.js @@ -270,13 +270,8 @@ describe('rss module', function(done) { feed_url: 'http://example.com/rss.xml', site_url: 'http://example.com', author: 'Dylan Greene', - categories: ['Category 1','Category 2','Category 3'], pubDate: 'May 20, 2012 04:00:00 GMT', - docs: 'http://example.com/rss/docs.html', - copyright: '2013 Dylan Green', language: 'en', - managingEditor: 'Dylan Green', - webMaster: 'Dylan Green', ttl: '60', custom: [ {'itunes:subtitle': 'A show about everything'}, @@ -332,15 +327,8 @@ describe('rss module', function(done) { '' + '' + 'Sun, 20 May 2012 04:00:00 GMT' + - '2013 Dylan Green' + - 'Dylan Green' + - 'Dylan Green' + - 'http://example.com/rss/docs.html' + '' + '60' + - 'Category 1' + - 'Category 2' + - 'Category 3' + 'A show about everything' + 'John Doe' + 'All About Everything is a show about everything. Each week we dive into any subject known to man and talk about it as much as we can. Look for our podcast in the Podcasts app or in the iTunes Store' + From 040d854c57daaecb2aa90096d44b2e05d6b31a1d Mon Sep 17 00:00:00 2001 From: Max Nowack Date: Tue, 11 Nov 2014 13:49:37 +0100 Subject: [PATCH 05/12] added functionality to add custom elements --- lib/rss.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/rss.js b/lib/rss.js index 11ca4915..a8110b90 100755 --- a/lib/rss.js +++ b/lib/rss.js @@ -10,6 +10,14 @@ function ifTruePush(bool, array, data) { } } +function ifTruePushArray(bool, array, dataArray) { + if(!bool) return; + + dataArray.forEach(function(item) { + ifTruePush(item, array, item); + }); +} + function generateXML (data){ var channel = []; @@ -40,6 +48,8 @@ function generateXML (data){ }); } + ifTruePushArray(data.custom, channel, data.custom); + data.items.forEach(function(item) { var item_values = [ { title: { _cdata: item.title } } @@ -84,6 +94,8 @@ function generateXML (data){ } } + ifTruePushArray(item.custom, item_values, item.custom); + channel.push({ item: item_values }); }); @@ -130,6 +142,7 @@ function RSS (options, items) { this.ttl = options.ttl; //option to return feed as GeoRSS is set automatically if feed.lat/long is used this.geoRSS = options.geoRSS || false; + this.custom = options.custom || []; this.items = items || []; this.item = function (options) { @@ -144,7 +157,8 @@ function RSS (options, items) { date: options.date, lat: options.lat, long: options.long, - enclosure: options.enclosure || false + enclosure: options.enclosure || false, + custom: options.custom || [] }; this.items.push(item); From 86716e2d8c12c7680c7a550f2205ff0871609c3e Mon Sep 17 00:00:00 2001 From: Max Nowack Date: Tue, 11 Nov 2014 13:57:58 +0100 Subject: [PATCH 06/12] added test for custom namespaces --- test/rss.test.js | 100 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/test/rss.test.js b/test/rss.test.js index 520441ee..c50ef810 100644 --- a/test/rss.test.js +++ b/test/rss.test.js @@ -359,4 +359,104 @@ describe('rss module', function(done) { expect(result).to.equal(expectedResult); done(); }); + + it('should work with custom namespaces', function(done) { + var feed = new RSS({ + title: 'title', + description: 'description', + feed_url: 'http://example.com/rss.xml', + site_url: 'http://example.com', + author: 'Dylan Greene', + pubDate: 'May 20, 2012 04:00:00 GMT', + language: 'en', + ttl: '60', + customNamespaces: { + 'itunes': 'http://www.itunes.com/dtds/podcast-1.0.dtd' + }, + custom: [ + {'itunes:subtitle': 'A show about everything'}, + {'itunes:author': 'John Doe'}, + {'itunes:summary': 'All About Everything is a show about everything. Each week we dive into any subject known to man and talk about it as much as we can. Look for our podcast in the Podcasts app or in the iTunes Store'}, + {'itunes:owner': [ + {'itunes:name': 'John Doe'}, + {'itunes:email': 'john.doe@example.com'} + ]}, + {'itunes:image': { + _attr: { + href: 'http://example.com/podcasts/everything/AllAboutEverything.jpg' + } + }}, + {'itunes:category': [ + {_attr: { + text: 'Technology' + }}, + {'itunes:category': { + _attr: { + text: 'Gadgets' + } + }} + ]} + ] + }); + + feed.item({ + title: 'item 1', + description: 'description 1', + url: 'http://example.com/article1', + date: 'May 24, 2012 04:00:00 GMT', + custom: [ + {'itunes:author': 'John Doe'}, + {'itunes:subtitle': 'A short primer on table spices'}, + {'itunes:image': { + _attr: { + href: 'http://example.com/podcasts/everything/AllAboutEverything/Episode1.jpg' + } + }}, + {'itunes:duration': '7:04'} + ] + }); + + var expectedResult ='\n'+ + ''+ + '' + + '<![CDATA[title]]>' + + '' + + 'http://example.com' + + 'RSS for Node' + + '' + new Date().toUTCString() +'' + + '' + + '' + + 'Sun, 20 May 2012 04:00:00 GMT' + + '' + + '60' + + 'A show about everything' + + 'John Doe' + + 'All About Everything is a show about everything. Each week we dive into any subject known to man and talk about it as much as we can. Look for our podcast in the Podcasts app or in the iTunes Store' + + '' + + 'John Doe' + + 'john.doe@example.com' + + '' + + '' + + '' + + '' + + '' + + '' + + '<![CDATA[item 1]]>' + + '' + + 'http://example.com/article1' + + 'http://example.com/article1' + + '' + + 'Thu, 24 May 2012 04:00:00 GMT' + + 'John Doe' + + 'A short primer on table spices' + + '' + + '7:04' + + '' + + '' + + ''; + var result = feed.xml(); + + expect(result).to.equal(expectedResult); + done(); + }); }); From 4bb6259ebf9af577c726140589e430a878b58994 Mon Sep 17 00:00:00 2001 From: Max Nowack Date: Tue, 11 Nov 2014 14:08:13 +0100 Subject: [PATCH 07/12] implemented functionality for custom namespaces --- lib/rss.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/rss.js b/lib/rss.js index a8110b90..c24f23ba 100755 --- a/lib/rss.js +++ b/lib/rss.js @@ -108,6 +108,10 @@ function generateXML (data){ version: '2.0' }; + for(var name in data.customNamespaces) { + _attr['xmlns:' + name] = data.customNamespaces[name]; + } + //only add namespace if GeoRSS is true if(data.geoRSS){ _attr['xmlns:geo'] = 'http://www.w3.org/2003/01/geo/wgs84_pos#'; @@ -142,6 +146,7 @@ function RSS (options, items) { this.ttl = options.ttl; //option to return feed as GeoRSS is set automatically if feed.lat/long is used this.geoRSS = options.geoRSS || false; + this.customNamespaces = options.customNamespaces || {}; this.custom = options.custom || []; this.items = items || []; From 544d783e18b949887c4478b59b93353d9467810a Mon Sep 17 00:00:00 2001 From: Max Nowack Date: Tue, 11 Nov 2014 14:15:13 +0100 Subject: [PATCH 08/12] updated readme --- readme.md | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 95d5e27c..7a14c933 100644 --- a/readme.md +++ b/readme.md @@ -37,6 +37,8 @@ var feed = new RSS(feedOptions); * `pubDate` _optional_ **Date object or date string** The publication date for content in the feed * `ttl` _optional_ **integer** Number of minutes feed can be cached before refreshing from source. * `hub` _optional_ **PubSubHubbub hub url** Where is the PubSubHub hub located. + * `customNamespaces` _optional_ **object** Put additional namespaces in element (without 'xmlns:' prefix) + * `custom` _optional_ **array** Put additional elements in the feed (node-xml syntax) #### Add items to a feed @@ -64,6 +66,7 @@ feed.item(itemOptions); if the content should be presented as unread. * `lat` _optional_ **number** The latitude coordinate of the item. * `long` _optional_ **number** The longitude coordinate of the item. + * `custom` _optional_ **array** Put additional elements in the item (node-xml syntax) ##### Feed XML @@ -96,7 +99,34 @@ var feed = new RSS({ language: 'en', categories: ['Category 1','Category 2','Category 3'], pubDate: 'May 20, 2012 04:00:00 GMT', - ttl: '60' + ttl: '60', + customNamespaces: { + 'itunes': 'http://www.itunes.com/dtds/podcast-1.0.dtd' + }, + custom: [ + {'itunes:subtitle': 'A show about everything'}, + {'itunes:author': 'John Doe'}, + {'itunes:summary': 'All About Everything is a show about everything. Each week we dive into any subject known to man and talk about it as much as we can. Look for our podcast in the Podcasts app or in the iTunes Store'}, + {'itunes:owner': [ + {'itunes:name': 'John Doe'}, + {'itunes:email': 'john.doe@example.com'} + ]}, + {'itunes:image': { + _attr: { + href: 'http://example.com/podcasts/everything/AllAboutEverything.jpg' + } + }}, + {'itunes:category': [ + {_attr: { + text: 'Technology' + }}, + {'itunes:category': { + _attr: { + text: 'Gadgets' + } + }} + ]} + ] }); /* loop over data and add to feed */ @@ -110,7 +140,17 @@ feed.item({ date: 'May 27, 2012', // any format that js Date can parse. lat: 33.417974, //optional latitude field for GeoRSS long: -111.933231, //optional longitude field for GeoRSS - enclosure: {url:'...', file:'path-to-file'} // optional enclosure + enclosure: {url:'...', file:'path-to-file'}, // optional enclosure + custom: [ + {'itunes:author': 'John Doe'}, + {'itunes:subtitle': 'A short primer on table spices'}, + {'itunes:image': { + _attr: { + href: 'http://example.com/podcasts/everything/AllAboutEverything/Episode1.jpg' + } + }}, + {'itunes:duration': '7:04'} + ] }); // cache the xml to send to clients From 74d7142ab4a7e2ff1913560536a3cb809532ae70 Mon Sep 17 00:00:00 2001 From: Max Nowack Date: Tue, 11 Nov 2014 15:00:30 +0100 Subject: [PATCH 09/12] fixed jshint error --- lib/rss.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/rss.js b/lib/rss.js index c24f23ba..d8bfdd1d 100755 --- a/lib/rss.js +++ b/lib/rss.js @@ -11,7 +11,9 @@ function ifTruePush(bool, array, data) { } function ifTruePushArray(bool, array, dataArray) { - if(!bool) return; + if(!bool) { + return; + } dataArray.forEach(function(item) { ifTruePush(item, array, item); From f46592e233d552de3a473cd1b4b7c4222024038f Mon Sep 17 00:00:00 2001 From: Max Nowack Date: Tue, 11 Nov 2014 18:30:54 +0100 Subject: [PATCH 10/12] changed object names to fit conventions --- lib/rss.js | 14 +++++++------- readme.md | 6 +++--- test/rss.test.js | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/rss.js b/lib/rss.js index d8bfdd1d..6df7e5bc 100755 --- a/lib/rss.js +++ b/lib/rss.js @@ -50,7 +50,7 @@ function generateXML (data){ }); } - ifTruePushArray(data.custom, channel, data.custom); + ifTruePushArray(data.custom_elements, channel, data.custom_elements); data.items.forEach(function(item) { var item_values = [ @@ -96,7 +96,7 @@ function generateXML (data){ } } - ifTruePushArray(item.custom, item_values, item.custom); + ifTruePushArray(item.custom_elements, item_values, item.custom_elements); channel.push({ item: item_values }); @@ -110,8 +110,8 @@ function generateXML (data){ version: '2.0' }; - for(var name in data.customNamespaces) { - _attr['xmlns:' + name] = data.customNamespaces[name]; + for(var name in data.custom_namespaces) { + _attr['xmlns:' + name] = data.custom_namespaces[name]; } //only add namespace if GeoRSS is true @@ -148,8 +148,8 @@ function RSS (options, items) { this.ttl = options.ttl; //option to return feed as GeoRSS is set automatically if feed.lat/long is used this.geoRSS = options.geoRSS || false; - this.customNamespaces = options.customNamespaces || {}; - this.custom = options.custom || []; + this.custom_namespaces = options.custom_namespaces || {}; + this.custom_elements = options.custom_elements || []; this.items = items || []; this.item = function (options) { @@ -165,7 +165,7 @@ function RSS (options, items) { lat: options.lat, long: options.long, enclosure: options.enclosure || false, - custom: options.custom || [] + custom_elements: options.custom_elements || [] }; this.items.push(item); diff --git a/readme.md b/readme.md index 7a14c933..dec89201 100644 --- a/readme.md +++ b/readme.md @@ -37,8 +37,8 @@ var feed = new RSS(feedOptions); * `pubDate` _optional_ **Date object or date string** The publication date for content in the feed * `ttl` _optional_ **integer** Number of minutes feed can be cached before refreshing from source. * `hub` _optional_ **PubSubHubbub hub url** Where is the PubSubHub hub located. - * `customNamespaces` _optional_ **object** Put additional namespaces in element (without 'xmlns:' prefix) - * `custom` _optional_ **array** Put additional elements in the feed (node-xml syntax) + * `custom_namespaces` _optional_ **object** Put additional namespaces in element (without 'xmlns:' prefix) + * `custom_elements` _optional_ **array** Put additional elements in the feed (node-xml syntax) #### Add items to a feed @@ -66,7 +66,7 @@ feed.item(itemOptions); if the content should be presented as unread. * `lat` _optional_ **number** The latitude coordinate of the item. * `long` _optional_ **number** The longitude coordinate of the item. - * `custom` _optional_ **array** Put additional elements in the item (node-xml syntax) + * `custom_elements` _optional_ **array** Put additional elements in the item (node-xml syntax) ##### Feed XML diff --git a/test/rss.test.js b/test/rss.test.js index c50ef810..39df2d6c 100644 --- a/test/rss.test.js +++ b/test/rss.test.js @@ -273,7 +273,7 @@ describe('rss module', function(done) { pubDate: 'May 20, 2012 04:00:00 GMT', language: 'en', ttl: '60', - custom: [ + custom_elements: [ {'itunes:subtitle': 'A show about everything'}, {'itunes:author': 'John Doe'}, {'itunes:summary': 'All About Everything is a show about everything. Each week we dive into any subject known to man and talk about it as much as we can. Look for our podcast in the Podcasts app or in the iTunes Store'}, @@ -304,7 +304,7 @@ describe('rss module', function(done) { description: 'description 1', url: 'http://example.com/article1', date: 'May 24, 2012 04:00:00 GMT', - custom: [ + custom_elements: [ {'itunes:author': 'John Doe'}, {'itunes:subtitle': 'A short primer on table spices'}, {'itunes:image': { @@ -370,10 +370,10 @@ describe('rss module', function(done) { pubDate: 'May 20, 2012 04:00:00 GMT', language: 'en', ttl: '60', - customNamespaces: { + custom_namespaces: { 'itunes': 'http://www.itunes.com/dtds/podcast-1.0.dtd' }, - custom: [ + custom_elements: [ {'itunes:subtitle': 'A show about everything'}, {'itunes:author': 'John Doe'}, {'itunes:summary': 'All About Everything is a show about everything. Each week we dive into any subject known to man and talk about it as much as we can. Look for our podcast in the Podcasts app or in the iTunes Store'}, @@ -404,7 +404,7 @@ describe('rss module', function(done) { description: 'description 1', url: 'http://example.com/article1', date: 'May 24, 2012 04:00:00 GMT', - custom: [ + custom_elements: [ {'itunes:author': 'John Doe'}, {'itunes:subtitle': 'A short primer on table spices'}, {'itunes:image': { From b9dfce389e9d73a91db1c0b1b92a6a04faa52547 Mon Sep 17 00:00:00 2001 From: Max Nowack Date: Tue, 11 Nov 2014 18:32:37 +0100 Subject: [PATCH 11/12] fixed indentations --- lib/rss.js | 62 +++++++++++++++++++++++++++--------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/lib/rss.js b/lib/rss.js index 6df7e5bc..a0fdd778 100755 --- a/lib/rss.js +++ b/lib/rss.js @@ -130,42 +130,42 @@ function generateXML (data){ function RSS (options, items) { options = options || {}; - this.title = options.title || 'Untitled RSS Feed'; - this.description = options.description || ''; - this.generator = options.generator || 'RSS for Node'; - this.feed_url = options.feed_url; - this.site_url = options.site_url; - this.image_url = options.image_url; - this.author = options.author; - this.categories = options.categories; - this.pubDate = options.pubDate; - this.hub = options.hub; - this.docs = options.docs; - this.copyright = options.copyright; - this.language = options.language; - this.managingEditor = options.managingEditor; - this.webMaster = options.webMaster; - this.ttl = options.ttl; + this.title = options.title || 'Untitled RSS Feed'; + this.description = options.description || ''; + this.generator = options.generator || 'RSS for Node'; + this.feed_url = options.feed_url; + this.site_url = options.site_url; + this.image_url = options.image_url; + this.author = options.author; + this.categories = options.categories; + this.pubDate = options.pubDate; + this.hub = options.hub; + this.docs = options.docs; + this.copyright = options.copyright; + this.language = options.language; + this.managingEditor = options.managingEditor; + this.webMaster = options.webMaster; + this.ttl = options.ttl; //option to return feed as GeoRSS is set automatically if feed.lat/long is used - this.geoRSS = options.geoRSS || false; - this.custom_namespaces = options.custom_namespaces || {}; - this.custom_elements = options.custom_elements || []; - this.items = items || []; + this.geoRSS = options.geoRSS || false; + this.custom_namespaces = options.custom_namespaces || {}; + this.custom_elements = options.custom_elements || []; + this.items = items || []; this.item = function (options) { options = options || {}; var item = { - title: options.title || 'No title', - description: options.description || '', - url: options.url, - guid: options.guid, - categories: options.categories || [], - author: options.author, - date: options.date, - lat: options.lat, - long: options.long, - enclosure: options.enclosure || false, - custom_elements: options.custom_elements || [] + title: options.title || 'No title', + description: options.description || '', + url: options.url, + guid: options.guid, + categories: options.categories || [], + author: options.author, + date: options.date, + lat: options.lat, + long: options.long, + enclosure: options.enclosure || false, + custom_elements: options.custom_elements || [] }; this.items.push(item); From 16ea3467aead233bfd4ad2eabb3fba77f61714a0 Mon Sep 17 00:00:00 2001 From: Max Nowack Date: Mon, 8 Dec 2014 07:35:53 +0100 Subject: [PATCH 12/12] changed namespace iteration style --- lib/rss.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rss.js b/lib/rss.js index a0fdd778..8199b629 100755 --- a/lib/rss.js +++ b/lib/rss.js @@ -110,9 +110,9 @@ function generateXML (data){ version: '2.0' }; - for(var name in data.custom_namespaces) { + Object.keys(data.custom_namespaces).forEach(function(name) { _attr['xmlns:' + name] = data.custom_namespaces[name]; - } + }); //only add namespace if GeoRSS is true if(data.geoRSS){