diff --git a/.gitignore b/.gitignore index 9cc6516546..2f966c4535 100644 --- a/.gitignore +++ b/.gitignore @@ -17,9 +17,7 @@ provision.sh .DS_Store feeds/recent.rss -# winston? -error.log -events.log +logs/ pidfile diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e75645e92b..111cd41c46 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,3 +1,8 @@ +# Having problems installing NodeBB? + +Chances are somebody has run into this problem before. After consulting our [documentation](https://docs.nodebb.org/en/latest/installing/os.html), please head over to our [community support forum](https://community.nodebb.org) for advice. + + # Issues & Bugs Thanks for reporting an issue with NodeBB! Please follow these guidelines in order to streamline the debugging process. The more guidelines you follow, the easier it will be for us to reproduce your problem. diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js index 184920b3f8..2aa61c9426 100644 --- a/public/src/ajaxify.js +++ b/public/src/ajaxify.js @@ -72,7 +72,7 @@ $(document).ready(function() { if (ajaxify.isTemplateAvailable(tpl_url) && !!!templatesModule.config.force_refresh[tpl_url]) { ajaxify.currentPage = url; - if (window.history && window.history.pushState) { + if (window.history && window.history.pushState && url !== '404') { window.history[!quiet ? 'pushState' : 'replaceState']({ url: url + hash }, url, RELATIVE_PATH + '/' + url + hash); diff --git a/public/src/modules/navigator.js b/public/src/modules/navigator.js index 5528b78b51..cfccbb871d 100644 --- a/public/src/modules/navigator.js +++ b/public/src/modules/navigator.js @@ -152,7 +152,7 @@ define('navigator', ['forum/pagination'], function(pagination) { } navigator.scrollToPost = function(postIndex, highlight, duration, offset) { - if (!utils.isNumber(postIndex)) { + if (!utils.isNumber(postIndex) || !$('.post-container').length) { return; } diff --git a/src/controllers/accounts.js b/src/controllers/accounts.js index 735aedb55c..35e86d7f81 100644 --- a/src/controllers/accounts.js +++ b/src/controllers/accounts.js @@ -544,7 +544,8 @@ accountsController.getChats = function(req, res, next) { return res.render('chats', { chats: results.recentChats.users, nextStart: results.recentChats.nextStart, - contacts: results.contacts + contacts: results.contacts, + allowed: true }); } diff --git a/src/controllers/topics.js b/src/controllers/topics.js index 7be21fd793..c816f29ecb 100644 --- a/src/controllers/topics.js +++ b/src/controllers/topics.js @@ -44,18 +44,6 @@ topicsController.get = function(req, res, next) { }, function (results, next) { - var postCount = parseInt(results.postCount, 10); - if (utils.isNumber(req.params.post_index)) { - var url = ''; - if (req.params.post_index > postCount) { - url = '/topic/' + req.params.topic_id + '/' + req.params.slug + '/' + postCount; - return res.locals.isAPI ? res.status(302).json(url) : res.redirect(url); - } else if (req.params.post_index < 1) { - url = '/topic/' + req.params.topic_id + '/' + req.params.slug; - return res.locals.isAPI ? res.status(302).json(url) : res.redirect(url); - } - } - userPrivileges = results.privileges; if (userPrivileges.disabled) { @@ -70,6 +58,18 @@ topicsController.get = function(req, res, next) { return categoriesController.notAllowed(req, res); } + var postCount = parseInt(results.postCount, 10); + if (utils.isNumber(req.params.post_index)) { + var url = ''; + if (req.params.post_index > postCount) { + url = '/topic/' + req.params.topic_id + '/' + req.params.slug + '/' + postCount; + return res.locals.isAPI ? res.status(302).json(url) : res.redirect(url); + } else if (req.params.post_index < 1) { + url = '/topic/' + req.params.topic_id + '/' + req.params.slug; + return res.locals.isAPI ? res.status(302).json(url) : res.redirect(url); + } + } + var settings = results.settings; var set = 'tid:' + tid + ':posts', reverse = false; diff --git a/src/database/mongo.js b/src/database/mongo.js index 0a5c5db6ef..3356f01cde 100644 --- a/src/database/mongo.js +++ b/src/database/mongo.js @@ -51,7 +51,7 @@ } } catch (err) { winston.error('Unable to initialize MongoDB! Is MongoDB installed? Error :' + err.message); - process.exit(); + return callback(err); } var usernamePassword = ''; @@ -66,9 +66,9 @@ } }; mongoClient.connect(connString, connOptions, function(err, _db) { - if(err) { + if (err) { winston.error("NodeBB could not connect to your Mongo database. Mongo returned the following error: " + err.message); - process.exit(); + return callback(err); } db = _db; diff --git a/src/favourites.js b/src/favourites.js index 341766bdb3..123e014bc9 100644 --- a/src/favourites.js +++ b/src/favourites.js @@ -25,8 +25,10 @@ var async = require('async'), return callback(new Error('[[error:cant-vote-self-post]]')); } + var now = Date.now(); + if(type === 'upvote' && !unvote) { - db.sortedSetAdd('uid:' + uid + ':upvote', postData.timestamp, pid); + db.sortedSetAdd('uid:' + uid + ':upvote', now, pid); } else { db.sortedSetRemove('uid:' + uid + ':upvote', pid); } @@ -34,7 +36,7 @@ var async = require('async'), if(type === 'upvote' || unvote) { db.sortedSetRemove('uid:' + uid + ':downvote', pid); } else { - db.sortedSetAdd('uid:' + uid + ':downvote', postData.timestamp, pid); + db.sortedSetAdd('uid:' + uid + ':downvote', now, pid); } user[type === 'upvote' ? 'incrementUserFieldBy' : 'decrementUserFieldBy'](postData.uid, 'reputation', 1, function (err, newreputation) {