diff --git a/lib/rss.js b/lib/rss.js index 09b7653..8286772 100755 --- a/lib/rss.js +++ b/lib/rss.js @@ -18,6 +18,7 @@ function RSS (options, items) { 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; @@ -82,6 +83,7 @@ function generateXML (data){ ifTruePush(data.webMaster, channel, { 'webMaster': { _cdata: data.webMaster } }); ifTruePush(data.docs, channel, { 'docs': data.docs }); ifTruePush(data.ttl, channel, { 'ttl': data.ttl }); + ifTruePush(data.hub, channel, { 'atom:link': { _attr: { href: data.hub, rel: 'hub' } } }); if (data.categories) { data.categories.forEach(function(category) { diff --git a/test/rss.test.js b/test/rss.test.js index b7651ac..41b801e 100644 --- a/test/rss.test.js +++ b/test/rss.test.js @@ -216,5 +216,33 @@ describe('rss module', function(done) { expect(result).to.equal(expectedResult); done(); }); + + it('should work with PubSubHubbub hub', function(done) { + var feed = new RSS({ + title: 'title', + description: 'description', + feed_url: 'http://example.com/rss.xml', + site_url: 'http://example.com', + hub: 'http://example.com/hub' + }); + + var expectedResult = '\n'+ + ''+ + ''+ + '<![CDATA[title]]>'+ + ''+ + 'http://example.com'+ + 'RSS for Node'+ + '' + new Date().toUTCString() +''+ + ''+ + ''+ + ''+ + ''; + + var result = feed.xml(); + + expect(result).to.equal(expectedResult); + done(); + }); });