Browse files

Added initial version of rss reader module

  • Loading branch information...
1 parent 25c2e02 commit 302280f3cd3eaec44ed85387b717cec26e1c6eeb @jheusala jheusala committed Sep 13, 2011
Showing with 34 additions and 0 deletions.
  1. +34 −0 lib/modules/rss.js
View
34 lib/modules/rss.js
@@ -0,0 +1,34 @@
+/*global Buffer: false, clearInterval: false, clearTimeout: false, console: false, global: false, exports:false, module: false, process: false, querystring: false, require: false, setInterval: false, setTimeout: false, util: false, __filename: false, __dirname: false */
+
+/*
+ * RSS Feed Reader Module
+ * Copyright 2011 Jaakko-Heikki Heusala <jheusala@iki.fi>
+ */
+
+var rssee = require('rssee');
+
+function RSSReaderModule(settings) {
+ var mod = this,
+ queue = [];
+ mod.settings = settings;
+ mod.routes = [];
+ mod.interval = null;
+ if(!mod.settings.interval) {
+ mod.settings.interval = 15*1000;
+ }
+ mod.rss = rssee.create({'interval':mod.settings.interval});
+ mod.on('article', function(a) {
+ queue.push(a);
+ });
+ mod.intervals = [[ function(cb) {
+ var a, title, link;
+ while(queue.length !== 0) {
+ a = queue.shift();
+ title = a.title || 'Untitled';
+ link = a.link || '[no link]';
+ cb('[rss] ' + title + ' ' + link);
+ }
+ }, mod.settings.interval]];
+}
+
+exports.Module = RSSReaderModule;

0 comments on commit 302280f

Please sign in to comment.