diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/bucky.js | 6 | ||||
| -rw-r--r-- | lib/db/bookshelf.js | 9 | ||||
| -rw-r--r-- | lib/db/index.js | 17 | ||||
| -rw-r--r-- | lib/index.js | 9 |
4 files changed, 33 insertions, 8 deletions
diff --git a/lib/bucky.js b/lib/bucky.js index aed6494..dddbae9 100644 --- a/lib/bucky.js +++ b/lib/bucky.js @@ -39,10 +39,8 @@ var bucky = module.exports = { }) }, ensureHootbox: function (req, res, next){ - db.getCommentsForThread(1, 50).then(function(hootbox){ - res.hootbox = hootbox.forEach(function(comment){ - comment.set("comment", comment.get("comment").toString() ) - }) + db.getCommentsForThread(1, 9).then(function(hootbox){ + res.hootbox = hootbox next() }) }, diff --git a/lib/db/bookshelf.js b/lib/db/bookshelf.js index 5774120..69157cc 100644 --- a/lib/db/bookshelf.js +++ b/lib/db/bookshelf.js @@ -5,7 +5,14 @@ var knex = require('knex')({ user : process.env.DB_USER, password : process.env.DB_PASS, database : process.env.DB_NAME, - charset : 'utf8' + charset : 'utf8', + typecast : function (field, next) { + console.log(field.type) + if (field.type == 'BLOB') { + return field.string() + } + return next() + } } }) diff --git a/lib/db/index.js b/lib/db/index.js index 2c8486b..994187e 100644 --- a/lib/db/index.js +++ b/lib/db/index.js @@ -83,8 +83,23 @@ db.getCommentsForThread = function (id, limit, offset){ if (offset) { qb = qb.offset(offset) } - }).fetchAll() + }).fetchAll().then(function(comments){ + comments.forEach(function(comment){ + comment.set("comment", comment.get("comment").toString() ) + }) + return comments + }) } db.getCommentCounts = function(ids){ return knex.column('thread').count('* as count').select().from('comments').where('thread', 'in', ids).groupBy('thread') } + +/* PRIVATE MESSAGES */ + +db.getMessage = function (id){ + var model = new Message({'id': id}) + return model.fetch().then(function(message){ + message.set("body", message.get("body").toString() ) + return message + }) +}
\ No newline at end of file diff --git a/lib/index.js b/lib/index.js index 51a8e07..7732001 100644 --- a/lib/index.js +++ b/lib/index.js @@ -72,10 +72,15 @@ site.route = function(){ res.redirect('/index') }) app.get("/login", function(req, res){ - res.render("pages/login", { title: "" }) + res.render("pages/login", { + title: "" + }) }) app.get("/index", middleware.ensureAuthenticated, function(req, res){ - res.render("pages/index", { title: fortune("titles") }) + res.render("pages/index", { + title: fortune("titles"), + hoot_text: fortune("hoots"), + }) }) app.post("/api/login", auth.loggedInLocal) app.get("/api/index", |
