mirror of
https://github.com/LightAir/turbo-rss.git
synced 2026-02-04 03:56:19 +00:00
Merge pull request #23 from andris9/master
Added support for PubSubHubbub hub
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -35,6 +35,7 @@ var feed = new RSS(feedOptions);
|
||||
* `categories` _optional_ **array of strings** One or more categories this feed belongs to.
|
||||
* `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 PubSubHubb hub located.
|
||||
|
||||
### Add items to a feed
|
||||
|
||||
|
||||
@@ -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 = '<?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();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user