Rinser/tech.js

144 lines
4.2 KiB
JavaScript
Raw Normal View History

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'
},
"plugins": ['filter_3_days', 'fix_images', 'fix_scripts'],
2015-08-12 10:39:59 +00:00
"sources": [{
2015-08-14 20:34:08 +00:00
"count": 100,
"feed_url": "http://feeds.feedburner.com/lenovoblogs/designmatters"
2015-08-12 10:39:59 +00:00
}, {
2015-08-14 20:34:08 +00:00
"count": 100,
"feed_url": "http://www.engadget.com/rss.xml"
2015-08-12 10:39:59 +00:00
}, {
2015-08-14 20:34:08 +00:00
"count": 100,
"feed_url": "http://www.computerweekly.com/rss/All-Computer-Weekly-content.xml"
2015-08-12 10:39:59 +00:00
}, {
2015-08-14 20:34:08 +00:00
"count": 100,
"feed_url": "http://winsupersite.com/rss.xml"
2015-08-12 10:39:59 +00:00
}, {
2015-08-14 20:34:08 +00:00
"count": 100,
"feed_url": "https://feeds.feedburner.com/TheGadgeteer"
2015-08-12 10:39:59 +00:00
}, {
2015-08-14 20:34:08 +00:00
"count": 100,
"feed_url": "http://www.wired.com/category/gear/feed/"
2015-08-12 10:39:59 +00:00
}, {
2015-08-14 20:34:08 +00:00
"count": 100,
"feed_url": "https://feeds2.feedburner.com/AndroidCommunity"
2015-08-12 10:39:59 +00:00
}, {
2015-08-14 20:34:08 +00:00
"count": 100,
"feed_url": "https://feeds.feedburner.com/AndroidPolice"
2015-08-12 12:17:33 +00:00
}, {
2015-08-14 20:34:08 +00:00
"count": 100,
"feed_url": "https://feeds.feedburner.com/AndroidPolice"
2015-08-12 12:17:33 +00:00
}, {
2015-08-14 20:34:08 +00:00
"count": 100,
"feed_url": "https://feeds2.feedburner.com/PlanetAndroidCom"
2015-08-12 10:39:59 +00:00
}, {
2015-08-14 20:34:08 +00:00
"count": 100,
"feed_url": "http://www.theverge.com/rss/frontpage"
2015-08-12 10:39:59 +00:00
}, {
2015-08-14 20:34:08 +00:00
"count": 100,
"feed_url": "http://feed.androidauthority.com/"
2015-08-12 10:39:59 +00:00
}, {
2015-08-14 20:34:08 +00:00
"count": 100,
"feed_url": "https://feeds.feedburner.com/codinghorror"
2015-08-12 10:39:59 +00:00
}, {
2015-08-14 20:34:08 +00:00
"count": 100,
"feed_url": "http://www.androidcentral.com/feed"
2015-08-12 10:39:59 +00:00
}, {
2015-08-14 20:34:08 +00:00
"count": 100,
"feed_url": "http://www.anandtech.com/rss/"
2015-08-12 10:39:59 +00:00
}, {
2015-08-14 20:34:08 +00:00
"count": 100,
"feed_url": "https://medium.com/feed/google-developers"
},
2015-08-14 20:34:08 +00:00
{
"count": 100,
"feed_url": "http://feedproxy.google.com/typepad/alleyinsider/silicon_alley_insider"
}
,
{
"count": 100,
"feed_url": "http://techcrunch.com/feed/"
},
{
"count": 100,
"feed_url": "http://feeds.venturebeat.com/VentureBeat"
},
{
"count": 100,
"feed_url": "http://feeds2.feedburner.com/thenextweb"
}
]
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)
2016-02-12 13:10:16 +00:00
//rss_braider.logger.level('off');
2015-07-21 11:03:44 +00:00
2015-08-14 20:34:08 +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);
2016-03-15 13:20:34 +00:00
fs.writeFile(__dirname + "/dist/" + 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!");
});
2016-03-15 13:20:34 +00:00
fs.writeFile(__dirname + "/dist/" + 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!");
});
});
2016-03-15 13:20:34 +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);
}
2016-03-15 13:20:34 +00:00
fs.writeFile(__dirname + "/dist/" + 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!");
});
2016-03-15 13:20:34 +00:00
});*/