diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-09-06 11:48:08 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-09-06 11:48:08 -0400 |
| commit | abe12120374d07cf5f87192964a9d1c10741e475 (patch) | |
| tree | 48a5c09e51863fe1508e7404cec2a9340e29f686 /lib | |
| parent | 5b1461e7b4d32e96eaa8386b4b7ea96ec4b18d5a (diff) | |
header
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/bucky.js | 8 | ||||
| -rw-r--r-- | lib/db/index.js | 4 | ||||
| -rw-r--r-- | lib/index.js | 2 | ||||
| -rw-r--r-- | lib/middleware.js | 6 |
4 files changed, 19 insertions, 1 deletions
diff --git a/lib/bucky.js b/lib/bucky.js index 2488c31..ef6fbbc 100644 --- a/lib/bucky.js +++ b/lib/bucky.js @@ -39,7 +39,13 @@ var bucky = module.exports = { next() }) }, - + ensureLastlog: function (req, res, next){ + db.getLastlog(6).then(function(lastlog){ + res.lastlog = lastlog + next() + }) + }, + /* DETAILS */ ensureThread: function (req, res, next){ diff --git a/lib/db/index.js b/lib/db/index.js index 994187e..e7ad632 100644 --- a/lib/db/index.js +++ b/lib/db/index.js @@ -53,6 +53,10 @@ db.getUserByUsername = function(username) { var model = new User({'username': username}) return model.fetch() } +db.getLastlog = function(limit){ + return knex.column('username').column('lastseen').select().from('users').orderBy('lastseen', 'desc').limit(limit || 10) +} + /* THREADS */ diff --git a/lib/index.js b/lib/index.js index e84c32a..ace34af 100644 --- a/lib/index.js +++ b/lib/index.js @@ -89,10 +89,12 @@ site.route = function(){ bucky.ensureFileCountsForThreads, // bucky.ensureFileSizeForThreads, bucky.ensureHootbox, + bucky.ensureLastlog, function(req, res){ res.json({ threads: res.threads, hootbox: res.hootbox, + lastlog: res.lastlog, }) } ) diff --git a/lib/middleware.js b/lib/middleware.js index b38cec3..a744c89 100644 --- a/lib/middleware.js +++ b/lib/middleware.js @@ -11,6 +11,12 @@ var middleware = module.exports = { ensureLocals: function (req, res, next) { res.locals.csrfToken = req.csrfToken() res.locals.title = "bucky" + if (req.isAuthenticated()) { + res.locals.show_header = true + } + else { + res.locals.show_header = false + } next() }, |
