Skip to content

Commit

Permalink
fixed aggregator config method
Browse files Browse the repository at this point in the history
  • Loading branch information
naggie committed Apr 23, 2013
1 parent 8597d12 commit 3afca24
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 67 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ This is a personal replacement for Google reader. It's simple and suits my workf
Articles are added to a circular FIFO queue, so that the latest articles always appear
next. Articles can be:

* **Skipped** to be viewed later
* **Published** to a JSONP 'RSS' feed
* **Discarded** from the queue
* **Inspected** to view the article from the original website, with comments
* **Skipped** (s) to be viewed later
* **Published** (p) to a JSONP 'RSS' feed
* **Discarded** (d) from the queue
* **Inspected** (i) to view the article from the original website, with comments

Destructive actions can be undone.
Destructive actions can be undone (u).

The current article is synchronised across all devices, so you can continue reading
on yor smartphone.
Expand Down
124 changes: 63 additions & 61 deletions aggregator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,72 +15,74 @@
*/


// must accept config somehow else FIXME
config = require('../config')
exports.aggregator = function(config) {
var exports = {}
// TODO: article validator
// TODO: may have to change to async with callbacks (store only)
// so that redis and sqlite (async) can be implemented

// TODO: article validator
// TODO: may have to change to async with callbacks (store only)
// so that redis and sqlite (async) can be implemented
// load chosen actors
queue = require('./articleQueue').internal()
store = require('./articleStore')[config.store.actor](config.store)

// load chosen actors
queue = require('./articleQueue').internal(config)
store = require('./articleStore')[config.store.actor](config.store)
exports.importer = require('./importer')
exports.importer.store = store // hack: FIXME

exports.importer = require('./importer')
exports.importer.store = store // hack: FIXME

watcher = require('./rss-watcher')

watcher = require('./rss-watcher')


exports.watchRssFeeds = function(urls) {
urls.forEach(function(url){
watcher.watch({
url:url,
callback:function(article) {
exports.enqueue(article)
exports.hooks.enqueue(article)
},
since: config.since
exports.watchRssFeeds = function(urls) {
urls.forEach(function(url){
watcher.watch({
url:url,
callback:function(article) {
exports.enqueue(article)
exports.hooks.enqueue(article)
},
since: config.since
})
})
})
}

exports.hooks = {}
exports.hooks.enqueue = function(article){}
exports.hooks.publish = function(article){}

exports.next = function() {
var article = queue.next()
if (article)
article.pending = queue.pending()
return article
}

exports.current = function() {
var article = queue.current()
if (article)
article.pending = queue.pending()
return article
}

exports.hooks = {}
exports.hooks.enqueue = function(article){}
exports.hooks.publish = function(article){}

exports.next = function() {
var article = queue.next()
if (article)
article.pending = queue.pending()
return article
}

exports.current = function() {
var article = queue.current()
if (article)
article.pending = queue.pending()
return article
}

exports.discard = function(id) {
return queue.discard(id)
}

exports.publish = function(id) {
var article = queue.get(id)
if (article) {
exports.hooks.publish(article)
return !!store.insert(article)
} else
return false
}

exports.enqueue = queue.enqueue
exports.dump = store.dump
exports.pending = queue.pending
exports.unpublish = store.discard
exports.store = store
exports.queue = queue
exports.articleHash = require('./articleQueue').articleHash

return exports
}

exports.discard = function(id) {
return queue.discard(id)
}

exports.publish = function(id) {
var article = queue.get(id)
if (article) {
exports.hooks.publish(article)
return !!store.insert(article)
} else
return false
}

exports.enqueue = queue.enqueue
exports.dump = store.dump
exports.pending = queue.pending
exports.unpublish = store.discard
exports.store = store
exports.queue = queue
exports.articleHash = require('./articleQueue').articleHash
2 changes: 1 addition & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var restify = require('restify')
var xml2js = require('xml2js')
var fs = require('fs')

var aggregator = require('./aggregator')
var aggregator = require('./aggregator').aggregator(config)
var importer = aggregator.importer


Expand Down

0 comments on commit 3afca24

Please sign in to comment.