194 lines
4.4 KiB
JavaScript
194 lines
4.4 KiB
JavaScript
var outputFile = 'jobs-special', 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
|
|
|
|
|
|
/*
|
|
"plugins": [
|
|
'filter_location', 'filter_reject', 'filter_md_jobs', 'filter_today_only'
|
|
]
|
|
*/
|
|
feeds.simple_test_feed = {
|
|
"feed_name": "feed", "default_count": 1, "no_cdata_fields": [], // Don't wrap these fields in CDATA tags
|
|
"plugins": [
|
|
'filter_location', 'filter_reject', 'filter_md_jobs', 'filter_today_only'
|
|
], "meta": {
|
|
"title": "Jobs",
|
|
"description": "Combined Jobs Feed",
|
|
'site_url': 'http://pipes.silvrtree.co.uk/jobs-special.xml'
|
|
}, "sources": [
|
|
|
|
|
|
{
|
|
|
|
"count": 100,
|
|
"feed_url": "http://www.jobserve.com/MySearch/6DA9769BA89834AA.rss"
|
|
} ,
|
|
{
|
|
|
|
"count": 100,
|
|
"feed_url": "http://www.JobServe.com/MySearch/EDF47BEA6B31EF.rss"
|
|
},
|
|
{
|
|
|
|
"count": 100,
|
|
"feed_url": "http://www.JobServe.com/MySearch/3CAD044BEF2BFA.rss"
|
|
},
|
|
{
|
|
|
|
"count": 100,
|
|
"feed_url": "http://www.JobServe.com/MySearch/C7B25D86D0844A.rss"
|
|
},
|
|
{
|
|
|
|
"count": 100,
|
|
"feed_url": "http://www.JobServe.com/MySearch/64A3EEF615FA4C.rss"
|
|
},
|
|
{
|
|
|
|
"count": 100,
|
|
"feed_url": "http://www.s1jobs.com/xml/m7dp711z2r.xml"
|
|
},
|
|
{
|
|
|
|
"count": 100,
|
|
"feed_url": "http://www.s1jobs.com/xml/pfvf7o7z2r.xml"
|
|
},
|
|
{
|
|
|
|
"count": 100,
|
|
"feed_url": "http://www.s1jobs.com/xml/lluqnt8z2r.xml"
|
|
},
|
|
{
|
|
|
|
"count": 100,
|
|
"feed_url": "http://www.s1jobs.com/xml/tu33qt8z2r.xml"
|
|
},
|
|
{
|
|
|
|
"count": 100,
|
|
"feed_url": "http://www.s1jobs.com/xml/u3btnz8z2r.xml"
|
|
},
|
|
{
|
|
|
|
"count": 100,
|
|
"feed_url": "http://www.purelyit.co.uk/cgi-bin/advsearch?rss_feed=1&daysback=1&jbe_id=33256062"
|
|
},
|
|
{
|
|
|
|
"count": 100,
|
|
"feed_url": "http://www.purelyit.co.uk/cgi-bin/advsearch?rss_feed=1&daysback=1&jbe_id=33450169"
|
|
},
|
|
{
|
|
|
|
"count": 100,
|
|
"feed_url": "http://www.purelyit.co.uk/cgi-bin/advsearch?rss_feed=1&daysback=1&jbe_id=34517029"
|
|
},
|
|
{
|
|
|
|
"count": 100,
|
|
"feed_url": "http://www.purelyit.co.uk/cgi-bin/advsearch?rss_feed=1&daysback=1&jbe_id=34888105"
|
|
},
|
|
{
|
|
|
|
"count": 100,
|
|
"feed_url": "http://www.jobserve.com/MySearch/6FC7E9ED5F042ECB.rss"
|
|
},
|
|
{
|
|
|
|
"count": 100,
|
|
"feed_url": "http://www.s1jobs.com/xml/b1d7e6c3a9a11964z3r.xml"
|
|
},
|
|
{
|
|
|
|
"count": 100,
|
|
"feed_url": "http://www.s1jobs.com/xml/b1d7e6c3a9a11964z3r.xml"
|
|
},
|
|
{
|
|
|
|
"count": 100,
|
|
"feed_url": "http://www.jobserve.com/MySearch/CA49421A86CA3F74.rss"
|
|
},
|
|
{
|
|
|
|
"count": 100,
|
|
"feed_url": "http://www.s1jobs.com/xml/ddeded091b6f6d33z3r.xml"
|
|
},
|
|
{
|
|
|
|
"count": 100,
|
|
"feed_url": "http://www.s1jobs.com/xml/3eafc1ea20f1ca02z3r.xml"
|
|
}
|
|
|
|
]
|
|
};
|
|
|
|
var braider_options = {
|
|
feeds: feeds,
|
|
indent: " ",
|
|
date_sort_order: "desc", // Newest first
|
|
log_level: "warn",
|
|
dedupe_fields: ['link', 'guid'],
|
|
plugins_directories: [__dirname + "/plugins/"]
|
|
};
|
|
console.log('Working..');
|
|
var rss_braider = RssBraider.createClient(braider_options);
|
|
|
|
// Override logging level (debug, info, warn, err, off)
|
|
rss_braider.logger.level('debug');
|
|
|
|
/*rss_braider.processFeed('simple_test_feed', 'json', function(err, data) {
|
|
console.warn('A');
|
|
if (err) {
|
|
return console.error(err);
|
|
}
|
|
|
|
console.warn('B');
|
|
var j = JSON.parse(data);
|
|
console.warn('C');
|
|
var ejsOutput = ejs.compile(str)(j);
|
|
|
|
console.warn('D')
|
|
fs.writeFile(__dirname + "/dist/" + outputFile + ".html",
|
|
ejsOutput,
|
|
function(err) {
|
|
|
|
if (err) {
|
|
return console.log(err);
|
|
}
|
|
|
|
console.log("The file was saved!");
|
|
});
|
|
|
|
fs.writeFile(__dirname + "/dist/" + outputFile + ".json",
|
|
data,
|
|
function(err) {
|
|
if (err) {
|
|
logger.error(err);
|
|
return console.log(err);
|
|
}
|
|
|
|
console.log("The file was saved!");
|
|
});
|
|
});
|
|
|
|
*/
|
|
rss_braider.processFeed('simple_test_feed', 'rss', function(err, data) {
|
|
if (err) {
|
|
return console.log(err);
|
|
}
|
|
console.log('Saving', __dirname + "/dist/" + outputFile + ".xml");
|
|
fs.writeFile(__dirname + "/dist/" + outputFile + ".xml", data, function(err) {
|
|
if (err) {
|
|
return console.log(err);
|
|
}
|
|
|
|
console.log("The file was saved!");
|
|
});
|
|
});
|