v1.18.x
psychobunny 10 years ago
commit 3b5b87c14e

@ -41,7 +41,7 @@
"nodebb-plugin-dbsearch": "^0.1.0",
"nodebb-plugin-emoji-extended": "^0.4.1-4",
"nodebb-plugin-markdown": "^1.0.0",
"nodebb-plugin-mentions": "^0.9.0",
"nodebb-plugin-mentions": "^0.10.0",
"nodebb-plugin-soundpack-default": "~0.1.1",
"nodebb-plugin-spam-be-gone": "^0.4.0",
"nodebb-theme-lavender": "^1.0.6",

@ -3,7 +3,7 @@
define('admin/extend/widgets', function() {
var Widgets = {};
Widgets.init = function() {
$('#widgets .nav-pills a').on('click', function(ev) {
var $this = $(this);

@ -200,8 +200,7 @@ categoriesController.get = function(req, res, next) {
var topicCount = parseInt(results.categoryData.topic_count, 10);
if (topicIndex < 0 || topicIndex > Math.max(topicCount - 1, 0)) {
var url = '/category/' + cid + '/' + req.params.slug + (topicIndex > topicCount ? '/' + topicCount : '');
return res.locals.isAPI ? res.status(302).json(url) : res.redirect(url);
return helpers.redirect(res, '/category/' + cid + '/' + req.params.slug + (topicIndex > topicCount ? '/' + topicCount : ''));
}
userPrivileges = results.privileges;

@ -51,31 +51,35 @@ groupsController.details = function(req, res, next) {
}
}
], function(err, ok) {
if (ok) {
async.parallel({
group: function(next) {
groups.get(res.locals.groupName, {
expand: true,
uid: uid
}, next);
},
posts: function(next) {
groups.getLatestMemberPosts(res.locals.groupName, 10, uid, next);
}
}, function(err, results) {
if (err) {
return next(err);
}
if (!results.group) {
return helpers.notFound(req, res);
}
if (err) {
return next(err);
}
res.render('groups/details', results);
});
} else {
return res.locals.isAPI ? res.status(302).json('/groups') : res.redirect('/groups');
if (!ok) {
return helpers.redirect(res, '/groups');
}
async.parallel({
group: function(next) {
groups.get(res.locals.groupName, {
expand: true,
uid: uid
}, next);
},
posts: function(next) {
groups.getLatestMemberPosts(res.locals.groupName, 10, uid, next);
}
}, function(err, results) {
if (err) {
return next(err);
}
if (!results.group) {
return helpers.notFound(req, res);
}
res.render('groups/details', results);
});
});
};

@ -45,6 +45,14 @@ helpers.notAllowed = function(req, res, error) {
}
};
helpers.redirect = function(res, url) {
if (res.locals.isAPI) {
res.status(302).json(url);
} else {
res.redirect(url);
}
};
helpers.buildCategoryBreadcrumbs = function(cid, callback) {
var breadcrumbs = [];

@ -56,12 +56,8 @@ topicsController.get = function(req, res, next) {
var postCount = parseInt(results.topic.postcount, 10);
var pageCount = Math.max(1, Math.ceil((postCount - 1) / settings.postsPerPage));
if (utils.isNumber(req.params.post_index)) {
var url = '';
if (req.params.post_index < 1 || req.params.post_index > postCount) {
url = '/topic/' + req.params.topic_id + '/' + req.params.slug + (req.params.post_index > postCount ? '/' + postCount : '');
return res.locals.isAPI ? res.status(302).json(url) : res.redirect(url);
}
if (utils.isNumber(req.params.post_index) && (req.params.post_index < 1 || req.params.post_index > postCount)) {
return helpers.redirect(res, '/topic/' + req.params.topic_id + '/' + req.params.slug + (req.params.post_index > postCount ? '/' + postCount : ''));
}
if (settings.usePagination && (req.query.page < 1 || req.query.page > pageCount)) {
@ -266,7 +262,7 @@ topicsController.get = function(req, res, next) {
});
topics.increaseViewCount(tid);
plugins.fireHook('filter:topic.build', {req: req, res: res, templateData: data}, function(err, data) {
if (err) {
return next(err);

@ -16,6 +16,7 @@ var async = require('async'),
posts = require('./posts'),
privileges = require('./privileges'),
utils = require('../public/src/utils'),
util = require('util'),
uploadsController = require('./controllers/uploads');
@ -952,7 +953,11 @@ var async = require('async'),
var memberOf = [];
isMembers.forEach(function(isMember, index) {
if (isMember) {
memberOf.push(groupData[index]);
if (uids.length > 1) {
memberOf.push(util._extend({}, groupData[index]));
} else {
memberOf.push(groupData[index]);
}
}
});
@ -1084,7 +1089,7 @@ var async = require('async'),
case 'alpha': // intentional fall-through
default:
groups = groups.sort(function(a, b) {
return a.slug > b.slug;
return a.slug > b.slug ? 1 : -1;
});
}

@ -60,12 +60,7 @@ middleware.redirectToAccountIfLoggedIn = function(req, res, next) {
if (err) {
return next(err);
}
if (res.locals.isAPI) {
res.status(302).json(nconf.get('relative_path') + '/user/' + userslug);
} else {
res.redirect(nconf.get('relative_path') + '/user/' + userslug);
}
helpers.redirect(res, '/user/' + userslug);
});
};
@ -85,13 +80,7 @@ middleware.addSlug = function(req, res, next) {
return next(err);
}
var url = nconf.get('relative_path') + name + encodeURI(slug);
if (res.locals.isAPI) {
res.status(302).json(url);
} else {
res.redirect(url);
}
helpers.redirect(res, name + encodeURI(slug));
});
}

@ -34,8 +34,8 @@ module.exports = function(Posts) {
var userData = results.userData;
userData.forEach(function(userData, i) {
userData.groups = results.groups[i];
results.groups[i].forEach(function(group, index) {
userData.groups.forEach(function(group) {
group.selected = group.name === results.userSettings[i].groupTitle;
});
userData.status = user.getStatus(userData.status, results.online[i]);

@ -218,7 +218,7 @@ function handleErrors(app, middleware) {
}
if (parseInt(err.status, 10) === 302 && err.path) {
return res.locals.isAPI ? res.status(302).json(err) : res.redirect(err.path);
return res.locals.isAPI ? res.status(302).json(err.path) : res.redirect(err.path);
}
res.status(err.status || 500);

@ -6,7 +6,7 @@
<ul class="nav nav-pills">
<!-- BEGIN templates -->
<li class="<!-- IF @first -->active<!-- ENDIF @first -->"><a href="#" data-template="{templates.template}" data-toggle="pill">{templates.template}</a></li>
<li class="<!-- IF @first -->active<!-- ENDIF @first -->"><a href="#" data-template="{template}" data-toggle="pill">{template}</a></li>
<!-- END templates -->
</ul>
@ -14,10 +14,10 @@
<div class="col-xs-12">
<div class="tab-content">
<!-- BEGIN templates -->
<div class="tab-pane <!-- IF @first -->active<!-- ENDIF @first -->" data-template="{templates.template}">
<div class="tab-pane <!-- IF @first -->active<!-- ENDIF @first -->" data-template="{template}">
<!-- BEGIN areas -->
<div class="area" data-template="{templates.template}" data-location="{templates.areas.location}">
<h4>{templates.areas.name} <small>{templates.template} / {templates.areas.location}</small></h4>
<div class="area" data-template="{template}" data-location="{areas.location}">
<h4>{areas.name} <small>{template} / {areas.location}</small></h4>
<div class="well widget-area">
</div>

@ -9,7 +9,6 @@ var async = require('async'),
(function(Widgets) {
Widgets.render = function(uid, area, callback) {
if (!area.locations || !area.template) {
return callback(new Error('[[error:invalid-data]]'));

Loading…
Cancel
Save