diff --git a/examples/plugins/add_content_encoded_block.js b/examples/plugins/add_content_encoded_block.js new file mode 100644 index 0000000..4f3e1f8 --- /dev/null +++ b/examples/plugins/add_content_encoded_block.js @@ -0,0 +1,21 @@ +// Put the description into content:encoded block +// Ex: +// +// Stewart let the news slip during a taping of his show today.]]> +// +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; +}; \ No newline at end of file diff --git a/examples/plugins/capitalize_title.js b/examples/plugins/capitalize_title.js new file mode 100644 index 0000000..35c8fa5 --- /dev/null +++ b/examples/plugins/capitalize_title.js @@ -0,0 +1,11 @@ +module.exports = function (item, itemOptions, source) { + if (!item || !itemOptions) { + return; + } + + if (itemOptions.title) { + itemOptions.title = itemOptions.title.toUpperCase(); + } + + return itemOptions; +}; \ No newline at end of file diff --git a/examples/plugins/filter_out_all_articles.js b/examples/plugins/filter_out_all_articles.js new file mode 100644 index 0000000..14d0759 --- /dev/null +++ b/examples/plugins/filter_out_all_articles.js @@ -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; +}; \ No newline at end of file diff --git a/examples/use_plugins.js b/examples/use_plugins.js new file mode 100644 index 0000000..983f540 --- /dev/null +++ b/examples/use_plugins.js @@ -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); +}); \ No newline at end of file