mirror of
https://github.com/LightAir/turbo-rss.git
synced 2026-02-04 03:56:19 +00:00
adds support for feed options: category, language, copyright, managingEditor, webMaster, pubDate, docs, ttl
This commit is contained in:
25
lib/rss.js
25
lib/rss.js
@@ -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 = [
|
||||
|
||||
Reference in New Issue
Block a user