raix:rssfeed

v0.0.5Published 9 years ago

This package has not had recent updates. Please investigate it's current state before committing to using it in your project.

raix:rssfeed

A package for serving data in RSS 2.0 XML format for Meteor

What is it?

It serves published data mounted on http://mysite.meteor.com/rss/name

or with a querystring http://mysite.meteor.com/rss/news?foo=latest

How?

Add the package

  meteor add raix:rssfeed

Publish a feed

1RssFeed.publish('test', function(query) {
2  var self = this;
3  // We got 3 helpers:
4  // 1. self.setValue
5  // 2. self.addItem
6  // 3. self.cdata
7
8
9  // query is the parsed querystring as an object
10  // eg. foo=latest would be query.foo === 'latest'
11
12  // feed handler helpers
13  // this.cdata, this.setValue, this.addItem
14  self.setValue('title', self.cdata('My news'));
15  self.setValue('description', self.cdata('This is a live feed'));
16  self.setValue('link', 'http://mysite.meteor.com');
17  self.setValue('lastBuildDate', new Date());
18  self.setValue('pubDate', new Date());
19  self.setValue('ttl', 1);
20  // managingEditor, webMaster, language, docs, generator
21
22  newsCollection.find({}).forEach(function(doc) {
23    self.addItem({
24      title: doc.name,
25      description: doc.text,
26      link: 'http://mysite.meteor.com',
27      pubDate: new Date()
28      // title, description, link, guid, pubDate
29    });
30  });
31
32});

API

  • RssFeed.publish: function(name, handlerFunction)
  • RssFeed.unpublish: function(name)
Internal
  • RssFeed.createTag: function(key, value)
  • RssFeed.cdataValue: function(value)
  • RssFeed.objectToXML: function(sourceObject)

this in publish feed handler helpers

  • this.cdata: RssFeed.cdataValue
  • this.setValue: function(key, value)
  • this.addItem: function(itemObject)