2018-08-09 16:05:59 +00:00
|
|
|
var outputFile = 'jobs-local',
|
|
|
|
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:
|
2015-07-23 10:37:04 +00:00
|
|
|
// feeds.simple_test_feed = require("./config/feed").feed;
|
|
|
|
// Or define in-line
|
|
|
|
feeds.simple_test_feed = {
|
2018-08-09 16:05:59 +00:00
|
|
|
'feed_name': 'feed',
|
|
|
|
'default_count': 1,
|
|
|
|
'no_cdata_fields': [], // Don't wrap these fields in CDATA tags
|
|
|
|
'plugins': [
|
|
|
|
'filter_show',
|
|
|
|
'filter_location',
|
|
|
|
'filter_reject',
|
|
|
|
'filter_md_jobs',
|
2018-08-10 09:11:24 +00:00
|
|
|
'filter_today_only'
|
2016-04-18 12:49:38 +00:00
|
|
|
],
|
2018-08-09 16:05:59 +00:00
|
|
|
'meta': {
|
|
|
|
'title': 'Jobs',
|
|
|
|
'description': 'Combined Jobs Feed',
|
|
|
|
'site_url': 'http://pipes.silvrtree.co.uk/jobs-local.xml'
|
|
|
|
},
|
2018-08-10 09:11:24 +00:00
|
|
|
'sources': [
|
|
|
|
{
|
|
|
|
'count': 100,
|
|
|
|
'feed_url': 'http://45.33.114.116:8080/https%3A%2F%2Fwww.jobserve.com%2FMySearch%2FBAEBF3BDF82B8FEF.rss'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'count': 100,
|
|
|
|
'feed_url': 'http://45.33.114.116:8080/https%3A%2F%2Fwww.jobserve.com%2FMySearch%2F9BCBF25C586A0E3F.rss'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'count': 100,
|
|
|
|
'feed_url': 'http://45.33.114.116:8080/https%3A%2F%2Fwww.jobserve.com%2FMySearch%2FF3A56475D5FD4966.rss'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'count': 100,
|
|
|
|
'feed_url': 'http://45.33.114.116:8080/https%3A%2F%2Fwww.jobserve.com%2FMySearch%2F4E2AC50E02AD128B.rss'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'count': 100,
|
|
|
|
'feed_url': 'http://45.33.114.116:8080/https%3A%2F%2Fwww.jobserve.com%2FMySearch%2F6DA9769BA89834AA.rss'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'count': 100,
|
|
|
|
'feed_url': 'http://45.33.114.116:8080/https%3A%2F%2Fwww.jobserve.com%2FMySearch%2FEDF47BEA6B31EF.rss'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'count': 100,
|
|
|
|
'feed_url': 'http://45.33.114.116:8080/https%3A%2F%2Fwww.jobserve.com%2FMySearch%2F3CAD044BEF2BFA.rss'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'count': 100,
|
|
|
|
'feed_url': 'http://45.33.114.116:8080/https%3A%2F%2Fwww.jobserve.com%2FMySearch%2FC7B25D86D0844A.rss'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'count': 100,
|
|
|
|
'feed_url': 'http://45.33.114.116:8080/https%3A%2F%2Fwww.jobserve.com%2FMySearch%2F64A3EEF615FA4C.rss'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'count': 100,
|
|
|
|
'feed_url': 'http://45.33.114.116:8080/http%3A%2F%2Fwww.s1jobs.com%2Fxml%2Fm7dp711z2r.xml'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'count': 100,
|
|
|
|
'feed_url': 'http://45.33.114.116:8080/http%3A%2F%2Fwww.s1jobs.com%2Fxml%2Fpfvf7o7z2r.xml'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'count': 100,
|
|
|
|
'feed_url': 'http://45.33.114.116:8080/http%3A%2F%2Fwww.s1jobs.com%2Fxml%2Flluqnt8z2r.xml'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'count': 100,
|
|
|
|
'feed_url': 'http://45.33.114.116:8080/http%3A%2F%2Fwww.s1jobs.com%2Fxml%2Ftu33qt8z2r.xml'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'count': 100,
|
|
|
|
'feed_url': 'http://45.33.114.116:8080/http%3A%2F%2Fwww.s1jobs.com%2Fxml%2Fu3btnz8z2r.xml'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'count': 100,
|
|
|
|
'feed_url': 'http://45.33.114.116:8080/https%3A%2F%2Fwww.technojobs.co.uk%2Frss.php%2Fglasgow%2Fsearchtypeand%2FlocationScotland%2Fsortbyrelevant%2Fjobtypeall'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'count': 100,
|
|
|
|
'feed_url': 'http://45.33.114.116:8080/https%3A%2F%2Fwww.jobserve.com%2FMySearch%2F6FC7E9ED5F042ECB.rss'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'count': 100,
|
|
|
|
'feed_url': 'http://45.33.114.116:8080/http%3A%2F%2Fwww.s1jobs.com%2Fxml%2Fb1d7e6c3a9a11964z3r.xml'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'count': 100,
|
|
|
|
'feed_url': 'http://45.33.114.116:8080/https%3A%2F%2Fwww.jobserve.com%2FMySearch%2FCA49421A86CA3F74.rss'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'count': 100,
|
|
|
|
'feed_url': 'http://45.33.114.116:8080/http%3A%2F%2Fwww.s1jobs.com%2Fxml%2Fddeded091b6f6d33z3r.xml'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'count': 100,
|
|
|
|
'feed_url': 'http://45.33.114.116:8080/http%3A%2F%2Fwww.s1jobs.com%2Fxml%2F3eafc1ea20f1ca02z3r.xml'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'count': 100,
|
|
|
|
'feed_url': 'http://45.33.114.116:8080/https%3A%2F%2Fwww.cwjobs.co.uk%2FJobSearch%2FRSS.aspx%3FKeywords%3Dhtml%2Ces6'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'count': 100,
|
|
|
|
'feed_url': 'http://45.33.114.116:8080/https%3A%2F%2Fwww.cwjobs.co.uk%2FJobSearch%2FRSS.aspx%3FKeywords%3Dnodejs'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'count': 100,
|
|
|
|
'feed_url': 'http://45.33.114.116:8080/https%3A%2F%2Fwww.cwjobs.co.uk%2FJobSearch%2FRSS.aspx%3FKeywords%3Dbackbone'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'count': 100,
|
|
|
|
'feed_url': 'http://45.33.114.116:8080/https%3A%2F%2Fwww.cwjobs.co.uk%2FJobSearch%2FRSS.aspx%3FKeywords%3Diot'
|
|
|
|
}
|
|
|
|
]
|
2018-08-09 16:05:59 +00:00
|
|
|
};
|
2016-04-18 12:49:38 +00:00
|
|
|
|
|
|
|
var braider_options = {
|
2018-08-09 16:05:59 +00:00
|
|
|
'feeds': feeds,
|
|
|
|
'indent': ' ',
|
|
|
|
'date_sort_order': 'desc', // Newest first
|
|
|
|
'log_level': 'warn',
|
|
|
|
'dedupe_fields': ['link', 'guid'],
|
|
|
|
'plugins_directories': [`${__dirname }/plugins/`]
|
2015-07-23 10:37:04 +00:00
|
|
|
};
|
|
|
|
var rss_braider = RssBraider.createClient(braider_options);
|
|
|
|
|
|
|
|
// Override logging level (debug, info, warn, err, off)
|
2018-08-09 16:05:59 +00:00
|
|
|
rss_braider.logger.level('error');
|
2015-07-23 10:37:04 +00:00
|
|
|
|
2018-08-09 16:05:59 +00:00
|
|
|
rss_braider.processFeed('simple_test_feed', 'json', function (err, data) {
|
|
|
|
if (err)
|
|
|
|
return console.log(err);
|
2015-07-23 10:37:04 +00:00
|
|
|
|
2018-08-09 16:05:59 +00:00
|
|
|
var j = JSON.parse(data);
|
|
|
|
var ejsOutput = ejs.compile(str)(j);
|
2015-07-23 10:37:04 +00:00
|
|
|
|
2018-08-09 16:05:59 +00:00
|
|
|
fs.writeFile(`${__dirname }/dist/${ outputFile }.html`, ejsOutput, function (err) {
|
|
|
|
if (err)
|
|
|
|
return console.log(err);
|
2015-07-23 10:37:04 +00:00
|
|
|
|
2018-08-09 16:05:59 +00:00
|
|
|
console.log('The file was saved!');
|
|
|
|
});
|
2015-07-23 10:37:04 +00:00
|
|
|
|
2018-08-09 16:05:59 +00:00
|
|
|
fs.writeFile(`${__dirname }/dist/${ outputFile }.json`, data, function (err) {
|
|
|
|
if (err) {
|
|
|
|
logger.error(err);
|
|
|
|
|
|
|
|
return console.log(err);
|
|
|
|
}
|
2015-07-23 10:37:04 +00:00
|
|
|
|
2018-08-09 16:05:59 +00:00
|
|
|
console.log('The file was saved!');
|
|
|
|
});
|
|
|
|
});
|
2015-07-23 10:37:04 +00:00
|
|
|
|
2018-08-09 16:05:59 +00:00
|
|
|
rss_braider.processFeed('simple_test_feed', 'rss', function (err, data) {
|
|
|
|
if (err)
|
|
|
|
return console.log(err);
|
2015-07-23 10:37:04 +00:00
|
|
|
|
2018-08-09 16:05:59 +00:00
|
|
|
fs.writeFile(`${__dirname }/dist/${ outputFile }.xml`, data, function (err) {
|
|
|
|
if (err)
|
|
|
|
return console.log(err);
|
2015-07-23 10:37:04 +00:00
|
|
|
|
2018-08-09 16:05:59 +00:00
|
|
|
console.log('The file was saved!');
|
|
|
|
});
|
2015-07-23 10:37:04 +00:00
|
|
|
});
|