mirror of
https://github.com/LightAir/turbo-rss.git
synced 2026-02-04 12:06:20 +00:00
add rest of my usual workflow, for better or worse.
This commit is contained in:
99
lib/rss.js
99
lib/rss.js
@@ -1,58 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
var XML = require('xml'),
|
||||
var xml = require('xml'),
|
||||
mime = require('mime'),
|
||||
fs = require('fs');
|
||||
|
||||
function RSS (options, items) {
|
||||
options = options || {};
|
||||
|
||||
this.title = options.title || 'Untitled RSS Feed';
|
||||
this.description = options.description || '';
|
||||
this.generator = options.generator || 'RSS for Node';
|
||||
this.feed_url = options.feed_url;
|
||||
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.hub = options.hub;
|
||||
this.docs = options.docs;
|
||||
this.copyright = options.copyright;
|
||||
this.language = options.language;
|
||||
this.managingEditor = options.managingEditor;
|
||||
this.webMaster = options.webMaster;
|
||||
this.ttl = options.ttl;
|
||||
//option to return feed as GeoRSS is set automatically if feed.lat/long is used
|
||||
this.geoRSS = options.geoRSS || false;
|
||||
this.items = items || [];
|
||||
|
||||
this.item = function (options) {
|
||||
options = options || {};
|
||||
var item = {
|
||||
title: options.title || 'No title',
|
||||
description: options.description || '',
|
||||
url: options.url,
|
||||
guid: options.guid,
|
||||
categories: options.categories || [],
|
||||
author: options.author,
|
||||
date: options.date,
|
||||
lat: options.lat,
|
||||
long: options.long,
|
||||
enclosure: options.enclosure || false
|
||||
};
|
||||
|
||||
this.items.push(item);
|
||||
return this;
|
||||
};
|
||||
|
||||
this.xml = function(indent) {
|
||||
return '<?xml version="1.0" encoding="UTF-8"?>\n'
|
||||
+ XML(generateXML(this), indent);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function ifTruePush(bool, array, data) {
|
||||
if (bool) {
|
||||
array.push(data);
|
||||
@@ -158,4 +109,52 @@ function generateXML (data){
|
||||
};
|
||||
}
|
||||
|
||||
function RSS (options, items) {
|
||||
options = options || {};
|
||||
|
||||
this.title = options.title || 'Untitled RSS Feed';
|
||||
this.description = options.description || '';
|
||||
this.generator = options.generator || 'RSS for Node';
|
||||
this.feed_url = options.feed_url;
|
||||
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.hub = options.hub;
|
||||
this.docs = options.docs;
|
||||
this.copyright = options.copyright;
|
||||
this.language = options.language;
|
||||
this.managingEditor = options.managingEditor;
|
||||
this.webMaster = options.webMaster;
|
||||
this.ttl = options.ttl;
|
||||
//option to return feed as GeoRSS is set automatically if feed.lat/long is used
|
||||
this.geoRSS = options.geoRSS || false;
|
||||
this.items = items || [];
|
||||
|
||||
this.item = function (options) {
|
||||
options = options || {};
|
||||
var item = {
|
||||
title: options.title || 'No title',
|
||||
description: options.description || '',
|
||||
url: options.url,
|
||||
guid: options.guid,
|
||||
categories: options.categories || [],
|
||||
author: options.author,
|
||||
date: options.date,
|
||||
lat: options.lat,
|
||||
long: options.long,
|
||||
enclosure: options.enclosure || false
|
||||
};
|
||||
|
||||
this.items.push(item);
|
||||
return this;
|
||||
};
|
||||
|
||||
this.xml = function(indent) {
|
||||
return '<?xml version="1.0" encoding="UTF-8"?>\n' +
|
||||
xml(generateXML(this), indent);
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = RSS;
|
||||
|
||||
Reference in New Issue
Block a user