Rinser/paleo.js

119 lines
3.3 KiB
JavaScript
Raw Normal View History

2015-07-21 09:50:51 +00:00
var outputFile = 'paleo',
RssBraider = require('rss-braider'),
fs = require('fs'),
ejs = require('ejs'),
read = require('fs').readFileSync,
join = require('path').join,
str = read(join(__dirname, '/templates/rss.ejs'), 'utf8'),
2015-07-20 13:49:34 +00:00
feeds = {};
2015-07-20 14:13:36 +00:00
// Pull feeds from config files: ,
2015-07-20 13:49:34 +00:00
// feeds.simple_test_feed = require("./config/feed").feed;
// Or define in-line
2015-07-21 09:50:51 +00:00
2015-07-20 13:49:34 +00:00
feeds.simple_test_feed = {
2015-07-21 09:50:51 +00:00
"feed_name": "feed",
"default_count": 1,
"no_cdata_fields": [], // Don't wrap these fields in CDATA tags
"meta": {
2015-07-20 13:49:34 +00:00
"title": "Paleo",
2015-07-20 15:56:35 +00:00
"description": "Combined Paleo Feed",
2015-07-21 09:50:51 +00:00
'site_url': 'http://pipes.silvrtree.co.uk/paleo.xml'
2015-07-20 13:49:34 +00:00
},
2015-07-23 12:25:35 +00:00
"plugins" : ['filter_3_days' ],
2015-07-21 09:50:51 +00:00
"sources": [
2015-07-20 13:49:34 +00:00
{
/* "name" : "JobServe",*/
2015-07-21 09:50:51 +00:00
"count": 100,
"feed_url": "http://feeds.feedburner.com/PaleoPlan"
2015-07-20 13:49:34 +00:00
},
{
/* "name" : "JobServe",*/
2015-07-21 09:50:51 +00:00
"count": 100,
"feed_url": "http://nomnompaleo.com/rss"
2015-07-20 13:49:34 +00:00
},
{
/* "name" : "JobServe",*/
2015-07-21 09:50:51 +00:00
"count": 100,
"feed_url": "http://thepaleodiet.com/feed/"
2015-07-20 13:49:34 +00:00
},
{
/* "name" : "JobServe",*/
2015-07-21 09:50:51 +00:00
"count": 100,
"feed_url": "http://paleoleap.com/feed/"
2015-07-20 13:49:34 +00:00
},
{
/* "name" : "JobServe",*/
2015-07-21 09:50:51 +00:00
"count": 100,
"feed_url": "http://ultimatepaleoguide.com/feed/"
2015-07-20 13:49:34 +00:00
},
{
/* "name" : "JobServe",*/
2015-07-21 09:50:51 +00:00
"count": 100,
"feed_url": "http://elanaspantry.com/feed/"
2015-07-20 13:49:34 +00:00
}
,
{
/* "name" : "JobServe",*/
2015-07-21 09:50:51 +00:00
"count": 100,
"feed_url": "http://feeds.feedburner.com/Paleomg-PaleoRecipes"
2015-07-20 13:49:34 +00:00
},
{
/* "name" : "JobServe",*/
2015-07-21 09:50:51 +00:00
"count": 100,
"feed_url": "http://civilizedcavemancooking.com/feed/"
2015-07-20 13:49:34 +00:00
}
]
};
var braider_options = {
2015-07-21 09:50:51 +00:00
feeds: feeds,
indent: " ",
date_sort_order: "desc", // Newest first
log_level: "warn",
2015-07-23 10:37:04 +00:00
dedupe_fields: ['link', 'guid'],
plugins_directories : [__dirname + "/plugins/"]
2015-07-20 13:49:34 +00:00
};
var rss_braider = RssBraider.createClient(braider_options);
// Override logging level (debug, info, warn, err, off)
rss_braider.logger.level('off');
2015-07-21 09:50:51 +00:00
rss_braider.processFeed('simple_test_feed', 'json', function (err, data) {
if (err) {
return console.log(err);
}
var j = JSON.parse(data);
var ejsOutput = ejs.compile(str)(j);
2015-07-27 12:52:34 +00:00
fs.writeFile(__dirname + "/html/" + outputFile + ".json", data, function (err) {
if (err) {
return console.log(err);
}
console.log("The file was saved!");
});
2015-07-21 09:50:51 +00:00
fs.writeFile(__dirname + "/html/" + outputFile + ".html", ejsOutput, function (err) {
if (err) {
return console.log(err);
}
console.log("The file was saved!");
});
});
rss_braider.processFeed('simple_test_feed', 'rss', function (err, data) {
2015-07-20 13:49:34 +00:00
if (err) {
return console.log(err);
}
2015-07-21 09:50:51 +00:00
fs.writeFile(__dirname + "/html/" + outputFile + ".xml", data, function (err) {
if (err) {
2015-07-20 14:01:47 +00:00
return console.log(err);
}
console.log("The file was saved!");
});
2015-07-20 14:13:36 +00:00
});