Added support for PubSubHubbub hub

This commit is contained in:
Andris Reinman
2014-01-18 16:01:38 +02:00
parent 2b9d4fa2ce
commit ede637b633
2 changed files with 30 additions and 0 deletions

View File

@@ -18,6 +18,7 @@ function RSS (options, items) {
this.author = options.author; this.author = options.author;
this.categories = options.categories; this.categories = options.categories;
this.pubDate = options.pubDate; this.pubDate = options.pubDate;
this.hub = options.hub;
this.docs = options.docs; this.docs = options.docs;
this.copyright = options.copyright; this.copyright = options.copyright;
this.language = options.language; this.language = options.language;
@@ -82,6 +83,7 @@ function generateXML (data){
ifTruePush(data.webMaster, channel, { 'webMaster': { _cdata: data.webMaster } }); ifTruePush(data.webMaster, channel, { 'webMaster': { _cdata: data.webMaster } });
ifTruePush(data.docs, channel, { 'docs': data.docs }); ifTruePush(data.docs, channel, { 'docs': data.docs });
ifTruePush(data.ttl, channel, { 'ttl': data.ttl }); ifTruePush(data.ttl, channel, { 'ttl': data.ttl });
ifTruePush(data.hub, channel, { 'atom:link': { _attr: { href: data.hub, rel: 'hub' } } });
if (data.categories) { if (data.categories) {
data.categories.forEach(function(category) { data.categories.forEach(function(category) {

View File

@@ -216,5 +216,33 @@ describe('rss module', function(done) {
expect(result).to.equal(expectedResult); expect(result).to.equal(expectedResult);
done(); 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 = '<?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>'+
'<generator>RSS for Node</generator>'+
'<lastBuildDate>' + new Date().toUTCString() +'</lastBuildDate>'+
'<atom:link href="http://example.com/rss.xml" rel="self" type="application/rss+xml"/>'+
'<atom:link href="http://example.com/hub" rel="hub"/>'+
'</channel>'+
'</rss>';
var result = feed.xml();
expect(result).to.equal(expectedResult);
done();
});
}); });