npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rss-braider

v1.2.4

Published

Braid/aggregate/combine RSS feeds into a single RSS (or JSON) document. Optionally process through specified plugins.

Downloads

76

Readme

Build Status dependencies Status

Summary

Braid/aggregate one or more RSS feeds (file or url) into a single feed (RSS or JSON output). Process resulting feed through specified plugins. Automatic deduplication

Installation

npm install rss-braider

Test

npm install
npm test

Examples

$ cd examples
$ node simple.js  (combines 3 sources)
$ node use_plugins.js (combines 3 sources and runs a transformation plugin)

Code Example

var RssBraider = require('rss-braider'),
    feeds = {};

// Pull feeds from config files:
//      feeds.simple_test_feed = require("./config/feed").feed;
// Or define in-line
feeds.simple_test_feed = {
    "feed_name"             : "feed",
    "default_count"         : 1,
    "no_cdata_fields"       : [], // Don't wrap these fields in CDATA tags
    "meta" : {
        "title": "NPR Braided Feed",
        "description": "This is a test of two NPR"
    },
    "sources" : [
        {
            "name"              : "NPR Headlines",
            "count"             : 2,
            "feed_url"          : "http://www.npr.org/rss/rss.php?id=1001",
        },
        {
            "name"              : "NPR Sports",
            "count"             : 2,
            "feed_url"          : "http://www.npr.org/rss/rss.php?id=1055"
        }
    ]
};
var braider_options = {
    feeds           : feeds,
    indent          : "    ",
    date_sort_order : "desc", // Newest first
    log_level       : "debug"
};
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){
    if (err) {
        return console.log(err);
    }
    console.log(data);
});

Plugins

Plugins provide custom manipulation and filtering of RSS items/articles. See examples/plugins for examples.

A plugin operates by modifying the itemOptions object or by returning null which will exclude the item (article) from the resulting feed (See examples/plugins/filter_out_all_articles.js).

The itemsOptions object gets passed to node-rss to generate the RSS feeds, so read the documentation on that module and its use of custom namespaces. (https://github.com/dylang/node-rss)

Plugin Example

This plugin will capitalize the article title for all articles

module.exports = function (item, itemOptions, source) {
    if (!item || !itemOptions) {
        return;
    }

    if (itemOptions.title) {
        itemOptions.title = itemOptions.title.toUpperCase();
    }

    return itemOptions;
};

The plugin is registered with the feed in the feed config .js file and are run in order.

var feed = {
    "feed_name"         : "feed with plugins",
    "default_count"     : 1,
    "plugins"           : ['capitalize_title', 'plugin_template'],
...

Release Notes

1.0.0

Changed plugin architecture to allow filtering out of article/items by returning -1 instead of a modified itemsOptions object. This is a breaking change as it will require existing plugins to return itemsOptions instead of modifying the reference. See examples/plugins.