diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2017-12-11 10:04:14 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2017-12-11 10:04:14 +0100 |
| commit | 242eed0093c59047033c286d7a14608d0096b125 (patch) | |
| tree | 71fddb93c5f2c65eb9a3b0a628b2b879eba0007c /bucky | |
| parent | c06f440e4a41853fc30ff5b231c68bd766ba96fa (diff) | |
comment edit form
Diffstat (limited to 'bucky')
| -rw-r--r-- | bucky/app/bucky.js | 1 | ||||
| -rw-r--r-- | bucky/app/router.js | 38 |
2 files changed, 23 insertions, 16 deletions
diff --git a/bucky/app/bucky.js b/bucky/app/bucky.js index ce02b24..2689c4b 100644 --- a/bucky/app/bucky.js +++ b/bucky/app/bucky.js @@ -191,6 +191,7 @@ var bucky = module.exports = { } db.getCommentById(id).then(function(comment){ if (comment) { + comment.set('comment', comment.get('comment').toString()) res.comment = comment next() } diff --git a/bucky/app/router.js b/bucky/app/router.js index e5890ca..2383ab2 100644 --- a/bucky/app/router.js +++ b/bucky/app/router.js @@ -43,6 +43,9 @@ module.exports = function(app){ res.render("pages/post", {title: "Start a new thread" }) } ) + app.get("/comment/:id/edit", middleware.ensureAuthenticated, function(req, res){ + res.render("pages/editcomment", {}) + }) app.get("/api/index", bucky.ensureLastlog, @@ -58,8 +61,7 @@ module.exports = function(app){ hootbox: res.hootbox, lastlog: res.lastlog, }) - } - ) + }) app.get("/api/keyword/:keyword", bucky.ensureLastlog, @@ -76,8 +78,7 @@ module.exports = function(app){ hootbox: res.hootbox, lastlog: res.lastlog, }) - } - ) + }) app.get("/api/thread/:id", middleware.ensureAuthenticated, bucky.ensureThread, @@ -91,8 +92,7 @@ module.exports = function(app){ files: res.files, keyword: res.keyword, }) - } - ) + }) app.post("/api/thread", middleware.ensureAuthenticated, multer.array("files"), @@ -102,7 +102,7 @@ module.exports = function(app){ bucky.createOptionalComment, function(req, res){ res.json(res.thread) - }) + }) app.post("/api/thread/:id/comment", middleware.ensureAuthenticated, bucky.ensureThread, @@ -115,15 +115,13 @@ module.exports = function(app){ res.json({ comment: res.comment }) - }) - app.delete("/api/thread/:id", + }) + app.get("/api/comment/:id", middleware.ensureAuthenticated, - bucky.ensureThread, -// bucky.destroyThread, + bucky.ensureComment, function(req, res){ - // delete a thread - res.send(200) - }) + res.json({ comment: res.comment }) + }) // edit a comment app.put("/api/comment/:id", middleware.ensureAuthenticated, @@ -131,8 +129,8 @@ module.exports = function(app){ bucky.checkCommentPrivacy, bucky.updateComment, function(req, res){ - res.send(200) - }) + res.json({ comment: res.comment }) + }) // delete a comment app.delete("/api/comment/:id", middleware.ensureAuthenticated, @@ -142,6 +140,14 @@ module.exports = function(app){ function(req, res){ console.log("BUAHLAHA") res.send(200) + }) + app.delete("/api/thread/:id", + middleware.ensureAuthenticated, + bucky.ensureThread, +// bucky.destroyThread, + function(req, res){ + // delete a thread + res.send(200) }) app.get("/search/", |
