From fa4ed0f3b1ce5decfc6ee59d38e63e78a7793de4 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 22 Dec 2017 07:11:26 +0100 Subject: new keyword form --- bucky/app/bucky.js | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'bucky/app/bucky.js') diff --git a/bucky/app/bucky.js b/bucky/app/bucky.js index dbb980d..cd70790 100644 --- a/bucky/app/bucky.js +++ b/bucky/app/bucky.js @@ -94,9 +94,9 @@ var bucky = module.exports = { next() }) }, - + /* DETAILS */ - + ensureThread: function (req, res, next){ var id = req.params.id.replace(/\D/g, "") if (! id) { @@ -253,7 +253,7 @@ var bucky = module.exports = { res.sendStatus(500) }) }, - + /* KEYWORDS */ ensureKeyword: function (req, res, next){ @@ -296,7 +296,24 @@ var bucky = module.exports = { next() }) }, - + createKeyword: function (req, res, next){ + if (! req.body.keyword || ! req.body.keyword.length) { + res.json({ error: "no keyword" }) + return + } + var data = { + keyword: req.body.keyword, + owner: req.user.get('username'), + createdate: util.now(), + public: 1, + color: req.body.color || 'blue', + } + db.createKeyword(data).then(function(keyword){ + res.keyword = keyword + next() + }) + }, + /* POSTING */ verifyFilesOrComment: function (req, res, next){ @@ -308,9 +325,9 @@ var bucky = module.exports = { } next() }, - + /* COMMENTS */ - + ensureComment: function (req, res, next){ var id = req.params.id.replace(/\D/g, "") if (! id) { @@ -442,7 +459,7 @@ var bucky = module.exports = { /* PROFILE / USER */ - + ensureUser: function (req, res, next){ var username = util.sanitizeName(req.params.username) if (! username) { -- cgit v1.2.3-70-g09d2