RSS-26: Example code

This commit is contained in:
Kip Gebhardt 2015-06-11 17:16:52 -07:00
parent 67bd0a78eb
commit 701af133ab
4 changed files with 59 additions and 0 deletions

View 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;
};

View 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;
};

View 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
View 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);
});