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

node-rss

v1.0.5

Published

Node.js package for efficently creating RSS feeds

Downloads

807

Readme

node-rss

A simple node.js RSS feed builder

Why another RSS module?

None of the other node.js RSS modules that I could find supported the flexibility that I wanted or were too slow. Additionally, many of them seemed overly complex when all we're doing here is building a RSS feed. Not rocket science.

Install

npm install node-rss

Dependencies

Update (6/18/2015): This step should no longer be necessary.

node-rss uses the libxmljs library to construct the actual feed. Unfortunately, some of the features of the library that are needed are only available in the current master branch. You will need to download the libxmljs source, compile, and install it yourself. Fortunately, this is fairly straight forward. https://github.com/polotek/libxmljs/

You will also need to have the libxml2 AND libxml2-dev packages installed on your system.

Usage

    // this exposes two methods: createNewFeed and getFeedXML
    var rss = require('node-rss');

    // first we create a "feed" object that will define your feed
    // method signature: function createNewFeed(title, link, desc, author, feedLink, options)
    // title : title of your feed
    // link : link to your website
    // desc : description of your feed
    // author : author of the feed
    // feedLink : link to the feed
    // options : additional options, explained below
    var feed = rss.createNewFeed('Blog Most Recent', 'http://someurl.com/',
                                'Most recent blog entries from blog',
                                'EJ Bensing',
                                'http://someurl.com/rss/MostRecent.xml',
                                {'CustomTag' : 'This is a custom tag under the channel tag!' });

    // the additional options parameter can essentially be used to
    // arbitrarily change the xml that will be created or other defaults.
    // currently, it only supports basic tags, where it will take a
    // key : value and turn it into <key>value</key>, but future releases
    // will contain the ability to specify attributes

    //next, we need to add some items to the feed
    // create some dummy data to loop over...
    var blogs = [
      {title: 'blog post 1', url : 'http://someurl.com/blog1', pubDate : new Date(), description: 'this is a description' },
      {title: 'blog post 2', url : 'http://someurl.com/blog2', pubDate : new Date(), description: 'this is a description' },
      {title: 'blog post 3', url : 'http://someurl.com/blog3', pubDate : new Date(), description: 'this is a description' },
      {title: 'blog post 4', url : 'http://someurl.com/blog4', pubDate : new Date(), description: 'this is a description' },
      {title: 'blog post 5', url : 'http://someurl.com/blog5', pubDate : new Date(), description: 'this is a description' },
      {title: 'blog post 6', url : 'http://someurl.com/blog6', pubDate : new Date(), description: 'this is a description' },
    ];


    // add some items to the feed
    // each feed object has a function addNewItem which should be used for adding new items
    // method signature : function addNewItem(itemTitle, itemLink, pubDate, description, fields)
    // itemTitle : Title of the item
    // itemLink : Link to the item
    // pubDate : Date the item was created/published
    // description : description of item
    // fields : functions exactly like the "options" parameter of createNewFeed,
    // allows the user to add arbitrary tags to an item
    blogs.forEach(function (blog) {
        feed.addNewItem(blog.title, blog.url, blog.pubDate, blog.description, {});
    });

    // now to get the XML simply call the getFeedXML function
    var xmlString = rss.getFeedXML(feed);

Other

The "feed" object has a defaults property. Inside this is a dictionary of default values.

cdata : a list of tag names whose content should be "escaped" in CDATA tags

tests

In the process of building these...

TODO

- add tests
- add support for attributes on custom tags
- add some express.js middleware
- ?? give me suggestions

Change log

Version 1.0.5 - Updated libxml version to 0.15.x to support node.js 4.x (Thanks @dhendo)

Version 1.0.4 - Updated libxml version to 0.14.x to support compilation on OSX (Thanks @jmathews)

Version 1.0.3 - update libxml version to 0.13.0