adds support for feed options: category, language, copyright, managingEditor, webMaster, pubDate, docs, ttl

This commit is contained in:
Danny Graham
2013-07-03 09:48:00 -07:00
parent 91121e8c32
commit 0eb51074d4
3 changed files with 60 additions and 7 deletions

View File

@@ -13,6 +13,14 @@ function RSS (options, items) {
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.docs = options.docs;
this.copyright = options.copyright;
this.language = options.language;
this.managingEditor = options.managingEditor;
this.webMaster = options.webMaster;
this.ttl = options.ttl;
this.items = items || [];
this.item = function (options) {
@@ -58,9 +66,22 @@ function generateXML (data){
channel.push({ generator: 'NodeJS RSS Module' });
channel.push({ lastBuildDate: new Date().toGMTString() });
ifTruePush(data.feed_url, channel, { 'atom:link': { _attr: { href: data.feed_url, rel: 'self', type: 'application/rss+xml' } } });
// { updated: new Date().toGMTString() }
ifTruePush(data.feed_url, channel, { 'atom:link': { _attr: { href: data.feed_url, rel: 'self', type: 'application/rss+xml' } } });
ifTruePush(data.author, channel, { 'author': { _cdata: data.author } });
ifTruePush(data.pubDate, channel, { 'pubDate': new Date(data.pubDate).toGMTString() });
ifTruePush(data.copyright, channel, { 'copyright': { _cdata: data.copyright } });
ifTruePush(data.language, channel, { 'language': { _cdata: data.language } });
ifTruePush(data.managingEditor, channel, { 'managingEditor': { _cdata: data.managingEditor } });
ifTruePush(data.webMaster, channel, { 'webMaster': { _cdata: data.webMaster } });
ifTruePush(data.docs, channel, { 'docs': data.docs });
ifTruePush(data.ttl, channel, { 'ttl': data.ttl });
if (data.categories) {
data.categories.forEach(function(category) {
ifTruePush(category, channel, { category: { _cdata: category } });
});
}
// { updated: new Date().toGMTString() }
data.items.forEach(function(item) {
var item_values = [