mirror of
https://gitlab.silvrtree.co.uk/martind2000/rss-braider.git
synced 2025-01-25 17:46:18 +00:00
RSS-26: Example code
This commit is contained in:
parent
67bd0a78eb
commit
701af133ab
21
examples/plugins/add_content_encoded_block.js
Normal file
21
examples/plugins/add_content_encoded_block.js
Normal file
@ -0,0 +1,21 @@
|
||||
// Put the description into content:encoded block
|
||||
// Ex:
|
||||
// <content:encoded>
|
||||
// <![CDATA[<p>Stewart let the news slip during a taping of his show today.]]>
|
||||
// </content:encoded>
|
||||
module.exports = function (item, itemOptions, source) {
|
||||
if (!item || !itemOptions) {
|
||||
return;
|
||||
}
|
||||
if (item["content:encoded"] && item["content:encoded"]["#"]){
|
||||
var content_encoded = item["content:encoded"]["#"];
|
||||
itemOptions.custom_elements.push(
|
||||
{ "content:encoded":
|
||||
{
|
||||
_cdata: content_encoded
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
return itemOptions;
|
||||
};
|
11
examples/plugins/capitalize_title.js
Normal file
11
examples/plugins/capitalize_title.js
Normal file
@ -0,0 +1,11 @@
|
||||
module.exports = function (item, itemOptions, source) {
|
||||
if (!item || !itemOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (itemOptions.title) {
|
||||
itemOptions.title = itemOptions.title.toUpperCase();
|
||||
}
|
||||
|
||||
return itemOptions;
|
||||
};
|
8
examples/plugins/filter_out_all_articles.js
Normal file
8
examples/plugins/filter_out_all_articles.js
Normal file
@ -0,0 +1,8 @@
|
||||
module.exports = function (item, itemOptions, source) {
|
||||
if (!item || !itemOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
// This plugin removes all items by returning null instead of the processed itemOptions
|
||||
return null;
|
||||
};
|
19
examples/use_plugins.js
Normal file
19
examples/use_plugins.js
Normal file
@ -0,0 +1,19 @@
|
||||
var RssBraider = require('../index'),
|
||||
feed_obj = {};
|
||||
|
||||
feed_obj.filefeed = require("./config/feed_with_plugins").feed;
|
||||
|
||||
var braider_options = {
|
||||
feeds : feed_obj,
|
||||
indent : " ",
|
||||
plugins_directories : [__dirname + "/plugins/"],
|
||||
log_level : 'debug'
|
||||
};
|
||||
var rss_braider = RssBraider.createClient(braider_options);
|
||||
|
||||
rss_braider.processFeed('filefeed', 'rss', function(err, data){
|
||||
if (err) {
|
||||
return console.log(err);
|
||||
}
|
||||
console.log(data);
|
||||
});
|
Loading…
Reference in New Issue
Block a user