From 5f90c13a256fa04806a0459dde91cc00c1ce695a Mon Sep 17 00:00:00 2001 From: Patrick Garman Date: Tue, 27 Aug 2013 17:13:10 -0500 Subject: [PATCH] Adding Generator Option --- lib/rss.js | 3 ++- package.json | 5 +++-- readme.md | 1 + test/test.js | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/rss.js b/lib/rss.js index 40f8516..96f0e67 100644 --- a/lib/rss.js +++ b/lib/rss.js @@ -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' } } }); diff --git a/package.json b/package.json index 4ec4104..ba9190b 100644 --- a/package.json +++ b/package.json @@ -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 ", @@ -9,7 +9,8 @@ "Xavier Damman ", "Michael R. Lange", "Victor Jonsson", - "Danny Graham" + "Danny Graham", + "Patrick Garman " ], "repository": { diff --git a/readme.md b/readme.md index 59362e2..f808c3e 100644 --- a/readme.md +++ b/readme.md @@ -54,6 +54,7 @@ * _title_ Title of your site or feed * _description_ Optional. Short description of the feed. + * _generator_ Optional. Feed generator. * _feed_url_ Url to the rss feed. * _site_url_ Url to the site that the feed is for. * _image_url_ Optional. Small image for feed readers to use. diff --git a/test/test.js b/test/test.js index 50e0731..8aac3ab 100644 --- a/test/test.js +++ b/test/test.js @@ -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 = '\n<![CDATA[title]]>http://example.comhttp://example.com/icon.pngtitlehttp://example.comNodeJS RSS Module' + new Date().toUTCString() +'Sun, 20 May 2012 04:00:00 GMThttp://example.com/rss/docs.html60<![CDATA[item 1]]>http://example.com/article1http://example.com/article1Thu, 24 May 2012 04:00:00 GMT<![CDATA[item 2]]>http://example.com/article2http://example.com/article2Fri, 25 May 2012 04:00:00 GMT<![CDATA[item 3]]>http://example.com/article3item3Sat, 26 May 2012 04:00:00 GMT<![CDATA[item 4 & html test with <strong>]]>html]]>http://example.com/article4?this&thathttp://example.com/article4?this&thatSun, 27 May 2012 04:00:00 GMT<![CDATA[item 5 & test for categories]]>http://example.com/article5http://example.com/article5Mon, 28 May 2012 04:00:00 GMT'; + var expectedResult = '\n<![CDATA[title]]>http://example.comhttp://example.com/icon.pngtitlehttp://example.comExample Generator' + new Date().toUTCString() +'Sun, 20 May 2012 04:00:00 GMThttp://example.com/rss/docs.html60<![CDATA[item 1]]>http://example.com/article1http://example.com/article1Thu, 24 May 2012 04:00:00 GMT<![CDATA[item 2]]>http://example.com/article2http://example.com/article2Fri, 25 May 2012 04:00:00 GMT<![CDATA[item 3]]>http://example.com/article3item3Sat, 26 May 2012 04:00:00 GMT<![CDATA[item 4 & html test with <strong>]]>html]]>http://example.com/article4?this&thathttp://example.com/article4?this&thatSun, 27 May 2012 04:00:00 GMT<![CDATA[item 5 & test for categories]]>http://example.com/article5http://example.com/article5Mon, 28 May 2012 04:00:00 GMT'; var result = feed.xml(); test.equal(result.length, expectedResult.length);