ESlint indent

v1.18.x
Peter Jaszkowiak 8 years ago
parent 3b0dd2d1ef
commit 1493afee2a

@ -21,11 +21,16 @@
"no-mixed-operators": ["error", { "allowSamePrecedence": true }], "no-mixed-operators": ["error", { "allowSamePrecedence": true }],
"strict": ["error", "global"], "strict": ["error", "global"],
"consistent-return": "off", "consistent-return": "off",
"func-names": "off",
"no-tabs": "off",
"indent": ["error", "tab"],
// ES6 // ES6
"prefer-rest-params": "off", "prefer-rest-params": "off",
"prefer-spread": "off", "prefer-spread": "off",
"prefer-arrow-callback": "off", "prefer-arrow-callback": "off",
"prefer-template": "off",
"no-var": "off",
// TODO // TODO
"import/no-unresolved": "off", "import/no-unresolved": "off",
@ -90,13 +95,9 @@
"no-restricted-module": "off", "no-restricted-module": "off",
"no-return-assign": "off", "no-return-assign": "off",
"no-restricted-modules": "off", "no-restricted-modules": "off",
"no-tabs": "off",
"indent": "off",
"func-names": "off",
"object-curly-spacing": "off", "object-curly-spacing": "off",
"no-var": "off",
"no-shadow": "off", "no-shadow": "off",
"prefer-template": "off", // "indent": "off",
// "padded-blocks": "off", // "padded-blocks": "off",
// "eol-last": "off", // "eol-last": "off",
// "lines-around-directive": "off", // "lines-around-directive": "off",

@ -75,13 +75,13 @@ Loader.addWorkerEvents = function (worker) {
worker.on('message', function (message) { worker.on('message', function (message) {
if (message && typeof message === 'object' && message.action) { if (message && typeof message === 'object' && message.action) {
switch (message.action) { switch (message.action) {
case 'restart': case 'restart':
console.log('[cluster] Restarting...'); console.log('[cluster] Restarting...');
Loader.restart(); Loader.restart();
break; break;
case 'reload': case 'reload':
console.log('[cluster] Reloading...'); console.log('[cluster] Reloading...');
Loader.reload(); Loader.reload();
break; break;
} }
} }

@ -50,9 +50,9 @@ function minifyScripts(scripts, callback) {
// Follow along here: https://github.com/mishoo/UglifyJS2/issues/700 // Follow along here: https://github.com/mishoo/UglifyJS2/issues/700
try { try {
var minified = uglifyjs.minify(scripts, { var minified = uglifyjs.minify(scripts, {
// outSourceMap: "nodebb.min.js.map", // outSourceMap: "nodebb.min.js.map",
compress: false, compress: false,
}); });
callback(minified.code/* , minified.map*/); callback(minified.code/* , minified.map*/);
} catch (err) { } catch (err) {

@ -15,25 +15,25 @@ define('admin/advanced/logs', function () {
var action = btnEl.attr('data-action'); var action = btnEl.attr('data-action');
switch (action) { switch (action) {
case 'reload': case 'reload':
socket.emit('admin.logs.get', function (err, logs) { socket.emit('admin.logs.get', function (err, logs) {
if (!err) { if (!err) {
logsEl.text(logs); logsEl.text(logs);
logsEl.scrollTop(logsEl.prop('scrollHeight')); logsEl.scrollTop(logsEl.prop('scrollHeight'));
} else { } else {
app.alertError(err.message); app.alertError(err.message);
} }
}); });
break; break;
case 'clear': case 'clear':
socket.emit('admin.logs.clear', function (err) { socket.emit('admin.logs.clear', function (err) {
if (!err) { if (!err) {
app.alertSuccess('[[admin/advanced/logs:clear-success]]'); app.alertSuccess('[[admin/advanced/logs:clear-success]]');
btnEl.prev().click(); btnEl.prev().click();
} }
}); });
break; break;
} }
}); });
}; };

@ -162,7 +162,7 @@ define('admin/extend/plugins', ['jqueryui', 'translator'], function (jqueryui, t
function confirmInstall(pluginID, callback) { function confirmInstall(pluginID, callback) {
bootbox.confirm(translator.compile('admin/extend/plugins:alert.possibly-incompatible', pluginID), function (confirm) { bootbox.confirm(translator.compile('admin/extend/plugins:alert.possibly-incompatible', pluginID), function (confirm) {
callback(confirm); callback(confirm);
}); });
} }

@ -57,18 +57,18 @@ define('admin/extend/rewards', ['translator'], function (translator) {
function select(el) { function select(el) {
el.val(el.attr('data-selected')); el.val(el.attr('data-selected'));
switch (el.attr('name')) { switch (el.attr('name')) {
case 'rid': case 'rid':
selectReward(el); selectReward(el);
break; break;
} }
} }
function update(el) { function update(el) {
el.attr('data-selected', el.val()); el.attr('data-selected', el.val());
switch (el.attr('name')) { switch (el.attr('name')) {
case 'rid': case 'rid':
selectReward(el); selectReward(el);
break; break;
} }
} }
@ -95,15 +95,15 @@ define('admin/extend/rewards', ['translator'], function (translator) {
inputs.forEach(function (input) { inputs.forEach(function (input) {
html += '<label for="' + input.name + '">' + input.label + '<br />'; html += '<label for="' + input.name + '">' + input.label + '<br />';
switch (input.type) { switch (input.type) {
case 'select': case 'select':
html += '<select name="' + input.name + '">'; html += '<select name="' + input.name + '">';
input.values.forEach(function (value) { input.values.forEach(function (value) {
html += '<option value="' + value.value + '">' + value.name + '</option>'; html += '<option value="' + value.value + '">' + value.name + '</option>';
}); });
break; break;
case 'text': case 'text':
html += '<input type="text" name="' + input.name + '" />'; html += '<input type="text" name="' + input.name + '" />';
break; break;
} }
html += '</label><br />'; html += '</label><br />';
}); });

@ -292,10 +292,10 @@ define('admin/general/dashboard', ['semver', 'Chart', 'translator'], function (s
$('[data-action="updateGraph"]').on('click', function () { $('[data-action="updateGraph"]').on('click', function () {
var until; var until;
switch ($(this).attr('data-until')) { switch ($(this).attr('data-until')) {
case 'last-month': case 'last-month':
var lastMonth = new Date(); var lastMonth = new Date();
lastMonth.setDate(lastMonth.getDate() - 30); lastMonth.setDate(lastMonth.getDate() - 30);
until = lastMonth.getTime(); until = lastMonth.getTime();
} }
updateTrafficGraph($(this).attr('data-units'), until); updateTrafficGraph($(this).attr('data-units'), until);
}); });

@ -10,11 +10,11 @@ define('admin/manage/category-analytics', ['Chart'], function (Chart) {
var topicsCanvas = document.getElementById('topics:daily'); var topicsCanvas = document.getElementById('topics:daily');
var postsCanvas = document.getElementById('posts:daily'); var postsCanvas = document.getElementById('posts:daily');
var hourlyLabels = utils.getHoursArray().map(function (text, idx) { var hourlyLabels = utils.getHoursArray().map(function (text, idx) {
return idx % 3 ? '' : text; return idx % 3 ? '' : text;
}); });
var dailyLabels = utils.getDaysArray().map(function (text, idx) { var dailyLabels = utils.getDaysArray().map(function (text, idx) {
return idx % 3 ? '' : text; return idx % 3 ? '' : text;
}); });
if (utils.isMobile()) { if (utils.isMobile()) {
Chart.defaults.global.tooltips.enabled = false; Chart.defaults.global.tooltips.enabled = false;

@ -113,36 +113,36 @@ define('admin/manage/group', [
var action = btnEl.attr('data-action'); var action = btnEl.attr('data-action');
switch (action) { switch (action) {
case 'toggleOwnership': case 'toggleOwnership':
socket.emit('groups.' + (isOwner ? 'rescind' : 'grant'), { socket.emit('groups.' + (isOwner ? 'rescind' : 'grant'), {
toUid: uid, toUid: uid,
groupName: groupName,
}, function (err) {
if (err) {
return app.alertError(err.message);
}
ownerFlagEl.toggleClass('invisible');
});
break;
case 'kick':
bootbox.confirm('[[admin/manage/groups:edit.confirm-remove-user]]', function (confirm) {
if (!confirm) {
return;
}
socket.emit('admin.groups.leave', {
uid: uid,
groupName: groupName, groupName: groupName,
}, function (err) { }, function (err) {
if (err) { if (err) {
return app.alertError(err.message); return app.alertError(err.message);
} }
ownerFlagEl.toggleClass('invisible'); userRow.slideUp().remove();
}); });
break; });
break;
case 'kick': default:
bootbox.confirm('[[admin/manage/groups:edit.confirm-remove-user]]', function (confirm) { break;
if (!confirm) {
return;
}
socket.emit('admin.groups.leave', {
uid: uid,
groupName: groupName,
}, function (err) {
if (err) {
return app.alertError(err.message);
}
userRow.slideUp().remove();
});
});
break;
default:
break;
} }
}); });

@ -274,25 +274,25 @@ app.cacheBuster = null;
function showAlert(type) { function showAlert(type) {
switch (messages[type].format) { switch (messages[type].format) {
case 'alert': case 'alert':
app.alert({ app.alert({
type: 'success', type: 'success',
title: messages[type].title, title: messages[type].title,
message: messages[type].message, message: messages[type].message,
timeout: 5000, timeout: 5000,
}); });
break; break;
case 'modal': case 'modal':
require(['translator'], function (translator) { require(['translator'], function (translator) {
translator.translate(messages[type].message, function (translated) { translator.translate(messages[type].message, function (translated) {
bootbox.alert({ bootbox.alert({
title: messages[type].title, title: messages[type].title,
message: translated, message: translated,
});
}); });
}); });
break; });
break;
} }
} }
@ -366,10 +366,10 @@ app.cacheBuster = null;
}; };
var titleObj = { var titleObj = {
active: false, active: false,
interval: undefined, interval: undefined,
titles: [], titles: [],
}; };
app.alternatingTitle = function (title) { app.alternatingTitle = function (title) {
if (typeof title !== 'string') { if (typeof title !== 'string') {

@ -56,13 +56,13 @@ define('forum/account/settings', ['forum/account/header', 'components', 'sounds'
} }
switch (input.attr('type')) { switch (input.attr('type')) {
case 'text': case 'text':
case 'textarea': case 'textarea':
settings[setting] = input.val(); settings[setting] = input.val();
break; break;
case 'checkbox': case 'checkbox':
settings[setting] = input.is(':checked') ? 1 : 0; settings[setting] = input.is(':checked') ? 1 : 0;
break; break;
} }
}); });

@ -59,61 +59,61 @@ define('forum/groups/details', [
var action = btnEl.attr('data-action'); var action = btnEl.attr('data-action');
switch (action) { switch (action) {
case 'toggleOwnership': case 'toggleOwnership':
socket.emit('groups.' + (isOwner ? 'rescind' : 'grant'), { socket.emit('groups.' + (isOwner ? 'rescind' : 'grant'), {
toUid: uid, toUid: uid,
groupName: groupName, groupName: groupName,
}, function (err) { }, function (err) {
if (!err) { if (!err) {
ownerFlagEl.toggleClass('invisible'); ownerFlagEl.toggleClass('invisible');
} else { } else {
app.alertError(err.message); app.alertError(err.message);
} }
}); });
break; break;
case 'kick': case 'kick':
socket.emit('groups.kick', { socket.emit('groups.kick', {
uid: uid, uid: uid,
groupName: groupName, groupName: groupName,
}, function (err) { }, function (err) {
if (!err) { if (!err) {
userRow.slideUp().remove(); userRow.slideUp().remove();
} else { } else {
app.alertError(err.message); app.alertError(err.message);
} }
}); });
break; break;
case 'update': case 'update':
Details.update(); Details.update();
break; break;
case 'delete': case 'delete':
Details.deleteGroup(); Details.deleteGroup();
break; break;
case 'join': // intentional fall-throughs! case 'join': // intentional fall-throughs!
case 'leave': case 'leave':
case 'accept': case 'accept':
case 'reject': case 'reject':
case 'issueInvite': case 'issueInvite':
case 'rescindInvite': case 'rescindInvite':
case 'acceptInvite': case 'acceptInvite':
case 'rejectInvite': case 'rejectInvite':
case 'acceptAll': case 'acceptAll':
case 'rejectAll': case 'rejectAll':
socket.emit('groups.' + action, { socket.emit('groups.' + action, {
toUid: uid, toUid: uid,
groupName: groupName, groupName: groupName,
}, function (err) { }, function (err) {
if (!err) { if (!err) {
ajaxify.refresh(); ajaxify.refresh();
} else { } else {
app.alertError(err.message); app.alertError(err.message);
} }
}); });
break; break;
} }
}); });
}; };

@ -372,31 +372,31 @@ define('forum/topic/postTools', [
translator.translate('[[topic:stale.warning]]', function (translated) { translator.translate('[[topic:stale.warning]]', function (translated) {
var warning = bootbox.dialog({ var warning = bootbox.dialog({
title: '[[topic:stale.title]]', title: '[[topic:stale.title]]',
message: translated, message: translated,
buttons: { buttons: {
reply: { reply: {
label: '[[topic:stale.reply_anyway]]', label: '[[topic:stale.reply_anyway]]',
className: 'btn-link', className: 'btn-link',
callback: function () { callback: function () {
staleReplyAnyway = true; staleReplyAnyway = true;
callback(); callback();
},
}, },
create: { },
label: '[[topic:stale.create]]', create: {
className: 'btn-primary', label: '[[topic:stale.create]]',
callback: function () { className: 'btn-primary',
translator.translate('[[topic:link_back, ' + ajaxify.data.title + ', ' + config.relative_path + '/topic/' + ajaxify.data.slug + ']]', function (body) { callback: function () {
$(window).trigger('action:composer.topic.new', { translator.translate('[[topic:link_back, ' + ajaxify.data.title + ', ' + config.relative_path + '/topic/' + ajaxify.data.slug + ']]', function (body) {
cid: ajaxify.data.cid, $(window).trigger('action:composer.topic.new', {
body: body, cid: ajaxify.data.cid,
}); body: body,
}); });
}, });
}, },
}, },
}); },
});
warning.modal(); warning.modal();
}); });

@ -290,11 +290,11 @@ define('forum/topic/posts', [
var images = components.get('post/content').find('img[data-state="unloaded"]'); var images = components.get('post/content').find('img[data-state="unloaded"]');
var visible = images.filter(function () { var visible = images.filter(function () {
return utils.isElementInViewport(this); return utils.isElementInViewport(this);
}); });
var posts = $.unique(visible.map(function () { var posts = $.unique(visible.map(function () {
return $(this).parents('[component="post"]').get(0); return $(this).parents('[component="post"]').get(0);
})); }));
var scrollTop = $(window).scrollTop(); var scrollTop = $(window).scrollTop();
var adjusting = false; var adjusting = false;
var adjustQueue = []; var adjustQueue = [];

@ -99,16 +99,16 @@ $('document').ready(function () {
} }
switch (type) { switch (type) {
case 'admin:username': case 'admin:username':
return validateUsername(field); return validateUsername(field);
case 'admin:password': case 'admin:password':
return validatePassword(field); return validatePassword(field);
case 'admin:passwordConfirm': case 'admin:passwordConfirm':
return validateConfirmPassword(field); return validateConfirmPassword(field);
case 'admin:email': case 'admin:email':
return validateEmail(field); return validateEmail(field);
case 'database': case 'database':
return switchDatabase(field); return switchDatabase(field);
} }
} }

@ -214,49 +214,49 @@
var icons = ''; var icons = '';
switch (data.platform) { switch (data.platform) {
case 'Linux': case 'Linux':
icons += '<i class="fa fa-fw fa-linux"></i>'; icons += '<i class="fa fa-fw fa-linux"></i>';
break; break;
case 'Microsoft Windows': case 'Microsoft Windows':
icons += '<i class="fa fa-fw fa-windows"></i>'; icons += '<i class="fa fa-fw fa-windows"></i>';
break; break;
case 'Apple Mac': case 'Apple Mac':
icons += '<i class="fa fa-fw fa-apple"></i>'; icons += '<i class="fa fa-fw fa-apple"></i>';
break; break;
case 'Android': case 'Android':
icons += '<i class="fa fa-fw fa-android"></i>'; icons += '<i class="fa fa-fw fa-android"></i>';
break; break;
case 'iPad': case 'iPad':
icons += '<i class="fa fa-fw fa-tablet"></i>'; icons += '<i class="fa fa-fw fa-tablet"></i>';
break; break;
case 'iPod': // intentional fall-through case 'iPod': // intentional fall-through
case 'iPhone': case 'iPhone':
icons += '<i class="fa fa-fw fa-mobile"></i>'; icons += '<i class="fa fa-fw fa-mobile"></i>';
break; break;
default: default:
icons += '<i class="fa fa-fw fa-question-circle"></i>'; icons += '<i class="fa fa-fw fa-question-circle"></i>';
break; break;
} }
switch (data.browser) { switch (data.browser) {
case 'Chrome': case 'Chrome':
icons += '<i class="fa fa-fw fa-chrome"></i>'; icons += '<i class="fa fa-fw fa-chrome"></i>';
break; break;
case 'Firefox': case 'Firefox':
icons += '<i class="fa fa-fw fa-firefox"></i>'; icons += '<i class="fa fa-fw fa-firefox"></i>';
break; break;
case 'Safari': case 'Safari':
icons += '<i class="fa fa-fw fa-safari"></i>'; icons += '<i class="fa fa-fw fa-safari"></i>';
break; break;
case 'IE': case 'IE':
icons += '<i class="fa fa-fw fa-internet-explorer"></i>'; icons += '<i class="fa fa-fw fa-internet-explorer"></i>';
break; break;
case 'Edge': case 'Edge':
icons += '<i class="fa fa-fw fa-edge"></i>'; icons += '<i class="fa fa-fw fa-edge"></i>';
break; break;
default: default:
icons += '<i class="fa fa-fw fa-question-circle"></i>'; icons += '<i class="fa fa-fw fa-question-circle"></i>';
break; break;
} }
return icons; return icons;

@ -24,41 +24,41 @@ define('iconSelect', function () {
html.find('.fa-icons').prepend($('<i class="fa fa-nbb-none"></i>')); html.find('.fa-icons').prepend($('<i class="fa fa-nbb-none"></i>'));
var picker = bootbox.dialog({ var picker = bootbox.dialog({
onEscape: true, onEscape: true,
backdrop: true, backdrop: true,
show: false, show: false,
message: html, message: html,
title: 'Select an Icon', title: 'Select an Icon',
buttons: { buttons: {
noIcon: { noIcon: {
label: 'No Icon', label: 'No Icon',
className: 'btn-default', className: 'btn-default',
callback: function () { callback: function () {
el.attr('class', 'fa ' + (doubleSize ? 'fa-2x ' : '')); el.attr('class', 'fa ' + (doubleSize ? 'fa-2x ' : ''));
el.val(''); el.val('');
el.attr('value', ''); el.attr('value', '');
onModified(el); onModified(el);
},
}, },
success: { },
label: 'Select', success: {
className: 'btn-primary', label: 'Select',
callback: function (confirm) { className: 'btn-primary',
var iconClass = $('.bootbox .selected').attr('class'); callback: function (confirm) {
var categoryIconClass = $('<div/>').addClass(iconClass).removeClass('fa').removeClass('selected').attr('class'); var iconClass = $('.bootbox .selected').attr('class');
var categoryIconClass = $('<div/>').addClass(iconClass).removeClass('fa').removeClass('selected').attr('class');
if (categoryIconClass) {
el.attr('class', 'fa ' + (doubleSize ? 'fa-2x ' : '') + categoryIconClass); if (categoryIconClass) {
el.val(categoryIconClass); el.attr('class', 'fa ' + (doubleSize ? 'fa-2x ' : '') + categoryIconClass);
el.attr('value', categoryIconClass); el.val(categoryIconClass);
} el.attr('value', categoryIconClass);
}
onModified(el);
}, onModified(el);
}, },
}, },
}); },
});
picker.on('show.bs.modal', function () { picker.on('show.bs.modal', function () {
var modalEl = $(this); var modalEl = $(this);

@ -30,7 +30,7 @@ define('pictureCropper', ['translator', 'cropper'], function (translator, croppe
}); });
}; };
module.handleImageCrop = function (data, callback) { module.handleImageCrop = function (data, callback) {
$('#crop-picture-modal').remove(); $('#crop-picture-modal').remove();
templates.parse('modals/crop_picture', {url: data.url}, function (cropperHtml) { templates.parse('modals/crop_picture', {url: data.url}, function (cropperHtml) {
translator.translate(cropperHtml, function (translated) { translator.translate(cropperHtml, function (translated) {

@ -491,26 +491,26 @@
// and correct NodeBB language codes to timeago codes, if necessary // and correct NodeBB language codes to timeago codes, if necessary
var languageCode = void 0; var languageCode = void 0;
switch (config.userLang) { switch (config.userLang) {
case 'en-GB': case 'en-GB':
case 'en-US': case 'en-US':
languageCode = 'en'; languageCode = 'en';
break; break;
case 'fa-IR': case 'fa-IR':
languageCode = 'fa'; languageCode = 'fa';
break; break;
case 'pt-BR': case 'pt-BR':
languageCode = 'pt-br'; languageCode = 'pt-br';
break; break;
case 'nb': case 'nb':
languageCode = 'no'; languageCode = 'no';
break; break;
default: default:
languageCode = config.userLang; languageCode = config.userLang;
break; break;
} }
jQuery.getScript(config.relative_path + '/assets/vendor/jquery/timeago/locales/jquery.timeago.' + languageCode + '.js').done(function () { jQuery.getScript(config.relative_path + '/assets/vendor/jquery/timeago/locales/jquery.timeago.' + languageCode + '.js').done(function () {

@ -72,29 +72,29 @@ app.isConnected = false;
var room; var room;
switch (url_parts[0]) { switch (url_parts[0]) {
case 'user': case 'user':
room = 'user/' + (ajaxify.data ? ajaxify.data.theirid : 0); room = 'user/' + (ajaxify.data ? ajaxify.data.theirid : 0);
break; break;
case 'topic': case 'topic':
room = 'topic_' + url_parts[1]; room = 'topic_' + url_parts[1];
break; break;
case 'category': case 'category':
room = 'category_' + url_parts[1]; room = 'category_' + url_parts[1];
break; break;
case 'recent': case 'recent':
room = 'recent_topics'; room = 'recent_topics';
break; break;
case 'unread': case 'unread':
room = 'unread_topics'; room = 'unread_topics';
break; break;
case 'popular': case 'popular':
room = 'popular_topics'; room = 'popular_topics';
break; break;
case 'admin': case 'admin':
room = 'admin'; room = 'admin';
break; break;
case 'categories': case 'categories':
room = 'categories'; room = 'categories';
break; break;
} }
app.currentRoom = ''; app.currentRoom = '';

@ -30,8 +30,8 @@ pluginsController.get = function (req, res, next) {
return next(err); return next(err);
} }
var compatiblePkgNames = payload.compatible.map(function (pkgData) { var compatiblePkgNames = payload.compatible.map(function (pkgData) {
return pkgData.name; return pkgData.name;
}); });
res.render('admin/extend/plugins', { res.render('admin/extend/plugins', {
installed: payload.compatible.filter(function (plugin) { installed: payload.compatible.filter(function (plugin) {

@ -11,12 +11,12 @@ settingsController.get = function (req, res, next) {
var term = req.params.term ? req.params.term : 'general'; var term = req.params.term ? req.params.term : 'general';
switch (req.params.term) { switch (req.params.term) {
case 'email': case 'email':
renderEmail(req, res, next); renderEmail(req, res, next);
break; break;
default: default:
res.render('admin/settings/' + term); res.render('admin/settings/' + term);
} }
}; };

@ -124,11 +124,11 @@ apiController.renderWidgets = function (req, res, next) {
req, req,
res, res,
function (err, widgets) { function (err, widgets) {
if (err) { if (err) {
return next(err); return next(err);
} }
res.status(200).json(widgets); res.status(200).json(widgets);
}); });
}; };
apiController.getPostData = function (pid, uid, callback) { apiController.getPostData = function (pid, uid, callback) {

@ -419,11 +419,11 @@ Controllers.handleURIErrors = function (err, req, res, next) {
Controllers.handleErrors = function (err, req, res, next) { Controllers.handleErrors = function (err, req, res, next) {
switch (err.code) { switch (err.code) {
case 'EBADCSRFTOKEN': case 'EBADCSRFTOKEN':
winston.error(req.path + '\n', err.message); winston.error(req.path + '\n', err.message);
return res.sendStatus(403); return res.sendStatus(403);
case 'blacklisted-ip': case 'blacklisted-ip':
return res.status(403).type('text/plain').send(err.message); return res.status(403).type('text/plain').send(err.message);
} }
if (parseInt(err.status, 10) === 302 && err.path) { if (parseInt(err.status, 10) === 302 && err.path) {

@ -431,7 +431,7 @@ module.exports = function (db, module) {
return item && item.value; return item && item.value;
}); });
callback(err, data); callback(err, data);
}); });
} }
module.sortedSetRemoveRangeByLex = function (key, min, max, callback) { module.sortedSetRemoveRangeByLex = function (key, min, max, callback) {

@ -302,8 +302,8 @@ var utils = require('../public/src/utils');
Groups.exists = function (name, callback) { Groups.exists = function (name, callback) {
if (Array.isArray(name)) { if (Array.isArray(name)) {
var slugs = name.map(function (groupName) { var slugs = name.map(function (groupName) {
return utils.slugify(groupName); return utils.slugify(groupName);
}); });
async.parallel([ async.parallel([
function (next) { function (next) {
next(null, slugs.map(function (slug) { next(null, slugs.map(function (slug) {

@ -38,25 +38,25 @@ module.exports = function (Groups) {
Groups.sort = function (strategy, groups, next) { Groups.sort = function (strategy, groups, next) {
switch (strategy) { switch (strategy) {
case 'count': case 'count':
groups = groups.sort(function (a, b) { groups = groups.sort(function (a, b) {
return a.slug > b.slug; return a.slug > b.slug;
}).sort(function (a, b) { }).sort(function (a, b) {
return b.memberCount - a.memberCount; return b.memberCount - a.memberCount;
}); });
break; break;
case 'date': case 'date':
groups = groups.sort(function (a, b) { groups = groups.sort(function (a, b) {
return b.createtime - a.createtime; return b.createtime - a.createtime;
}); });
break; break;
case 'alpha': // intentional fall-through case 'alpha': // intentional fall-through
default: default:
groups = groups.sort(function (a, b) { groups = groups.sort(function (a, b) {
return a.slug > b.slug ? 1 : -1; return a.slug > b.slug ? 1 : -1;
}); });
} }
next(null, groups); next(null, groups);

@ -256,7 +256,7 @@ Messaging.canMessageUser = function (uid, toUid, callback) {
return next(); return next();
} }
next(new Error('[[error:chat-restricted]]')); next(new Error('[[error:chat-restricted]]'));
}, },
], callback); ], callback);
}; };

@ -6,8 +6,8 @@ var async = require('async');
var db = require('../database'); var db = require('../database');
var Blacklist = { var Blacklist = {
_rules: [], _rules: [],
}; };
Blacklist.load = function (callback) { Blacklist.load = function (callback) {
async.waterfall([ async.waterfall([

@ -84,37 +84,37 @@ exports.buildTargets = function (targets, callback) {
async.eachSeries(targets, function (target, next) { async.eachSeries(targets, function (target, next) {
var startTime; var startTime;
switch (target) { switch (target) {
case 'js': case 'js':
setImmediate(next); setImmediate(next);
break; break;
case 'clientCSS': case 'clientCSS':
winston.info('[build] Building client-side CSS'); winston.info('[build] Building client-side CSS');
startTime = Date.now(); startTime = Date.now();
meta.css.minify('client', step.bind(this, startTime, target, next)); meta.css.minify('client', step.bind(this, startTime, target, next));
break; break;
case 'acpCSS': case 'acpCSS':
winston.info('[build] Building admin control panel CSS'); winston.info('[build] Building admin control panel CSS');
startTime = Date.now(); startTime = Date.now();
meta.css.minify('admin', step.bind(this, startTime, target, next)); meta.css.minify('admin', step.bind(this, startTime, target, next));
break; break;
case 'tpl': case 'tpl':
winston.info('[build] Building templates'); winston.info('[build] Building templates');
startTime = Date.now(); startTime = Date.now();
meta.templates.compile(step.bind(this, startTime, target, next)); meta.templates.compile(step.bind(this, startTime, target, next));
break; break;
case 'lang': case 'lang':
winston.info('[build] Building language files'); winston.info('[build] Building language files');
startTime = Date.now(); startTime = Date.now();
meta.languages.build(step.bind(this, startTime, target, next)); meta.languages.build(step.bind(this, startTime, target, next));
break; break;
default: default:
winston.warn('[build] Unknown build target: \'' + target + '\''); winston.warn('[build] Unknown build target: \'' + target + '\'');
setImmediate(next); setImmediate(next);
break; break;
} }
}, next); }, next);
}, },

@ -134,8 +134,8 @@ module.exports = function (Meta) {
var themeId = data.currentThemeId || 'nodebb-theme-persona'; var themeId = data.currentThemeId || 'nodebb-theme-persona';
var themeObj = data.themesData.filter(function (themeObj) { var themeObj = data.themesData.filter(function (themeObj) {
return themeObj.id === themeId; return themeObj.id === themeId;
})[0]; })[0];
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {
winston.info('[themes] Using theme ' + themeId); winston.info('[themes] Using theme ' + themeId);

@ -461,33 +461,33 @@ var utils = require('../public/src/utils');
switch (mergeId) { switch (mergeId) {
// intentional fall-through // intentional fall-through
case 'notifications:upvoted_your_post_in': case 'notifications:upvoted_your_post_in':
case 'notifications:user_started_following_you': case 'notifications:user_started_following_you':
case 'notifications:user_posted_to': case 'notifications:user_posted_to':
case 'notifications:user_flagged_post_in': case 'notifications:user_flagged_post_in':
var usernames = set.map(function (notifObj) { var usernames = set.map(function (notifObj) {
return notifObj && notifObj.user && notifObj.user.username; return notifObj && notifObj.user && notifObj.user.username;
}).filter(function (username, idx, array) { }).filter(function (username, idx, array) {
return array.indexOf(username) === idx; return array.indexOf(username) === idx;
}); });
var numUsers = usernames.length; var numUsers = usernames.length;
var title = S(notifications[modifyIndex].topicTitle || '').decodeHTMLEntities().s; var title = S(notifications[modifyIndex].topicTitle || '').decodeHTMLEntities().s;
var titleEscaped = title.replace(/%/g, '&#37;').replace(/,/g, '&#44;'); var titleEscaped = title.replace(/%/g, '&#37;').replace(/,/g, '&#44;');
titleEscaped = titleEscaped ? (', ' + titleEscaped) : ''; titleEscaped = titleEscaped ? (', ' + titleEscaped) : '';
if (numUsers === 2) { if (numUsers === 2) {
notifications[modifyIndex].bodyShort = '[[' + mergeId + '_dual, ' + usernames.join(', ') + titleEscaped + ']]'; notifications[modifyIndex].bodyShort = '[[' + mergeId + '_dual, ' + usernames.join(', ') + titleEscaped + ']]';
} else if (numUsers > 2) { } else if (numUsers > 2) {
notifications[modifyIndex].bodyShort = '[[' + mergeId + '_multiple, ' + usernames[0] + ', ' + (numUsers - 1) + titleEscaped + ']]'; notifications[modifyIndex].bodyShort = '[[' + mergeId + '_multiple, ' + usernames[0] + ', ' + (numUsers - 1) + titleEscaped + ']]';
} }
notifications[modifyIndex].path = set[set.length - 1].path; notifications[modifyIndex].path = set[set.length - 1].path;
break; break;
case 'new_register': case 'new_register':
notifications[modifyIndex].bodyShort = '[[notifications:' + mergeId + '_multiple, ' + set.length + ']]'; notifications[modifyIndex].bodyShort = '[[notifications:' + mergeId + '_multiple, ' + set.length + ']]';
break; break;
} }
// Filter out duplicates // Filter out duplicates

@ -83,18 +83,18 @@ module.exports = function (Plugins) {
var hookType = hook.split(':')[0]; var hookType = hook.split(':')[0];
switch (hookType) { switch (hookType) {
case 'filter': case 'filter':
fireFilterHook(hook, hookList, params, callback); fireFilterHook(hook, hookList, params, callback);
break; break;
case 'action': case 'action':
fireActionHook(hook, hookList, params, callback); fireActionHook(hook, hookList, params, callback);
break; break;
case 'static': case 'static':
fireStaticHook(hook, hookList, params, callback); fireStaticHook(hook, hookList, params, callback);
break; break;
default: default:
winston.warn('[plugins] Unknown hookType: ' + hookType + ', hook : ' + hook); winston.warn('[plugins] Unknown hookType: ' + hookType + ', hook : ' + hook);
break; break;
} }
}; };

@ -247,18 +247,18 @@ module.exports = function (Posts) {
if (prop === 'flag:state') { if (prop === 'flag:state') {
switch (postObj[prop]) { switch (postObj[prop]) {
case 'open': case 'open':
postObj.flagData.labelClass = 'info'; postObj.flagData.labelClass = 'info';
break; break;
case 'wip': case 'wip':
postObj.flagData.labelClass = 'warning'; postObj.flagData.labelClass = 'warning';
break; break;
case 'resolved': case 'resolved':
postObj.flagData.labelClass = 'success'; postObj.flagData.labelClass = 'success';
break; break;
case 'rejected': case 'rejected':
postObj.flagData.labelClass = 'danger'; postObj.flagData.labelClass = 'danger';
break; break;
} }
} }
@ -324,22 +324,22 @@ module.exports = function (Posts) {
changes.forEach(function (property) { changes.forEach(function (property) {
switch (property) { switch (property) {
case 'assignee': // intentional fall-through case 'assignee': // intentional fall-through
case 'state': case 'state':
history.unshift({ history.unshift({
uid: uid, uid: uid,
type: property, type: property,
value: flagObj[property], value: flagObj[property],
timestamp: Date.now(), timestamp: Date.now(),
}); });
break; break;
case 'notes': case 'notes':
history.unshift({ history.unshift({
uid: uid, uid: uid,
type: property, type: property,
timestamp: Date.now(), timestamp: Date.now(),
}); });
} }
}); });

@ -21,9 +21,9 @@ var sitemap = {
sitemap.render = function (callback) { sitemap.render = function (callback) {
var numTopics = parseInt(meta.config.sitemapTopics, 10) || 500; var numTopics = parseInt(meta.config.sitemapTopics, 10) || 500;
var returnData = { var returnData = {
url: nconf.get('url'), url: nconf.get('url'),
topics: [], topics: [],
}; };
var numPages; var numPages;
async.waterfall([ async.waterfall([
@ -55,22 +55,22 @@ sitemap.getPages = function (callback) {
} }
var urls = [{ var urls = [{
url: '', url: '',
changefreq: 'weekly', changefreq: 'weekly',
priority: 0.6, priority: 0.6,
}, { }, {
url: '/recent', url: '/recent',
changefreq: 'daily', changefreq: 'daily',
priority: 0.4, priority: 0.4,
}, { }, {
url: '/users', url: '/users',
changefreq: 'daily', changefreq: 'daily',
priority: 0.4, priority: 0.4,
}, { }, {
url: '/groups', url: '/groups',
changefreq: 'daily', changefreq: 'daily',
priority: 0.4, priority: 0.4,
}]; }];
plugins.fireHook('filter:sitemap.getPages', {urls: urls}, function (err, data) { plugins.fireHook('filter:sitemap.getPages', {urls: urls}, function (err, data) {
if (err) { if (err) {

@ -26,25 +26,25 @@ module.exports = function (SocketUser) {
}, },
function (next) { function (next) {
switch (type) { switch (type) {
case 'default': case 'default':
next(null, ''); next(null, '');
break; break;
case 'uploaded': case 'uploaded':
user.getUserField(data.uid, 'uploadedpicture', next); user.getUserField(data.uid, 'uploadedpicture', next);
break; break;
default: default:
plugins.fireHook('filter:user.getPicture', { plugins.fireHook('filter:user.getPicture', {
uid: socket.uid, uid: socket.uid,
type: type, type: type,
picture: undefined, picture: undefined,
}, function (err, returnData) { }, function (err, returnData) {
if (err) { if (err) {
return next(err); return next(err);
} }
next(null, returnData.picture || ''); next(null, returnData.picture || '');
}); });
break; break;
} }
}, },
function (picture, next) { function (picture, next) {

@ -57,21 +57,21 @@ start.start = function () {
], function (err) { ], function (err) {
if (err) { if (err) {
switch (err.message) { switch (err.message) {
case 'schema-out-of-date': case 'schema-out-of-date':
winston.warn('Your NodeBB schema is out-of-date. Please run the following command to bring your dataset up to spec:'); winston.warn('Your NodeBB schema is out-of-date. Please run the following command to bring your dataset up to spec:');
winston.warn(' ./nodebb upgrade'); winston.warn(' ./nodebb upgrade');
break; break;
case 'dependencies-out-of-date': case 'dependencies-out-of-date':
winston.warn('One or more of NodeBB\'s dependent packages are out-of-date. Please run the following command to update them:'); winston.warn('One or more of NodeBB\'s dependent packages are out-of-date. Please run the following command to update them:');
winston.warn(' ./nodebb upgrade'); winston.warn(' ./nodebb upgrade');
break; break;
case 'dependencies-missing': case 'dependencies-missing':
winston.warn('One or more of NodeBB\'s dependent packages are missing. Please run the following command to update them:'); winston.warn('One or more of NodeBB\'s dependent packages are missing. Please run the following command to update them:');
winston.warn(' ./nodebb upgrade'); winston.warn(' ./nodebb upgrade');
break; break;
default: default:
winston.error(err); winston.error(err);
break; break;
} }
// Either way, bad stuff happened. Abort start. // Either way, bad stuff happened. Abort start.
@ -125,8 +125,8 @@ function addProcessHandlers() {
var meta = require('./meta'); var meta = require('./meta');
switch (message.action) { switch (message.action) {
case 'reload': case 'reload':
meta.reload(); meta.reload();
break; break;
} }
}); });

@ -30,18 +30,18 @@ module.exports = function (Topics) {
} }
switch (meta.config.teaserPost) { switch (meta.config.teaserPost) {
case 'first': case 'first':
teaserPids.push(topic.mainPid); teaserPids.push(topic.mainPid);
break; break;
case 'last-post': case 'last-post':
teaserPids.push(topic.teaserPid || topic.mainPid); teaserPids.push(topic.teaserPid || topic.mainPid);
break; break;
case 'last-reply': // intentional fall-through case 'last-reply': // intentional fall-through
default: default:
teaserPids.push(topic.teaserPid); teaserPids.push(topic.teaserPid);
break; break;
} }
} }
}); });

@ -121,10 +121,10 @@ module.exports = function (Topics) {
return false; return false;
} }
switch (filter) { switch (filter) {
case 'new': case 'new':
return !userRead[recentTopic.value]; return !userRead[recentTopic.value];
default: default:
return !userRead[recentTopic.value] || recentTopic.score > userRead[recentTopic.value]; return !userRead[recentTopic.value] || recentTopic.score > userRead[recentTopic.value];
} }
}).map(function (topic) { }).map(function (topic) {
return topic.value; return topic.value;

@ -119,9 +119,9 @@ module.exports = function (User) {
function formatBanData(data) { function formatBanData(data) {
var reasons = data.reasons.reduce(function (memo, cur) { var reasons = data.reasons.reduce(function (memo, cur) {
memo[cur.score] = cur.value; memo[cur.score] = cur.value;
return memo; return memo;
}, {}); }, {});
data.bans = data.bans.map(function (banObj) { data.bans = data.bans.map(function (banObj) {
banObj.until = parseInt(banObj.value, 10); banObj.until = parseInt(banObj.value, 10);

@ -5,59 +5,59 @@ var assert = require('assert');
var search = require('../src/admin/search'); var search = require('../src/admin/search');
describe('admin search', function () { describe('admin search', function () {
describe('filterDirectories', function () { describe('filterDirectories', function () {
it('should resolve all paths to relative paths', function (done) { it('should resolve all paths to relative paths', function (done) {
assert.deepEqual(search.filterDirectories([ assert.deepEqual(search.filterDirectories([
'hfjksfd/fdsgagag/admin/gdhgfsdg/sggag.tpl', 'hfjksfd/fdsgagag/admin/gdhgfsdg/sggag.tpl',
]), [ ]), [
'admin/gdhgfsdg/sggag', 'admin/gdhgfsdg/sggag',
]); ]);
done(); done();
}); });
it('should exclude partials', function (done) { it('should exclude partials', function (done) {
assert.deepEqual(search.filterDirectories([ assert.deepEqual(search.filterDirectories([
'hfjksfd/fdsgagag/admin/gdhgfsdg/sggag.tpl', 'hfjksfd/fdsgagag/admin/gdhgfsdg/sggag.tpl',
'dfahdfsgf/admin/partials/hgkfds/fdhsdfh.tpl', 'dfahdfsgf/admin/partials/hgkfds/fdhsdfh.tpl',
]), [ ]), [
'admin/gdhgfsdg/sggag', 'admin/gdhgfsdg/sggag',
]); ]);
done(); done();
}); });
it('should exclude files in the admin directory', function (done) { it('should exclude files in the admin directory', function (done) {
assert.deepEqual(search.filterDirectories([ assert.deepEqual(search.filterDirectories([
'hfjksfd/fdsgagag/admin/gdhgfsdg/sggag.tpl', 'hfjksfd/fdsgagag/admin/gdhgfsdg/sggag.tpl',
'dfdasg/admin/hjkdfsk.tpl', 'dfdasg/admin/hjkdfsk.tpl',
]), [ ]), [
'admin/gdhgfsdg/sggag', 'admin/gdhgfsdg/sggag',
]); ]);
done(); done();
}); });
}); });
describe('sanitize', function () { describe('sanitize', function () {
it('should strip out scripts', function (done) { it('should strip out scripts', function (done) {
assert.equal( assert.equal(
search.sanitize('Pellentesque tristique senectus' + search.sanitize('Pellentesque tristique senectus' +
'<script>alert("nope");</script> habitant morbi'), '<script>alert("nope");</script> habitant morbi'),
'Pellentesque tristique senectus' + 'Pellentesque tristique senectus' +
' habitant morbi' ' habitant morbi'
); );
done(); done();
}); });
it('should remove all tags', function (done) { it('should remove all tags', function (done) {
assert.equal( assert.equal(
search.sanitize('<p>Pellentesque <b>habitant morbi</b> tristique senectus' + search.sanitize('<p>Pellentesque <b>habitant morbi</b> tristique senectus' +
'Aenean <i>vitae</i> est.Mauris <a href="placerat">eleifend</a> leo.</p>'), 'Aenean <i>vitae</i> est.Mauris <a href="placerat">eleifend</a> leo.</p>'),
'Pellentesque habitant morbi tristique senectus' + 'Pellentesque habitant morbi tristique senectus' +
'Aenean vitae est.Mauris eleifend leo.' 'Aenean vitae est.Mauris eleifend leo.'
); );
done(); done();
}); });
}); });
describe('simplify', function () { describe('simplify', function () {
it('should remove all mustaches', function (done) { it('should remove all mustaches', function (done) {
assert.equal( assert.equal(
search.simplify( search.simplify(
'Pellentesque tristique {{senectus}}habitant morbi' + 'Pellentesque tristique {{senectus}}habitant morbi' +
'liquam tincidunt {mauris.eu}risus' 'liquam tincidunt {mauris.eu}risus'
@ -65,10 +65,10 @@ describe('admin search', function () {
'Pellentesque tristique habitant morbi' + 'Pellentesque tristique habitant morbi' +
'liquam tincidunt risus' 'liquam tincidunt risus'
); );
done(); done();
}); });
it('should collapse all whitespace', function (done) { it('should collapse all whitespace', function (done) {
assert.equal( assert.equal(
search.simplify( search.simplify(
'Pellentesque tristique habitant morbi' + 'Pellentesque tristique habitant morbi' +
' \n\n liquam tincidunt mauris eu risus.' ' \n\n liquam tincidunt mauris eu risus.'
@ -76,7 +76,7 @@ describe('admin search', function () {
'Pellentesque tristique habitant morbi' + 'Pellentesque tristique habitant morbi' +
'\nliquam tincidunt mauris eu risus.' '\nliquam tincidunt mauris eu risus.'
); );
done(); done();
}); });
}); });
}); });

@ -562,11 +562,11 @@ describe('Topic\'s', function () {
var originalBookmark = 5; var originalBookmark = 5;
function postReply(next) { function postReply(next) {
topics.reply({uid: topic.userId, content: 'test post ' + replies.length, tid: newTopic.tid}, function (err, result) { topics.reply({uid: topic.userId, content: 'test post ' + replies.length, tid: newTopic.tid}, function (err, result) {
assert.equal(err, null, 'was created with error'); assert.equal(err, null, 'was created with error');
assert.ok(result); assert.ok(result);
replies.push(result); replies.push(result);
next(); next();
} }
); );
} }

@ -728,7 +728,7 @@ describe('User', function () {
it('should send digests', function (done) { it('should send digests', function (done) {
User.updateDigestSetting(uid, 'day', function (err) { User.updateDigestSetting(uid, 'day', function (err) {
assert.ifError(err); assert.ifError(err);
User.digest.execute('day', function (err) { User.digest.execute('day', function (err) {
assert.ifError(err); assert.ifError(err);
done(); done();
}); });

Loading…
Cancel
Save