Updated jobs-local to generate html
This commit is contained in:
parent
9f81e18182
commit
d014b4be86
@ -1,4 +1,10 @@
|
||||
var RssBraider = require('rss-braider'), fs = require('fs'),
|
||||
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:
|
||||
@ -192,28 +198,43 @@ feeds.simple_test_feed = {
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
var braider_options = {
|
||||
feeds : feeds,
|
||||
indent : " ",
|
||||
date_sort_order : "desc", // Newest first
|
||||
log_level : "warn",
|
||||
plugins_directories : [__dirname + "/plugins/"],
|
||||
dedupe_fields : ['link','guid']
|
||||
feeds: feeds,
|
||||
indent: " ",
|
||||
date_sort_order: "desc", // Newest first
|
||||
log_level: "warn",
|
||||
dedupe_fields: ['link', 'guid']
|
||||
};
|
||||
var rss_braider = RssBraider.createClient(braider_options);
|
||||
|
||||
// Override logging level (debug, info, warn, err, off)
|
||||
rss_braider.logger.level('off');
|
||||
|
||||
// Output braided feed as rss. use 'json' for JSON output.
|
||||
rss_braider.processFeed('simple_test_feed', 'rss', function(err, data){
|
||||
// rss_braider.processFeed('simple_test_feed', 'json', function(err, data){
|
||||
rss_braider.processFeed('simple_test_feed', 'json', function (err, data) {
|
||||
if (err) {
|
||||
return console.log(err);
|
||||
}
|
||||
// console.log(data);
|
||||
fs.writeFile(__dirname + "/html/jobs-local.xml", data, function(err) {
|
||||
if(err) {
|
||||
|
||||
var j = JSON.parse(data);
|
||||
var ejsOutput = ejs.compile(str)(j);
|
||||
|
||||
fs.writeFile(__dirname + "/html/" + outputFile + ".html", ejsOutput, function (err) {
|
||||
|
||||
if (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);
|
||||
}
|
||||
fs.writeFile(__dirname + "/html/" + outputFile + ".xml", data, function (err) {
|
||||
if (err) {
|
||||
return console.log(err);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user