From 41d0bd185c19c8a51ed9b85700f52181b6cc5012 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 12 Dec 2017 02:09:15 +0100 Subject: color stuff, building settings form --- bucky/app/bucky.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'bucky/app/bucky.js') diff --git a/bucky/app/bucky.js b/bucky/app/bucky.js index ab30e85..9d8d0a7 100644 --- a/bucky/app/bucky.js +++ b/bucky/app/bucky.js @@ -112,6 +112,21 @@ var bucky = module.exports = { } }) }, + prepareThread: function (req, res, next){ + var thread = res.thread + if (thread) { + var settings + try { + settings = JSON.parse(thread.get('settings') || '{}') + } catch(e) { + settings = {} + } + res.thread.set("settings", settings) + res.thread.set("display", res.thread.get("display").toString()) + res.thread.set("allowed", res.thread.get("allowed").toString()) + } + next() + }, ensureCommentThread: function (req, res, next){ if (! res.comment) { return res.sendStatus(404) @@ -135,9 +150,15 @@ var bucky = module.exports = { if (! keyword) return next() db.getKeyword(keyword).then(function(keyword){ res.keyword = keyword + if (keyword) { + keyword.set("threads", keyword.get("threads").toString()) + keyword.set("ops", keyword.get("ops").toString()) + keyword.set("display", keyword.get("display").toString()) + } next() }) }, + ensureCommentsForThread: function (req, res, next){ db.getCommentsForThread(res.thread.get('id')).then(function(comments){ res.comments = comments -- cgit v1.2.3-70-g09d2