Merge branch 'master' of github.com:NodeBB/NodeBB

v1.18.x
Julian Lam 10 years ago
commit f7ccdc3668

@ -46,11 +46,6 @@ winston.add(winston.transports.Console, {
level: global.env === 'production' ? 'info' : 'verbose'
});
// TODO: remove once https://github.com/flatiron/winston/issues/280 is fixed
winston.err = function (err) {
winston.error(err.stack);
};
if(os.platform() === 'linux') {
require('child_process').exec('/usr/bin/which convert', function(err, stdout, stderr) {
if(err || !stdout) {

@ -27,6 +27,10 @@
"field": "minimumPostLength",
"value": 8
},
{
"field": "maximumPostLength",
"value": 32767
},
{
"field": "allowGuestSearching",
"value": 0

@ -59,11 +59,11 @@
"socket.io-redis": "^0.1.3",
"socketio-wildcard": "~0.1.1",
"string": "^3.0.0",
"templates.js": "0.1.10",
"templates.js": "^0.1.15",
"uglify-js": "git+https://github.com/julianlam/UglifyJS2.git",
"underscore": "~1.7.0",
"validator": "~3.26.0",
"winston": "^0.8.1",
"validator": "~3.28.0",
"winston": "^0.9.0",
"xregexp": "~2.0.0"
},
"devDependencies": {

@ -46,6 +46,7 @@
"still-uploading": "Please wait for uploads to complete.",
"content-too-short": "Please enter a longer post. Posts should contain at least %1 characters.",
"content-too-long": "Please enter a shorter post. Posts can't be longer than %1 characters.",
"title-too-short": "Please enter a longer title. Titles should contain at least %1 characters.",
"title-too-long": "Please enter a shorter title. Titles can't be longer than %1 characters.",
"invalid-title": "Invalid title!",

@ -35,7 +35,7 @@ define('forum/topic/fork', function() {
forkModal.find('.close,#fork_thread_cancel').on('click', closeForkModal);
forkModal.find('#fork-title').on('change', checkForkButtonEnable);
$('#post-container').on('click', 'li[data-pid]', function() {
$('#post-container').on('click', '[data-pid]', function() {
togglePostSelection($(this));
});
@ -58,7 +58,7 @@ define('forum/topic/fork', function() {
pids: pids
}, function(err, newTopic) {
function fadeOutAndRemove(pid) {
$('#post-container li[data-pid="' + pid + '"]').fadeOut(500, function() {
$('#post-container [data-pid="' + pid + '"]').fadeOut(500, function() {
$(this).remove();
});
}
@ -125,10 +125,10 @@ define('forum/topic/fork', function() {
function closeForkModal() {
for(var i=0; i<pids.length; ++i) {
$('#post-container li[data-pid="' + pids[i] + '"]').css('opacity', 1);
$('#post-container [data-pid="' + pids[i] + '"]').css('opacity', 1);
}
forkModal.addClass('hide');
$('#post-container').off('click', 'li[data-pid]');
$('#post-container').off('click', '[data-pid]');
enableClicksOnPosts();
}

@ -406,6 +406,8 @@ define('composer', [
return composerAlert('[[error:invalid-title]]');
} else if (bodyEl.val().length < parseInt(config.minimumPostLength, 10)) {
return composerAlert('[[error:content-too-short, ' + config.minimumPostLength + ']]');
} else if (bodyEl.val().length > parseInt(config.maximumPostLength, 10)) {
return composerAlert('[[error:content-too-long, ' + config.maximumPostLength + ']]');
}
var composerData = {}, action;

@ -51,12 +51,12 @@
if (!area.length && window.location.pathname.indexOf('/admin') === -1 && renderedWidgets.length) {
if (location === 'footer' && !$('#content [widget-area="footer"]').length) {
$('#content').append($('<div class="col-xs-12"><div widget-area="footer"></div></div>'));
$('#content').append($('<div class="row"><div widget-area="footer" class="col-xs-12"></div></div>'));
} else if (location === 'sidebar' && !$('#content [widget-area="sidebar"]').length) {
$('#content > *').wrapAll($('<div class="col-lg-9 col-xs-12"></div>'));
$('#content').append($('<div class="col-lg-3 col-xs-12"><div widget-area="sidebar"></div></div>'));
$('#content > *').wrapAll($('<div class="row"><div class="col-lg-9 col-xs-12"></div></div>'));
$('#content').append($('<div class="row"><div widget-area="sidebar" class="col-lg-3 col-xs-12"></div></div>'));
} else if (location === 'header' && !$('#content [widget-area="header"]').length) {
$('#content').prepend($('<div class="col-xs-12"><div widget-area="header"></div></div>'));
$('#content').prepend($('<div class="row"><div widget-area="header" class="col-xs-12"></div></div>'));
}
area = $('#content [widget-area="' + location + '"]');

@ -103,7 +103,10 @@ module.exports = function(Categories) {
pids = pids.concat(topicPids).filter(function(pid, index, array) {
return !!pid && array.indexOf(pid) === index;
});
}).sort(function(a, b) {
return b - a;
}).slice(0, count);
callback(null, pids);
});
});

@ -466,7 +466,7 @@ accountsController.uploadPicture = function (req, res, next) {
fs.unlink(absolutePath, function (err) {
if (err) {
winston.err(err);
winston.error(err);
}
file.saveFileToLocal(filename, 'profile', userPhoto.path, done);

@ -113,11 +113,17 @@ function getStatsForSet(set, field, callback) {
db.sortedSetCount(set, now - terms.month, now, next);
},
alltime: function(next) {
db.getObjectField('global', field, next);
getGlobalField(field, next);
}
}, callback);
}
function getGlobalField(field, callback) {
db.getObjectField('global', field, function(err, count) {
callback(err, parseInt(count, 10) || 0);
});
}
adminController.categories.active = function(req, res, next) {
filterAndRenderCategories(req, res, next, true);
};

@ -23,6 +23,7 @@ apiController.getConfig = function(req, res, next) {
config.minimumTitleLength = meta.config.minimumTitleLength;
config.maximumTitleLength = meta.config.maximumTitleLength;
config.minimumPostLength = meta.config.minimumPostLength;
config.maximumPostLength = meta.config.maximumPostLength;
config.hasImageUploadPlugin = plugins.hasListeners('filter:uploadImage');
config.maximumProfileImageSize = meta.config.maximumProfileImageSize;
config.minimumUsernameLength = meta.config.minimumUsernameLength;

@ -690,8 +690,14 @@ var async = require('async'),
Groups.acceptMembership = function(groupName, uid, callback) {
// Note: For simplicity, this method intentially doesn't check the caller uid for ownership!
db.setRemove('group:' + groupName + ':pending', uid, callback);
Groups.join.apply(Groups, arguments);
async.waterfall([
function(next) {
db.setRemove('group:' + groupName + ':pending', uid, next);
},
function(next) {
Groups.join(groupName, uid, next);
}
], callback);
};
Groups.rejectMembership = function(groupName, uid, callback) {

@ -13,6 +13,10 @@ SocketGroups.join = function(socket, data, callback) {
return callback(new Error('[[error:invalid-data]]'));
}
if (!parseInt(socket.uid, 10)) {
return callback(new Error('[[error:invalid-uid]]'));
}
if (meta.config.allowPrivateGroups !== '0') {
async.parallel({
isAdmin: async.apply(user.isAdministrator, socket.uid),
@ -34,6 +38,10 @@ SocketGroups.leave = function(socket, data, callback) {
return callback(new Error('[[error:invalid-data]]'));
}
if (!parseInt(socket.uid, 10)) {
return callback(new Error('[[error:invalid-uid]]'));
}
groups.leave(data.groupName, socket.uid, callback);
};

@ -261,6 +261,8 @@ SocketPosts.edit = function(socket, data, callback) {
return callback(new Error('[[error:title-too-long, ' + meta.config.maximumTitleLength + ']]'));
} else if (!data.content || data.content.length < parseInt(meta.config.minimumPostLength, 10)) {
return callback(new Error('[[error:content-too-short, ' + meta.config.minimumPostLength + ']]'));
} else if (data.content.length > parseInt(meta.config.maximumPostLength, 10)) {
return callback(new Error('[[error:content-too-long, ' + meta.config.maximumPostLength + ']]'));
}
// uid, pid, title, content, options
@ -394,9 +396,6 @@ SocketPosts.flag = function(socket, pid, callback) {
post;
async.waterfall([
function(next) {
posts.flag(pid, next);
},
function(next) {
user.getUserFields(socket.uid, ['username', 'reputation'], next);
},
@ -405,7 +404,6 @@ SocketPosts.flag = function(socket, pid, callback) {
return next(new Error('[[error:not-enough-reputation-to-flag]]'));
}
userName = userData.username;
posts.getPostFields(pid, ['tid', 'uid', 'content', 'deleted'], next);
},
function(postData, next) {
@ -413,7 +411,10 @@ SocketPosts.flag = function(socket, pid, callback) {
return next(new Error('[[error:post-deleted]]'));
}
post = postData;
topics.getTopicFields(postData.tid, ['title', 'cid'], next);
posts.flag(pid, next);
},
function(next) {
topics.getTopicFields(post.tid, ['title', 'cid'], next);
},
function(topic, next) {
post.topic = topic;

@ -289,6 +289,8 @@ module.exports = function(Topics) {
function checkContentLength(content, callback) {
if (!content || content.length < parseInt(meta.config.miminumPostLength, 10)) {
return callback(new Error('[[error:content-too-short, ' + meta.config.minimumPostLength + ']]'));
} else if (content.length > parseInt(meta.config.maximumPostLength, 10)) {
return callback(new Error('[[error:content-too-long, ' + meta.config.maximumPostLength + ']]'));
}
callback();
}

@ -177,7 +177,7 @@ module.exports = function(Topics) {
return next(err);
}
latestPid = pids[0];
isDeleted = deleted;
isDeleted = parseInt(deleted, 10) === 1;
++index;
next();
});

@ -49,6 +49,10 @@
<label>Minimum Post Length</label>
<input type="number" class="form-control" value="8" data-field="minimumPostLength">
</div>
<div class="form-group">
<label>Minimum Post Length</label>
<input type="number" class="form-control" value="32767" data-field="maximumPostLength">
</div>
<div class="checkbox">
<label>
<input type="checkbox" data-field="trackIpPerPost"> <strong>Track IP Address for each post</strong>

Loading…
Cancel
Save