mirror of
https://gitlab.silvrtree.co.uk/martind2000/rss-braider.git
synced 2025-02-11 00:19:16 +00:00
RSS-26 - WIP restructuring the way plugins work to allow skipping of items/articles that don't meet criteria
This commit is contained in:
parent
8dcca51955
commit
66e6cb2d64
@ -203,7 +203,7 @@ RssBraider.prototype.processItem = function (item, source, feed_name) {
|
||||
// Run the plugins specified by the "plugins" section of the
|
||||
// feed config file to build out any custom elements or
|
||||
// do transforms
|
||||
self.runPlugins(item, itemOptions, source, feed_name);
|
||||
itemOptions = self.runPlugins(item, itemOptions, source, feed_name);
|
||||
|
||||
return itemOptions;
|
||||
};
|
||||
@ -211,16 +211,29 @@ RssBraider.prototype.processItem = function (item, source, feed_name) {
|
||||
RssBraider.prototype.runPlugins = function (item, itemOptions, source, feed_name) {
|
||||
var self = this,
|
||||
feed = self.feeds[feed_name] || {},
|
||||
plugins_list = feed.plugins || [];
|
||||
plugins_list = feed.plugins || [],
|
||||
ret_val;
|
||||
// Process the item through the desired feed plugins
|
||||
plugins_list.forEach(function(plugin_name){
|
||||
// plugins_list.forEach(function(plugin_name){
|
||||
for (var i = 0; i < plugins_list.length; i++) {
|
||||
var plugin_name = plugins_list[i];
|
||||
if (self.plugins[plugin_name]) {
|
||||
// logger.info("DEBUG runPlugins running " + plugin_name + " for item " + item.guid + " in feed: " + feed.meta.title);
|
||||
self.plugins[plugin_name](item, itemOptions, source);
|
||||
logger.info("DEBUG runPlugins running " + plugin_name + " for item " + item.guid + " in feed: " + feed.meta.title);
|
||||
itemOptions = self.plugins[plugin_name](item, itemOptions, source);
|
||||
} else {
|
||||
logger.error("A plugin named '" + plugin_name + "' hasn't been registered");
|
||||
}
|
||||
});
|
||||
|
||||
// If itemOptions comes back null, skip this item
|
||||
// as one of the plugins decided to toss it
|
||||
if (itemOptions === null) {
|
||||
logger.info("Plugin rejected item", plugin_name, item.guid, feed.meta.title);
|
||||
break;
|
||||
} else {
|
||||
logger.info("Plugin completed", plugin_name, item.guid, feed.meta.title);
|
||||
}
|
||||
}
|
||||
return itemOptions;
|
||||
};
|
||||
|
||||
// Dedupe articles in node-rss itemOptions format
|
||||
|
@ -51,4 +51,5 @@ module.exports = function (item, itemOptions, source) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return itemOptions;
|
||||
};
|
@ -17,4 +17,5 @@ module.exports = function (item, itemOptions, source) {
|
||||
}
|
||||
);
|
||||
}
|
||||
return itemOptions;
|
||||
};
|
@ -36,4 +36,5 @@ module.exports = function (item, itemOptions, source) {
|
||||
{ 'kqed:feed_url': item.feed_url }
|
||||
);
|
||||
}
|
||||
return itemOptions;
|
||||
};
|
@ -82,4 +82,6 @@ module.exports = function (item, itemOptions, source) {
|
||||
}
|
||||
});
|
||||
}
|
||||
return itemOptions;
|
||||
|
||||
};
|
@ -11,4 +11,5 @@ module.exports = function (item, itemOptions, source) {
|
||||
if (item["slash:comments"] && item["slash:comments"]["#"]){
|
||||
itemOptions.custom_elements.push({ "slash:comments": item["slash:comments"]["#"]});
|
||||
}
|
||||
return itemOptions;
|
||||
};
|
Loading…
Reference in New Issue
Block a user