mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 03:55:55 +01:00
Add user home pages. #3616
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
"allowLocalLogin": 1,
|
||||
"allowAccountDelete": 1,
|
||||
"allowFileUploads": 0,
|
||||
"allowUserHomePage": 1,
|
||||
"maximumFileSize": 2048,
|
||||
"minimumTitleLength": 3,
|
||||
"maximumTitleLength": 255,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) 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