From 9e5a8856d1e0afb1dfd349f7c14c6569f3648626 Mon Sep 17 00:00:00 2001 From: Baris Usakli Date: Wed, 15 Nov 2017 14:01:20 -0500 Subject: [PATCH 1/5] fix wrong sorting option in acp --- public/language/en-GB/admin/settings/post.json | 1 + src/views/admin/settings/post.tpl | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/public/language/en-GB/admin/settings/post.json b/public/language/en-GB/admin/settings/post.json index a789025597..7cef2f34a0 100644 --- a/public/language/en-GB/admin/settings/post.json +++ b/public/language/en-GB/admin/settings/post.json @@ -4,6 +4,7 @@ "sorting.oldest-to-newest": "Oldest to Newest", "sorting.newest-to-oldest": "Newest to Oldest", "sorting.most-votes": "Most Votes", + "sorting.most-posts": "Most Posts", "sorting.topic-default": "Default Topic Sorting", "restrictions": "Posting Restrictions", "restrictions.post-queue": "Enable post queue", diff --git a/src/views/admin/settings/post.tpl b/src/views/admin/settings/post.tpl index 2c77c48692..094ec4b7e7 100644 --- a/src/views/admin/settings/post.tpl +++ b/src/views/admin/settings/post.tpl @@ -17,7 +17,7 @@ From 6a623c30d719f1fb74298a01c51eda0153d88958 Mon Sep 17 00:00:00 2001 From: "Misty (Bot)" Date: Wed, 15 Nov 2017 19:00:47 +0000 Subject: [PATCH 2/5] Incremented version number - v1.7.0 --- package.default.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.default.json b/package.default.json index 3d9f4ab394..a357382221 100644 --- a/package.default.json +++ b/package.default.json @@ -2,7 +2,7 @@ "name": "nodebb", "license": "GPL-3.0", "description": "NodeBB Forum", - "version": "1.6.1", + "version": "1.7.0", "homepage": "http://www.nodebb.org", "repository": { "type": "git", @@ -134,4 +134,4 @@ "url": "https://github.com/barisusakli" } ] -} +} \ No newline at end of file From 38e52a65bed40aed3bff74615cb790d6f09f45d3 Mon Sep 17 00:00:00 2001 From: Baris Usakli Date: Wed, 15 Nov 2017 14:48:28 -0500 Subject: [PATCH 3/5] fix breadcrumbs and home /api route not loading --- src/controllers/categories.js | 2 +- src/controllers/category.js | 8 +++++--- src/controllers/home.js | 4 ++-- src/controllers/popular.js | 2 +- src/controllers/recent.js | 2 +- src/controllers/unread.js | 3 +-- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/controllers/categories.js b/src/controllers/categories.js index 25e384c0ed..350fdd245f 100644 --- a/src/controllers/categories.js +++ b/src/controllers/categories.js @@ -40,7 +40,7 @@ categoriesController.list = function (req, res, next) { categories: categoryData, }; - if (req.path.startsWith('/api/categories') || req.path.startsWith('/categories')) { + if (req.originalUrl.startsWith(nconf.get('relative_path') + '/api/categories') || req.originalUrl.startsWith(nconf.get('relative_path') + '/categories')) { data.breadcrumbs = helpers.buildBreadcrumbs([{ text: data.title }]); } diff --git a/src/controllers/category.js b/src/controllers/category.js index c7414fc096..f231349a49 100644 --- a/src/controllers/category.js +++ b/src/controllers/category.js @@ -109,7 +109,7 @@ categoryController.get = function (req, res, callback) { return helpers.redirect(res, categoryData.link); } - buildBreadcrumbs(categoryData, next); + buildBreadcrumbs(req, categoryData, next); }, function (categoryData, next) { if (!categoryData.children.length) { @@ -148,7 +148,7 @@ categoryController.get = function (req, res, callback) { ], callback); }; -function buildBreadcrumbs(categoryData, callback) { +function buildBreadcrumbs(req, categoryData, callback) { var breadcrumbs = [ { text: categoryData.name, @@ -160,7 +160,9 @@ function buildBreadcrumbs(categoryData, callback) { helpers.buildCategoryBreadcrumbs(categoryData.parentCid, next); }, function (crumbs, next) { - categoryData.breadcrumbs = crumbs.concat(breadcrumbs); + if (req.originalUrl.startsWith(nconf.get('relative_path') + '/api/category') || req.originalUrl.startsWith(nconf.get('relative_path') + '/category')) { + categoryData.breadcrumbs = crumbs.concat(breadcrumbs); + } next(null, categoryData); }, ], callback); diff --git a/src/controllers/home.js b/src/controllers/home.js index d5a8c30050..c044f889c5 100644 --- a/src/controllers/home.js +++ b/src/controllers/home.js @@ -37,7 +37,7 @@ pubsub.on('config:update', configUpdated); configUpdated(); module.exports = function (req, res, next) { - if (req.path !== '/' && req.path !== '/api/') { + if (req.path !== '/' && req.path !== '/api/' && req.path !== '/api') { return next(); } @@ -56,7 +56,7 @@ module.exports = function (req, res, next) { }); } - req.url = req.path + route; + req.url = req.path + (!req.path.endsWith('/') ? '/' : '') + route; next(); }); }; diff --git a/src/controllers/popular.js b/src/controllers/popular.js index 99af5baf19..8b0ee26899 100644 --- a/src/controllers/popular.js +++ b/src/controllers/popular.js @@ -52,7 +52,7 @@ popularController.get = function (req, res, next) { term: term, }; - if (req.path.startsWith('/api/popular') || req.path.startsWith('/popular')) { + if (req.originalUrl.startsWith(nconf.get('relative_path') + '/api/popular') || req.originalUrl.startsWith(nconf.get('relative_path') + '/popular')) { var breadcrumbs = [{ text: termToBreadcrumb[term] }]; if (req.params.term) { diff --git a/src/controllers/recent.js b/src/controllers/recent.js index d6947d53a7..1477cf01f9 100644 --- a/src/controllers/recent.js +++ b/src/controllers/recent.js @@ -71,7 +71,7 @@ recentController.get = function (req, res, next) { var pageCount = Math.max(1, Math.ceil(data.topicCount / settings.topicsPerPage)); data.pagination = pagination.create(page, pageCount, req.query); - if (req.path.startsWith('/api/recent') || req.path.startsWith('/recent')) { + if (req.originalUrl.startsWith(nconf.get('relative_path') + '/api/recent') || req.originalUrl.startsWith(nconf.get('relative_path') + '/recent')) { data.breadcrumbs = helpers.buildBreadcrumbs([{ text: '[[recent:title]]' }]); } diff --git a/src/controllers/unread.js b/src/controllers/unread.js index 7891012e19..d8a77345c5 100644 --- a/src/controllers/unread.js +++ b/src/controllers/unread.js @@ -64,8 +64,7 @@ unreadController.get = function (req, res, next) { data.categories = results.watchedCategories.categories; data.selectedCategory = results.watchedCategories.selectedCategory; data.selectedCids = results.watchedCategories.selectedCids; - - if (req.path.startsWith('/api/unread') || req.path.startsWith('/unread')) { + if (req.originalUrl.startsWith(nconf.get('relative_path') + '/api/unread') || req.originalUrl.startsWith(nconf.get('relative_path') + '/unread')) { data.breadcrumbs = helpers.buildBreadcrumbs([{ text: '[[unread:title]]' }]); } From 1eca1f1da9f2e967d99ba42da781ea8d925b1448 Mon Sep 17 00:00:00 2001 From: Baris Usakli Date: Wed, 15 Nov 2017 14:49:04 -0500 Subject: [PATCH 4/5] add missing require --- src/controllers/unread.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/controllers/unread.js b/src/controllers/unread.js index d8a77345c5..6d60bab8e7 100644 --- a/src/controllers/unread.js +++ b/src/controllers/unread.js @@ -2,6 +2,7 @@ 'use strict'; var async = require('async'); +var nconf = require('nconf'); var querystring = require('querystring'); var pagination = require('../pagination'); From e68e5122e2415d764f796230d2f22b5b9c4723ae Mon Sep 17 00:00:00 2001 From: Baris Usakli Date: Wed, 15 Nov 2017 14:57:26 -0500 Subject: [PATCH 5/5] add test to check breadcrumbs on home route --- test/controllers.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/controllers.js b/test/controllers.js index a0c4eba1dc..15d2be3765 100644 --- a/test/controllers.js +++ b/test/controllers.js @@ -120,6 +120,16 @@ describe('Controllers', function () { }); }); + it('should load not load breadcrumbs on home page route', function (done) { + request(nconf.get('url') + '/api', { json: true }, function (err, res, body) { + assert.ifError(err); + assert.equal(res.statusCode, 200); + assert(body); + assert(!body.breadcrumbs); + done(); + }); + }); + it('should redirect to custom homepage', function (done) { meta.configs.set('homePageRoute', 'groups', function (err) { assert.ifError(err);