diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2017-12-07 22:24:50 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2017-12-07 22:24:50 +0100 |
| commit | 340c3080b38518976c5c833399d8e07a7fc561bf (patch) | |
| tree | a81a5e5e1022557650e71f7f282b9175509c3f6f /lib | |
| parent | 72ef99ec0666ce0a4d7051a4a7a89c54a86014b8 (diff) | |
show post metadata and thread list
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/bucky.js | 6 | ||||
| -rw-r--r-- | lib/db/index.js | 34 | ||||
| -rw-r--r-- | lib/router.js | 2 |
3 files changed, 35 insertions, 7 deletions
diff --git a/lib/bucky.js b/lib/bucky.js index bfc4b6f..70910ef 100644 --- a/lib/bucky.js +++ b/lib/bucky.js @@ -21,7 +21,9 @@ var bucky = module.exports = { lookup[c.thread] = c }) res.threads.forEach(function(thread){ - thread.set("comment_count", lookup[thread.id].count) + if (lookup[thread.id]) { + thread.set("comment_count", lookup[thread.id].count) + } }) next() }) @@ -58,7 +60,7 @@ var bucky = module.exports = { }) }, ensureHootbox: function (req, res, next){ - db.getCommentsForThread(1, 9, 0, "desc").then(function(hootbox){ + db.getCommentsForThread(1, 15, 0, "desc").then(function(hootbox){ res.hootbox = hootbox next() }) diff --git a/lib/db/index.js b/lib/db/index.js index b6fa235..6906b27 100644 --- a/lib/db/index.js +++ b/lib/db/index.js @@ -58,7 +58,6 @@ db.getLastlog = function(limit){ return knex.column('username').column('lastseen').select().from('users').orderBy('lastseen', 'desc').limit(limit || 10) } - /* THREADS */ db.getLatestThreads = function () { @@ -74,7 +73,12 @@ db.getThreadsForKeyword = function (keyword) { db.getThread = function (id) { return Thread.query("where", "id", "=", id).fetch() } - +db.createThread = function(data){ +} +db.updateThread = function(data){ +} +db.removeThread = function(id){ +} /* FILES */ @@ -87,7 +91,10 @@ db.getFileCounts = function(ids){ db.getFileSizes = function(ids){ return knex.column('thread').sum('size as size').select().from('files').where('thread', 'in', ids).groupBy('thread') } - +db.createFile = function(data){ +} +db.removeFile = function(id){ +} /* COMMENTS */ @@ -111,6 +118,12 @@ db.getCommentsForThread = function (id, limit, offset, order){ db.getCommentCounts = function(ids){ return knex.column('thread').count('* as count').select().from('comments').where('thread', 'in', ids).groupBy('thread') } +db.createComment = function(data){ +} +db.updateComment = function(data){ +} +db.removeComment = function(id){ +} /* KEYWORDS */ @@ -121,6 +134,12 @@ db.getKeywords = function (keywords){ db.getKeyword = function (keyword) { return Keyword.query("where", "keyword", "=", keyword).fetch() } +db.createKeyword = function(data){ +} +db.updateKeyword = function(data){ +} +db.removeKeyword = function(id){ +} /* MAILBOXES */ @@ -131,7 +150,8 @@ db.getMailboxes = function(username){ db.getMailboxCounts = function(boxes){ return knex.column('mbox').count('* as count').select().from('messages').where('mbox', 'in', boxes).groupBy('mbox') } - +db.createMailbox = function(data){ +} /* MESSAGES */ @@ -154,3 +174,9 @@ db.getMessage = function (id){ return message }) } +db.createMessage = function(data){ +} +db.updateMessage = function(data){ +} +db.removeMessage = function(id){ +} diff --git a/lib/router.js b/lib/router.js index 66aa1bf..4451a13 100644 --- a/lib/router.js +++ b/lib/router.js @@ -29,13 +29,13 @@ module.exports = function(app){ app.post("/api/login", auth.loggedInLocal) app.get("/api/index", + bucky.ensureLastlog, middleware.ensureAuthenticated, bucky.ensureLatestThreads, bucky.ensureCommentCountsForThreads, bucky.ensureFileCountsForThreads, bucky.ensureKeywordsForThreads, bucky.ensureHootbox, - bucky.ensureLastlog, function(req, res){ res.json({ threads: res.threads, |
