add rest of my usual workflow, for better or worse.

This commit is contained in:
Dylan Greene
2014-10-21 17:46:07 -04:00
parent 263ff40c41
commit 0895c42dd4
13 changed files with 357 additions and 96 deletions

View File

@@ -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;