mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-06-19 22:09:39 +02:00
Merge branch 'userhomepage' of https://github.com/yariplus/NodeBB into yariplus-userhomepage
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
"allowLocalLogin": 1,
|
||||
"allowAccountDelete": 1,
|
||||
"allowFileUploads": 0,
|
||||
"allowUserHomePage": 1,
|
||||
"maximumFileSize": 2048,
|
||||
"minimumTitleLength": 3,
|
||||
"maximumTitleLength": 255,
|
||||
|
||||
@@ -107,6 +107,11 @@
|
||||
|
||||
"select-skin": "Select a Skin",
|
||||
|
||||
"select-homepage": "Select a Custom 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",
|
||||
|
||||
"sso.title": "Single Sign-on Services",
|
||||
"sso.associated": "Associated with",
|
||||
"sso.not-associated": "Click here to associate with"
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
|
||||
@@ -11,5 +11,4 @@ var accountsController = {
|
||||
chats: require('./accounts/chats')
|
||||
};
|
||||
|
||||
|
||||
module.exports = accountsController;
|
||||
|
||||
@@ -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]]'}]);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -12,11 +12,18 @@
|
||||
<option value="{routes.route}">{routes.name}</option>
|
||||
<!-- END routes -->
|
||||
</select>
|
||||
<br>
|
||||
<div id="homePageCustom" style="display: none;">
|
||||
<br>
|
||||
<label>Custom Route</label>
|
||||
<input type="text" class="form-control" data-field="homePageCustom"/>
|
||||
</div>
|
||||
<br>
|
||||
<div class="checkbox">
|
||||
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
|
||||
<input class="mdl-switch__input" type="checkbox" data-field="allowUserHomePage">
|
||||
<span class="mdl-switch__label"><strong>Allow User Home Pages</strong></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user