Giter Club home page Giter Club logo

node-rss's Introduction

RSS for Node

Fast and simple Javascript-based RSS generator/builder for Node projects.

Install

$ npm install rss

Tests

Use nodeunit to run the tests.

$ npm install nodeunit
$ nodeunit test

Usage

var RSS = require('rss');

/* lets create an rss feed */
var feed = new RSS({
        title: 'title',
        description: 'description',
        feed_url: 'http://example.com/rss.xml',
        site_url: 'http://example.com',
        image_url: 'http://example.com/icon.png',
        author: 'Dylan Greene'
    });

/* loop over data and add to feed */
feed.item({
    title:  'item title',
    description: 'use this for the content. It can include html.',
    url: 'http://example.com/article4?this&that', // link to the item
    guid: '1123', // optional - defaults to url
    author: 'Guest Author', // optional - defaults to feed author property
    date: 'May 27, 2012' // any format that js Date can parse.
    enclosure : {url:'...', file:'path-to-file'} // optional
});

// cache the xml
var xml = feed.xml();

Feed Options

  • title Title of your site or feed
  • description Optional. Short description of the feed.
  • feed_url Url to the rss feed.
  • site_url Url to the site that the feed is for.
  • image_url Optional. Small image for feed readers to use.
  • author Who owns this feed.

Item Options

In RSS an item can be used for a blog entry, project update, log entry, etc. Your rss feed an have any number of items. Ten to tenty is usually good.

  • title Title of this particular item.
  • description Content for the item. Can contain html but link and image urls must include the server name. (Note: I might change this to content in the next release.)
  • url Url to the item. This could be a blog entry.
  • guid A unique string feed readers use to know if an item is new or has already been seen. If you use a guid never change it. If you don't provide a guid then your item urls must be unique.
  • author Optional. If included it is the name of the item's creator. If not provided the item author will be the same as the feed author. This is typical except on multi-author blogs.
  • date The date and time of when the intem was created. Feed readers use this to determin the sort order. Some readers will also use it to determin if the content should be presented as unread.

Methods

  • item(item_options) - add an rss item, article, entry etc.
  • xml([indent]) - return the xml. If you pass in true it will use four spaces for indenting. If you prefer tabs use \t instead of true.

Notes

  • You do not need to escape anything. This module will escape characters when necessary.
  • This module is very fast but you might as well cache the output of xml() and serve it until something changes.

Upcoming features

  • Atom support
  • Feed validation
  • Feedburner integration
  • More customization
  • Express middleware for serving feeds
  • What else?

Contributing

Contributions to the project are welcome. Feel free to fork and improve. I accept pull requests and issues, especially when tests are included.

License

(The MIT License)

Copyright (c) 2011 Dylan Greene [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

node-rss's People

Contributors

dylang avatar langmi avatar victorjonsson avatar xdamman avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.