summaryrefslogtreecommitdiff
path: root/lib/bucky.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bucky.js')
-rw-r--r--lib/bucky.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/bucky.js b/lib/bucky.js
index ef6fbbc..9a43c0d 100644
--- a/lib/bucky.js
+++ b/lib/bucky.js
@@ -1,4 +1,5 @@
var db = require('./db')
+var _ = require('lodash')
var bucky = module.exports = {
@@ -8,6 +9,7 @@ var bucky = module.exports = {
db.getLatestThreads().then(function(threads){
res.threads = threads
res.threads_ids = res.threads.pluck("id").sort()
+ res.keywords = _.uniq(res.threads.pluck("keyword"))
next()
})
},
@@ -33,6 +35,26 @@ var bucky = module.exports = {
next()
})
},
+ ensureKeywordsForThreads: function (req, res, next){
+ db.getKeywords(res.keywords).then(function(keywords){
+ var lookup = {}
+ keywords.forEach(function(k){
+ lookup[k.get('keyword')] = k
+ })
+ console.log(keywords)
+ res.threads.forEach(function(t){
+ var kw = t.get('keyword')
+ if (! kw) return
+ var k = lookup[kw]
+ if (! k) return
+ if (! t.get("color")) {
+ t.set("color", k.get("color"))
+ console.log(k.get("color"))
+ }
+ })
+ next()
+ })
+ },
ensureHootbox: function (req, res, next){
db.getCommentsForThread(1, 9).then(function(hootbox){
res.hootbox = hootbox