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: ,
|
2016-03-15 13:20: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-08-14 09:55:39 +00:00
|
|
|
"plugins": ['filter_3_days', "fix_images", 'fix_scripts'],
|
|
|
|
"sources": [{
|
2016-06-15 13:38:21 +00:00
|
|
|
|
2015-08-14 09:55:39 +00:00
|
|
|
"count": 100,
|
|
|
|
"feed_url": "http://feeds.feedburner.com/PaleoPlan"
|
|
|
|
}, {
|
2016-06-15 13:38:21 +00:00
|
|
|
|
2015-08-14 09:55:39 +00:00
|
|
|
"count": 100,
|
|
|
|
"feed_url": "http://nomnompaleo.com/rss"
|
|
|
|
}, {
|
2016-06-15 13:38:21 +00:00
|
|
|
|
2015-08-14 09:55:39 +00:00
|
|
|
"count": 100,
|
|
|
|
"feed_url": "http://thepaleodiet.com/feed/"
|
|
|
|
}, {
|
2016-06-15 13:38:21 +00:00
|
|
|
|
2015-08-14 09:55:39 +00:00
|
|
|
"count": 100,
|
|
|
|
"feed_url": "http://paleoleap.com/feed/"
|
|
|
|
}, {
|
2016-06-15 13:38:21 +00:00
|
|
|
|
2015-08-14 09:55:39 +00:00
|
|
|
"count": 100,
|
|
|
|
"feed_url": "http://ultimatepaleoguide.com/feed/"
|
|
|
|
}, {
|
2016-06-15 13:38:21 +00:00
|
|
|
|
2015-08-14 09:55:39 +00:00
|
|
|
"count": 100,
|
|
|
|
"feed_url": "http://elanaspantry.com/feed/"
|
|
|
|
}, {
|
2016-06-15 13:38:21 +00:00
|
|
|
|
2015-08-14 09:55:39 +00:00
|
|
|
"count": 100,
|
|
|
|
"feed_url": "http://feeds.feedburner.com/Paleomg-PaleoRecipes"
|
|
|
|
}, {
|
2016-06-15 13:38:21 +00:00
|
|
|
|
2015-08-14 09:55:39 +00:00
|
|
|
"count": 100,
|
|
|
|
"feed_url": "http://civilizedcavemancooking.com/feed/"
|
2016-01-22 16:35:47 +00:00
|
|
|
}, {
|
2016-06-15 13:38:21 +00:00
|
|
|
|
2016-01-22 16:35:47 +00:00
|
|
|
"count": 100,
|
|
|
|
"feed_url": "http://www.ruled.me/feed/"
|
2016-07-05 10:09:41 +00:00
|
|
|
}/*, {
|
2016-06-15 13:38:21 +00:00
|
|
|
|
2016-05-18 16:00:38 +00:00
|
|
|
"count": 100,
|
|
|
|
"feed_url": "http://www.primalbro.com/blog?format=RSS"
|
2016-07-05 10:09:41 +00:00
|
|
|
}*/
|
2016-05-18 16:00:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
]
|
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
|
2016-07-05 10:09:41 +00:00
|
|
|
log_level: "error",
|
2015-07-31 10:45:38 +00:00
|
|
|
dedupe_fields: ['guid'],
|
2015-08-14 09:55:39 +00:00
|
|
|
plugins_directories: [__dirname + "/plugins/"]
|
2015-07-20 13:49:34 +00:00
|
|
|
};
|
|
|
|
var rss_braider = RssBraider.createClient(braider_options);
|
|
|
|
|
2016-03-15 13:20:34 +00:00
|
|
|
// Override logging level (debug, info, warn, err, off)
|
2016-07-05 10:09:41 +00:00
|
|
|
rss_braider.logger.level('error');
|
2015-07-20 13:49:34 +00:00
|
|
|
|
2015-08-14 09:55:39 +00:00
|
|
|
rss_braider.processFeed('simple_test_feed', 'json', function(err, data) {
|
2015-07-21 09:50:51 +00:00
|
|
|
if (err) {
|
|
|
|
return console.log(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
var j = JSON.parse(data);
|
|
|
|
var ejsOutput = ejs.compile(str)(j);
|
|
|
|
|
2016-03-15 13:20:34 +00:00
|
|
|
fs.writeFile(__dirname + "/dist/" + outputFile + ".json", data, function(err) {
|
2015-07-27 12:52:34 +00:00
|
|
|
if (err) {
|
|
|
|
return console.log(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log("The file was saved!");
|
|
|
|
});
|
|
|
|
|
2015-07-31 10:45:38 +00:00
|
|
|
/*fs.writeFile(__dirname + "/html/" + outputFile + ".html", ejsOutput, function (err) {
|
2015-07-21 09:50:51 +00:00
|
|
|
|
|
|
|
if (err) {
|
|
|
|
return console.log(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log("The file was saved!");
|
2015-07-31 10:45:38 +00:00
|
|
|
});*/
|
2015-07-21 09:50:51 +00:00
|
|
|
});
|
|
|
|
|
2015-07-31 10:45:38 +00:00
|
|
|
/*
|
2015-07-21 09:50:51 +00:00
|
|
|
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
|
|
|
});
|
2015-07-31 10:45:38 +00:00
|
|
|
*/
|