2015-02-11 02:54:25 +00:00
[![Build Status ](https://travis-ci.org/KQED/rss-braider.svg?branch=master )](https://travis-ci.org/KQED/rss-braider)
2015-02-13 03:44:33 +00:00
## Summary
2015-05-29 01:18:07 +00:00
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
2015-02-13 03:44:33 +00:00
## Installation
```
2015-05-29 00:57:33 +00:00
npm install rss-braider
2015-02-13 03:44:33 +00:00
```
## Test
`npm test`
## Examples
```
$ cd examples
2015-05-29 01:18:07 +00:00
$ node simple.js (combines 3 sources)
2015-05-29 01:01:47 +00:00
$ node plugins.js (combines 3 sources and runs a transformation plugin)
2015-02-13 03:44:33 +00:00
```
2015-05-29 01:01:47 +00:00
## Code Example
```js
var RssBraider = require('rss-braider'),
2015-05-29 01:18:07 +00:00
feeds = {};
2015-05-29 01:01:47 +00:00
2015-05-29 01:18:07 +00:00
// 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"
}
]
};
2015-05-29 01:01:47 +00:00
var braider_options = {
2015-05-29 01:18:07 +00:00
feeds : feeds,
2015-05-29 01:01:47 +00:00
indent : " ",
date_sort_order : "desc" // Newest first
};
var rss_braider = RssBraider.createClient(braider_options);
2015-05-29 01:18:07 +00:00
// Output braided feed as rss. use 'json' for JSON output.
rss_braider.processFeed('simple_test_feed', 'rss', function(err, data){
2015-05-29 01:01:47 +00:00
if (err) {
return console.log(err);
}
console.log(data);
});
2015-05-29 01:18:07 +00:00
```