2015-07-21 11:03:44 +00:00
|
|
|
var outputFile = 'tech',
|
|
|
|
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'),
|
|
|
|
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": {
|
2015-07-21 12:24:46 +00:00
|
|
|
"title": "Technology",
|
2015-07-21 11:03:44 +00:00
|
|
|
"description": "Combined Tech Feed",
|
|
|
|
'site_url': 'http://pipes.silvrtree.co.uk/tech.xml'
|
|
|
|
},
|
2015-08-12 10:39:59 +00:00
|
|
|
"plugins": ['filter_3_days', 'fix_images'],
|
|
|
|
"sources": [{
|
|
|
|
"count": 100,
|
|
|
|
"feed_url": "http://feeds.feedburner.com/lenovoblogs/designmatters"
|
|
|
|
}, {
|
|
|
|
"count": 100,
|
|
|
|
"feed_url": "http://www.engadget.com/rss.xml"
|
|
|
|
}, {
|
|
|
|
"count": 100,
|
|
|
|
"feed_url": "http://www.computerweekly.com/rss/All-Computer-Weekly-content.xml"
|
|
|
|
}, {
|
|
|
|
"count": 100,
|
|
|
|
"feed_url": "http://winsupersite.com/rss.xml"
|
|
|
|
}, {
|
|
|
|
"count": 100,
|
|
|
|
"feed_url": "https://feeds.feedburner.com/TheGadgeteer"
|
|
|
|
}, {
|
|
|
|
"count": 100,
|
|
|
|
"feed_url": "http://www.wired.com/category/gear/feed/"
|
|
|
|
}, {
|
|
|
|
"count": 100,
|
|
|
|
"feed_url": "https://feeds2.feedburner.com/AndroidCommunity"
|
|
|
|
}, {
|
|
|
|
"count": 100,
|
|
|
|
"feed_url": "https://feeds.feedburner.com/AndroidPolice"
|
2015-08-12 12:17:33 +00:00
|
|
|
}, {
|
|
|
|
"count": 100,
|
|
|
|
"feed_url": "https://feeds.feedburner.com/AndroidPolice"
|
|
|
|
}, {
|
2015-08-12 10:39:59 +00:00
|
|
|
"count": 100,
|
|
|
|
"feed_url": "https://feeds2.feedburner.com/PlanetAndroidCom"
|
|
|
|
}, {
|
|
|
|
"count": 100,
|
|
|
|
"feed_url": "http://www.theverge.com/rss/frontpage"
|
|
|
|
}, {
|
|
|
|
"count": 100,
|
|
|
|
"feed_url": "http://feed.androidauthority.com/"
|
|
|
|
}, {
|
|
|
|
"count": 100,
|
|
|
|
"feed_url": "https://feeds.feedburner.com/codinghorror"
|
|
|
|
}, {
|
|
|
|
"count": 100,
|
|
|
|
"feed_url": "http://www.androidcentral.com/feed"
|
|
|
|
}, {
|
|
|
|
"count": 100,
|
|
|
|
"feed_url": "http://www.anandtech.com/rss/"
|
|
|
|
}, {
|
|
|
|
"count": 100,
|
|
|
|
"feed_url": "https://medium.com/feed/google-developers"
|
|
|
|
}]
|
2015-07-21 11:03:44 +00:00
|
|
|
};
|
|
|
|
var braider_options = {
|
|
|
|
feeds: feeds,
|
|
|
|
indent: " ",
|
|
|
|
date_sort_order: "desc", // Newest first
|
|
|
|
log_level: "warn",
|
2015-08-07 13:22:57 +00:00
|
|
|
dedupe_fields: ['link', 'guid'],
|
2015-08-12 10:39:59 +00:00
|
|
|
plugins_directories: [__dirname + "/plugins/"]
|
2015-07-21 11:03:44 +00:00
|
|
|
};
|
|
|
|
var rss_braider = RssBraider.createClient(braider_options);
|
|
|
|
|
|
|
|
// Override logging level (debug, info, warn, err, off)
|
|
|
|
rss_braider.logger.level('off');
|
|
|
|
|
2015-08-12 10:39:59 +00:00
|
|
|
rss_braider.processFeed('simple_test_feed', 'json', function(err, data) {
|
2015-07-21 11:03:44 +00:00
|
|
|
if (err) {
|
|
|
|
return console.log(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
var j = JSON.parse(data);
|
|
|
|
var ejsOutput = ejs.compile(str)(j);
|
|
|
|
|
2015-08-12 10:39:59 +00:00
|
|
|
fs.writeFile(__dirname + "/html/" + outputFile + ".html", ejsOutput, function(err) {
|
2015-07-21 11:03:44 +00:00
|
|
|
|
|
|
|
if (err) {
|
|
|
|
return console.log(err);
|
|
|
|
}
|
|
|
|
|
2015-07-27 22:39:14 +00:00
|
|
|
console.log("The file was saved!");
|
|
|
|
});
|
|
|
|
|
2015-08-12 10:39:59 +00:00
|
|
|
fs.writeFile(__dirname + "/html/" + outputFile + ".json", data, function(err) {
|
2015-07-27 22:39:14 +00:00
|
|
|
if (err) {
|
|
|
|
return console.log(err);
|
|
|
|
}
|
|
|
|
|
2015-07-21 11:03:44 +00:00
|
|
|
console.log("The file was saved!");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2015-08-12 10:39:59 +00:00
|
|
|
rss_braider.processFeed('simple_test_feed', 'rss', function(err, data) {
|
2015-07-21 11:03:44 +00:00
|
|
|
if (err) {
|
|
|
|
return console.log(err);
|
|
|
|
}
|
2015-08-12 10:39:59 +00:00
|
|
|
fs.writeFile(__dirname + "/html/" + outputFile + ".xml", data, function(err) {
|
2015-07-21 11:03:44 +00:00
|
|
|
if (err) {
|
|
|
|
return console.log(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log("The file was saved!");
|
|
|
|
});
|
|
|
|
});
|