summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bucky/app/bucky.js31
-rw-r--r--bucky/app/index.js16
-rw-r--r--bucky/app/router.js4
-rw-r--r--bucky/util/auth.js2
-rw-r--r--package-lock.json8
-rw-r--r--package.json1
-rw-r--r--public/assets/js/lib/views/index/threadbox.js2
-rw-r--r--public/assets/js/vendor/view/formview.js2
8 files changed, 54 insertions, 12 deletions
diff --git a/bucky/app/bucky.js b/bucky/app/bucky.js
index 8b829da..e7455ad 100644
--- a/bucky/app/bucky.js
+++ b/bucky/app/bucky.js
@@ -94,7 +94,7 @@ var bucky = module.exports = {
next()
})
},
-
+
/* DETAILS */
ensureThread: function (req, res, next){
@@ -112,6 +112,24 @@ var bucky = module.exports = {
}
})
},
+ ensureCommentThread: function (req, res, next){
+ if (! res.comment) {
+ return res.sendStatus(404)
+ }
+ var id = res.comment.get('thread')
+ if (! id) {
+ return res.sendStatus(404)
+ }
+ db.getThread(id).then(function(thread){
+ if (thread) {
+ res.thread = thread
+ next()
+ }
+ else {
+ res.sendStatus(404)
+ }
+ })
+ },
ensureKeywordForThread: function (req, res, next){
var keyword = res.thread.get('keyword')
if (! keyword) return next()
@@ -132,7 +150,16 @@ var bucky = module.exports = {
next()
})
},
-
+ bumpViewCount: function(req, res, next) {
+ res.thread.set('viewed', res.thread.get('viewed') + 1)
+ res.thread.save().then( () => next() )
+ },
+ bumpThreadRevisions: function (req, res, next){
+ res.thread.set('revision', res.thread.get('revision')+1)
+ res.thread.set('lastmodified', util.now())
+ res.thread.save().then( () => next() )
+ },
+
/* KEYWORDS */
ensureKeyword: function (req, res, next){
diff --git a/bucky/app/index.js b/bucky/app/index.js
index 0da18c7..85c1d82 100644
--- a/bucky/app/index.js
+++ b/bucky/app/index.js
@@ -13,6 +13,7 @@ var favicon = require('serve-favicon')
var passport = require('passport')
var sessionstore = require('sessionstore')
var session = require('express-session')
+var MongoStore = require('connect-mongo')(session);
var upload = require('../util/upload')
var app, server
@@ -28,13 +29,14 @@ site.init = function(){
key: 'bucky.sid',
secret: 'argonauts',
cookie: { domain: '.' + process.env.HOST_NAME, maxAge: 43200000000 },
- store: sessionstore.createSessionStore({
- type: 'mongodb',
- host: 'localhost',
- port: 27017,
- dbName: 'buckySessionDb',
- collectionName: 'sessions',
- timeout: 10000,
+ store: new MongoStore({
+ url: 'mongodb://localhost/buckySessionDb'
+// type: 'mongodb',
+// host: 'localhost',
+// port: 27017,
+// dbName: 'buckySessionDb',
+// collectionName: 'sessions',
+// timeout: 10000,
}),
resave: true,
saveUninitialized: false,
diff --git a/bucky/app/router.js b/bucky/app/router.js
index 8ff9d87..ac176bc 100644
--- a/bucky/app/router.js
+++ b/bucky/app/router.js
@@ -85,6 +85,7 @@ module.exports = function(app){
bucky.ensureKeywordForThread,
bucky.ensureCommentsForThread,
bucky.ensureFilesForThread,
+ bucky.bumpViewCount,
function(req, res){
res.json({
thread: res.thread,
@@ -111,6 +112,7 @@ module.exports = function(app){
bucky.verifyFilesOrComment,
bucky.createOptionalFiles,
bucky.createOptionalComment,
+ bucky.bumpThreadRevisions,
function(req, res){
res.json({
comment: res.comment
@@ -127,7 +129,9 @@ module.exports = function(app){
middleware.ensureAuthenticated,
bucky.ensureComment,
bucky.checkCommentPrivacy,
+ bucky.ensureCommentThread,
bucky.updateComment,
+ bucky.bumpThreadRevisions,
function(req, res){
res.json({ comment: res.comment })
})
diff --git a/bucky/util/auth.js b/bucky/util/auth.js
index 6fdd5bd..41cd155 100644
--- a/bucky/util/auth.js
+++ b/bucky/util/auth.js
@@ -33,7 +33,7 @@ var auth = module.exports = {
if (req.isAuthenticated()) {
var returnTo = req.session.returnTo
delete req.session.returnTo
- console.log("LOGGED IN", req.user.username)
+ console.log(">> logged in", req.user.get('username'))
return res.json({
status: "OK",
user: auth.sanitizeUser(req.user),
diff --git a/package-lock.json b/package-lock.json
index ca163f5..b5f9eff 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -605,6 +605,14 @@
}
}
},
+ "connect-mongo": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/connect-mongo/-/connect-mongo-2.0.0.tgz",
+ "integrity": "sha512-2Nj5d4XO55AXSy1GOXDZteSEEUObGm/kvJaXyEQCa8cCHsCiZH+V/+sjk3b+khc4V8oyVi34rCtUxor4TfETLA==",
+ "requires": {
+ "mongodb": "2.2.33"
+ }
+ },
"connect-timeout": {
"version": "1.6.2",
"resolved": "https://registry.npmjs.org/connect-timeout/-/connect-timeout-1.6.2.tgz",
diff --git a/package.json b/package.json
index d3ab72d..0f5483c 100644
--- a/package.json
+++ b/package.json
@@ -16,6 +16,7 @@
"berkeleydb": "^0.2.1",
"body-parser": "^1.13.3",
"bookshelf": "^0.8.2",
+ "connect-mongo": "^2.0.0",
"cookie-parser": "^1.3.5",
"csurf": "^1.8.3",
"dotenv": "^1.2.0",
diff --git a/public/assets/js/lib/views/index/threadbox.js b/public/assets/js/lib/views/index/threadbox.js
index 2cde812..f3c4e0f 100644
--- a/public/assets/js/lib/views/index/threadbox.js
+++ b/public/assets/js/lib/views/index/threadbox.js
@@ -38,7 +38,7 @@ var ThreadBox = View.extend({
this.appendThreads(keywords[keyword])
})
}
- if (is_mobile) {
+ if (is_mobile || window.innerWidth < 700) {
$('.ledger .keyword').each(function(){
$('td:nth-child(2)', this).prepend($("td:nth-child(1)", this).html())
})
diff --git a/public/assets/js/vendor/view/formview.js b/public/assets/js/vendor/view/formview.js
index 1f681cb..6da7db6 100644
--- a/public/assets/js/vendor/view/formview.js
+++ b/public/assets/js/vendor/view/formview.js
@@ -100,7 +100,7 @@ var FormView = View.extend({
dataType: "json",
processData: false,
success: function(response){
- console.log(response)
+ // console.log(response)
if (response.error) {
var errors = []
for (var key in response.error.errors) {