diff --git a/install/data/defaults.json b/install/data/defaults.json
index 3274c8ec4e..6d81fdbc82 100644
--- a/install/data/defaults.json
+++ b/install/data/defaults.json
@@ -15,6 +15,7 @@
"allowLocalLogin": 1,
"allowAccountDelete": 1,
"allowFileUploads": 0,
+ "allowUserHomePage": 1,
"maximumFileSize": 2048,
"minimumTitleLength": 3,
"maximumTitleLength": 255,
diff --git a/package.json b/package.json
index ccf4ecb694..4a951ba247 100644
--- a/package.json
+++ b/package.json
@@ -49,8 +49,8 @@
"nodebb-plugin-spam-be-gone": "0.4.2",
"nodebb-rewards-essentials": "0.0.5",
"nodebb-theme-lavender": "2.0.13",
- "nodebb-theme-persona": "4.0.21",
- "nodebb-theme-vanilla": "5.0.6",
+ "nodebb-theme-persona": "4.0.23",
+ "nodebb-theme-vanilla": "5.0.7",
"nodebb-widget-essentials": "2.0.3",
"npm": "^2.1.4",
"passport": "^0.3.0",
diff --git a/public/language/en_GB/user.json b/public/language/en_GB/user.json
index 32040e49c8..15cf8d7405 100644
--- a/public/language/en_GB/user.json
+++ b/public/language/en_GB/user.json
@@ -107,6 +107,12 @@
"select-skin": "Select a Skin",
+ "select-homepage": "Select a Homepage",
+ "homepage": "Homepage",
+ "homepage_description": "Select a page to use as the forum homepage or 'None' to use the default homepage.",
+ "custom_route": "Custom Homepage Route",
+ "custom_route_help": "Enter a route name here, without any preceding slash (e.g. \"recent\", or \"popular\")",
+
"sso.title": "Single Sign-on Services",
"sso.associated": "Associated with",
"sso.not-associated": "Click here to associate with"
diff --git a/public/src/client/account/settings.js b/public/src/client/account/settings.js
index bf535d8ec0..840f498259 100644
--- a/public/src/client/account/settings.js
+++ b/public/src/client/account/settings.js
@@ -68,7 +68,20 @@ define('forum/account/settings', ['forum/account/header'], function(header) {
css.attr('href', val);
});
+
+ $('[data-property="homePageRoute"]').on('change', toggleCustomRoute);
+
+ toggleCustomRoute();
};
+ function toggleCustomRoute() {
+ $('[data-property="homePageCustom"]').val('');
+ if ($('[data-property="homePageRoute"]').val() === 'custom') {
+ $('#homePageCustom').show();
+ }else{
+ $('#homePageCustom').hide();
+ }
+ }
+
return AccountSettings;
});
diff --git a/src/controllers/accounts.js b/src/controllers/accounts.js
index 8384b4e9b8..65116b26da 100644
--- a/src/controllers/accounts.js
+++ b/src/controllers/accounts.js
@@ -11,5 +11,4 @@ var accountsController = {
chats: require('./accounts/chats')
};
-
module.exports = accountsController;
diff --git a/src/controllers/accounts/settings.js b/src/controllers/accounts/settings.js
index 451711b166..1e18d4a4a4 100644
--- a/src/controllers/accounts/settings.js
+++ b/src/controllers/accounts/settings.js
@@ -7,6 +7,9 @@ var async = require('async'),
languages = require('../../languages'),
meta = require('../../meta'),
plugins = require('../../plugins'),
+ privileges = require('../../privileges'),
+ categories = require('../../categories'),
+ db = require('../../database'),
helpers = require('../helpers'),
accountHelpers = require('./helpers');
@@ -34,6 +37,52 @@ settingsController.get = function(req, res, callback) {
},
languages: function(next) {
languages.list(next);
+ },
+ homePageRoutes: function(next) {
+ async.waterfall([
+ function(next) {
+ db.getSortedSetRange('cid:0:children', 0, -1, next);
+ },
+ function(cids, next) {
+ privileges.categories.filterCids('find', cids, 0, next);
+ },
+ function(cids, next) {
+ categories.getMultipleCategoryFields(cids, ['name', 'slug'], next);
+ },
+ function(categoryData, next) {
+ categoryData = categoryData.map(function(category) {
+ return {
+ route: 'category/' + category.slug,
+ name: 'Category: ' + category.name
+ };
+ });
+ next(null, categoryData);
+ }
+ ], function(err, categoryData) {
+ if (err || !categoryData) categoryData = [];
+
+ plugins.fireHook('filter:homepage.get', {routes: [
+ {
+ route: 'categories',
+ name: 'Categories'
+ },
+ {
+ route: 'recent',
+ name: 'Recent'
+ },
+ {
+ route: 'popular',
+ name: 'Popular'
+ }
+ ].concat(categoryData)}, function(err, data) {
+ data.routes.push({
+ route: 'custom',
+ name: 'Custom'
+ });
+
+ next(null, data.routes);
+ });
+ });
}
}, next);
},
@@ -41,6 +90,7 @@ settingsController.get = function(req, res, callback) {
userData.settings = results.settings;
userData.languages = results.languages;
userData.userGroups = results.userGroups[0];
+ userData.homePageRoutes = results.homePageRoutes;
plugins.fireHook('filter:user.customSettings', {settings: results.settings, customSettings: [], uid: req.uid}, next);
},
function(data, next) {
@@ -95,6 +145,8 @@ settingsController.get = function(req, res, callback) {
userData.disableCustomUserSkins = parseInt(meta.config.disableCustomUserSkins, 10) === 1;
+ userData.allowUserHomePage = parseInt(meta.config.allowUserHomePage, 10) === 1;
+
userData.title = '[[pages:account/settings]]';
userData.breadcrumbs = helpers.buildBreadcrumbs([{text: userData.username, url: '/user/' + userData.userslug}, {text: '[[user:settings]]'}]);
diff --git a/src/controllers/api.js b/src/controllers/api.js
index 9a6fbee238..5ccedc5aeb 100644
--- a/src/controllers/api.js
+++ b/src/controllers/api.js
@@ -57,6 +57,7 @@ apiController.getConfig = function(req, res, next) {
config.allowProfileImageUploads = parseInt(meta.config.allowProfileImageUploads) === 1;
config.allowTopicsThumbnail = parseInt(meta.config.allowTopicsThumbnail, 10) === 1;
config.allowAccountDelete = parseInt(meta.config.allowAccountDelete, 10) === 1;
+ config.allowUserHomePage = parseInt(meta.config.allowUserHomePage, 10) === 1;
config.privateUserInfo = parseInt(meta.config.privateUserInfo, 10) === 1;
config.privateTagListing = parseInt(meta.config.privateTagListing, 10) === 1;
config.usePagination = parseInt(meta.config.usePagination, 10) === 1;
diff --git a/src/controllers/index.js b/src/controllers/index.js
index ccb8ece26a..5d776780cf 100644
--- a/src/controllers/index.js
+++ b/src/controllers/index.js
@@ -33,22 +33,27 @@ var Controllers = {
Controllers.home = function(req, res, next) {
- var route = meta.config.homePageRoute || meta.config.homePageCustom || 'categories',
- hook = 'action:homepage.get:' + route;
+ var route = meta.config.homePageRoute || meta.config.homePageCustom || 'categories';
- if (plugins.hasListeners(hook)) {
- plugins.fireHook(hook, {req: req, res: res, next: next});
- } else {
- if (route === 'categories' || route === '/') {
- Controllers.categories.list(req, res, next);
- } else if (route === 'recent') {
- Controllers.recent.get(req, res, next);
- } else if (route === 'popular') {
- Controllers.popular.get(req, res, next);
+ user.getSettings(req.uid, function(err, settings) {
+ if (!err && settings.homePageRoute !== 'undefined' && settings.homePageRoute !== 'none') route = settings.homePageRoute || route;
+
+ var hook = 'action:homepage.get:' + route;
+
+ if (plugins.hasListeners(hook)) {
+ plugins.fireHook(hook, {req: req, res: res, next: next});
} else {
- res.redirect(route);
+ if (route === 'categories' || route === '/') {
+ Controllers.categories.list(req, res, next);
+ } else if (route === 'recent') {
+ Controllers.recent.get(req, res, next);
+ } else if (route === 'popular') {
+ Controllers.popular.get(req, res, next);
+ } else {
+ res.redirect(route);
+ }
}
- }
+ });
};
Controllers.reset = function(req, res, next) {
diff --git a/src/user/settings.js b/src/user/settings.js
index 17e524bcb7..a2d83e89eb 100644
--- a/src/user/settings.js
+++ b/src/user/settings.js
@@ -115,7 +115,8 @@ module.exports = function(User) {
sendPostNotifications: data.sendPostNotifications,
restrictChat: data.restrictChat,
topicSearchEnabled: data.topicSearchEnabled,
- groupTitle: data.groupTitle
+ groupTitle: data.groupTitle,
+ homePageRoute: data.homePageCustom || data.homePageRoute
};
if (data.bootswatchSkin) {
diff --git a/src/views/admin/general/homepage.tpl b/src/views/admin/general/homepage.tpl
index 5148d79da9..bfdc086b11 100644
--- a/src/views/admin/general/homepage.tpl
+++ b/src/views/admin/general/homepage.tpl
@@ -12,11 +12,18 @@
-