Rinser/lifestyle.js

239 lines
6.2 KiB
JavaScript
Raw Normal View History

2015-07-21 09:50:51 +00:00
var outputFile = 'lifestyle',
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 15:56:35 +00:00
feeds = {};
// Pull feeds from config files: ,
// feeds.simple_test_feed = require("./config/feed").feed;
// Or define in-line
feeds.simple_test_feed = {
"feed_name" : "feed",
"default_count" : 1,
"no_cdata_fields" : [], // Don't wrap these fields in CDATA tags
"meta" : {
"title": "Lifestyle",
"description": "Combined Lifestyle Feed",
2015-07-20 21:25:42 +00:00
'site_url': 'http://pipes.silvrtree.co.uk/lifestyle.xml'
2015-07-20 15:56:35 +00:00
},
2015-07-27 12:49:21 +00:00
"plugins" : ['filter_3_days' ],
2015-07-20 15:56:35 +00:00
"sources" : [
{
2015-07-20 21:25:42 +00:00
2015-07-20 15:56:35 +00:00
"count" : 100,
"feed_url" : "http://feeds2.feedburner.com/acquire"
},
2015-07-20 21:25:42 +00:00
2015-07-20 15:56:35 +00:00
{
2015-07-20 21:25:42 +00:00
2015-07-20 15:56:35 +00:00
"count" : 100,
2015-07-20 21:25:42 +00:00
"feed_url" : "http://www.fhm.com/category/style/feed"
},
2015-07-20 15:56:35 +00:00
{
2015-07-20 21:25:42 +00:00
2015-07-20 15:56:35 +00:00
"count" : 100,
2015-07-20 21:25:42 +00:00
"feed_url" : "http://www.askmen.com/style.rss"
},
2015-07-20 15:56:35 +00:00
{
2015-07-20 21:25:42 +00:00
2015-07-20 15:56:35 +00:00
"count" : 100,
2015-07-20 21:25:42 +00:00
"feed_url" : "http://www.askmen.com/fine_living.rss"
2015-07-20 15:56:35 +00:00
},
{
2015-07-20 21:25:42 +00:00
2015-07-20 15:56:35 +00:00
"count" : 100,
2015-07-20 21:25:42 +00:00
"feed_url" : "http://www.askmen.com/money.rss"
2015-07-31 11:35:56 +00:00
}/*,
2015-07-20 15:56:35 +00:00
{
2015-07-20 21:25:42 +00:00
2015-07-20 15:56:35 +00:00
"count" : 100,
2015-07-20 21:25:42 +00:00
"feed_url" : "http://abetterguy.com/feed/"
2015-07-31 11:35:56 +00:00
}*/,
2015-07-20 21:25:42 +00:00
2015-07-20 15:56:35 +00:00
{
2015-07-20 21:25:42 +00:00
2015-07-20 15:56:35 +00:00
"count" : 100,
2015-07-20 21:25:42 +00:00
"feed_url" : "http://www.dmarge.com/feed"
2015-07-20 15:56:35 +00:00
},
{
2015-07-20 21:25:42 +00:00
2015-07-20 15:56:35 +00:00
"count" : 100,
2015-07-20 21:25:42 +00:00
"feed_url" : "http://www.esquire.com/rss/all.xml"
2015-07-20 15:56:35 +00:00
},
{
2015-07-20 21:25:42 +00:00
2015-07-20 15:56:35 +00:00
"count" : 100,
2015-07-20 21:25:42 +00:00
"feed_url" : "http://feeds.feedburner.com/gearpatrol"
2015-07-20 15:56:35 +00:00
},
2015-07-20 21:25:42 +00:00
2015-07-20 15:56:35 +00:00
{
2015-07-20 21:25:42 +00:00
2015-07-20 15:56:35 +00:00
"count" : 100,
2015-07-20 21:25:42 +00:00
"feed_url" : "http://www.getkempt.com/rss.xml"
2015-07-20 15:56:35 +00:00
},
{
2015-07-20 21:25:42 +00:00
2015-07-20 15:56:35 +00:00
"count" : 100,
2015-07-20 21:26:51 +00:00
"feed_url" : "http://feeds.feedburner.com/kinowear"
2015-07-20 15:56:35 +00:00
},
{
2015-07-20 21:25:42 +00:00
2015-07-20 15:56:35 +00:00
"count" : 100,
2015-07-20 21:25:42 +00:00
"feed_url" : "http://www.mensfitness.co.uk/feeds/all"
},
{
"count" : 100,
2015-07-20 21:26:51 +00:00
"feed_url" : "http://feeds.feedburner.com/TheArtOfManliness"
2015-07-20 21:25:42 +00:00
},
2015-07-20 15:56:35 +00:00
{
2015-07-20 21:25:42 +00:00
2015-07-20 15:56:35 +00:00
"count" : 100,
2015-07-20 21:26:51 +00:00
"feed_url" : "http://www.trunkclub.com/blog/feed"
2015-07-20 15:56:35 +00:00
},
{
2015-07-20 21:25:42 +00:00
2015-07-20 15:56:35 +00:00
"count" : 100,
2015-07-20 21:26:51 +00:00
"feed_url" : "http://feeds.feedburner.com/acontinuouslean/"
2015-07-20 15:56:35 +00:00
},
{
2015-07-20 21:25:42 +00:00
2015-07-20 15:56:35 +00:00
"count" : 100,
2015-07-20 21:25:42 +00:00
"feed_url" : "http://www.fashionbeans.com/feed/"
},
{
"count" : 100,
2015-07-20 21:26:51 +00:00
"feed_url" : "http://feeds.feedburner.com/MensFlair?format=xml"
2015-07-20 21:25:42 +00:00
},
{
"count" : 100,
2015-07-20 21:26:51 +00:00
"feed_url" : "http://feeds.feedburner.com/TheChoosyBeggar"
2015-07-20 21:25:42 +00:00
},
{
"count" : 100,
"feed_url" : "http://www.valetmag.com/distribution/rss_all.xml"
},
{
"count" : 100,
"feed_url" : "http://putthison.com/rss"
},
{
"count" : 100,
"feed_url" : "http://dieworkwear.com/rss"
},
{
"count" : 100,
"feed_url" : "http://menofhabit.tumblr.com/rss"
},
{
"count" : 100,
"feed_url" : "http://www.hodinkee.com/blog/rss.xml"
},
{
"count" : 100,
"feed_url" : "http://www.gq-magazine.co.uk/RSS"
},
{
"count" : 100,
"feed_url" : "http://feeds.feedburner.com/firstinwatches"
},
{
"count" : 100,
"feed_url" : "http://feeds2.feedburner.com/primermagazine/otzU"
},
{
"count" : 100,
"feed_url" : "http://chrisguillebeau.com/3x5/feed/"
},
{
"count" : 100,
"feed_url" : "http://feeds.feedburner.com/TheAwesomer"
},
{
"count" : 100,
"feed_url" : "http://bondclothes.blogspot.com/feeds/posts/default"
},
{
"count" : 100,
"feed_url" : "http://affordablebond007.tumblr.com/rss"
},
{
"count" : 100,
"feed_url" : "http://thecozyspace.tumblr.com/rss"
},
{
"count" : 100,
"feed_url" : "http://fourpins.com/feed/"
2015-07-20 15:56:35 +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-31 11:47:21 +00:00
dedupe_fields: ['link', 'guid'],
2015-07-23 10:37:04 +00:00
plugins_directories : [__dirname + "/plugins/"]
2015-07-20 15:56:35 +00:00
};
var rss_braider = RssBraider.createClient(braider_options);
// Override logging level (debug, info, warn, err, off)
2015-07-21 09:50:51 +00:00
rss_braider.logger.level('off');
2015-07-20 15:56:35 +00:00
2015-07-21 09:50:51 +00:00
rss_braider.processFeed('simple_test_feed', 'json', function (err, data) {
2015-07-20 15:56:35 +00:00
if (err) {
return console.log(err);
}
2015-07-21 09:50:51 +00:00
2015-07-31 11:47:21 +00:00
var j = JSON.parse(data);
var ejsOutput = ejs.compile(str)(j);
2015-07-31 10:49:19 +00:00
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-31 11:47:21 +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 11:47:21 +00:00
});
2015-07-21 09:50:51 +00:00
});
2015-07-31 11:47:21 +00:00
rss_braider.processFeed('simple_test_feed', 'rss', function (err, data) {
2015-07-31 12:10:04 +00:00
2015-07-21 09:50:51 +00:00
fs.writeFile(__dirname + "/html/" + outputFile + ".xml", data, function (err) {
if (err) {
2015-07-20 15:56:35 +00:00
return console.log(err);
}
console.log("The file was saved!");
});
2015-07-31 11:47:21 +00:00
});
2015-07-21 09:50:51 +00:00