ESlint indent

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

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

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

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

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

@ -162,7 +162,7 @@ define('admin/extend/plugins', ['jqueryui', 'translator'], function (jqueryui, t
function confirmInstall(pluginID, callback) {
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) {
el.val(el.attr('data-selected'));
switch (el.attr('name')) {
case 'rid':
selectReward(el);
break;
case 'rid':
selectReward(el);
break;
}
}
function update(el) {
el.attr('data-selected', el.val());
switch (el.attr('name')) {
case 'rid':
selectReward(el);
break;
case 'rid':
selectReward(el);
break;
}
}
@ -95,15 +95,15 @@ define('admin/extend/rewards', ['translator'], function (translator) {
inputs.forEach(function (input) {
html += '<label for="' + input.name + '">' + input.label + '<br />';
switch (input.type) {
case 'select':
html += '<select name="' + input.name + '">';
input.values.forEach(function (value) {
html += '<option value="' + value.value + '">' + value.name + '</option>';
});
break;
case 'text':
html += '<input type="text" name="' + input.name + '" />';
break;
case 'select':
html += '<select name="' + input.name + '">';
input.values.forEach(function (value) {
html += '<option value="' + value.value + '">' + value.name + '</option>';
});
break;
case 'text':
html += '<input type="text" name="' + input.name + '" />';
break;
}
html += '</label><br />';
});

@ -292,10 +292,10 @@ define('admin/general/dashboard', ['semver', 'Chart', 'translator'], function (s
$('[data-action="updateGraph"]').on('click', function () {
var until;
switch ($(this).attr('data-until')) {
case 'last-month':
var lastMonth = new Date();
lastMonth.setDate(lastMonth.getDate() - 30);
until = lastMonth.getTime();
case 'last-month':
var lastMonth = new Date();
lastMonth.setDate(lastMonth.getDate() - 30);
until = lastMonth.getTime();
}
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 postsCanvas = document.getElementById('posts:daily');
var hourlyLabels = utils.getHoursArray().map(function (text, idx) {
return idx % 3 ? '' : text;
});
return idx % 3 ? '' : text;
});
var dailyLabels = utils.getDaysArray().map(function (text, idx) {
return idx % 3 ? '' : text;
});
return idx % 3 ? '' : text;
});
if (utils.isMobile()) {
Chart.defaults.global.tooltips.enabled = false;

@ -113,36 +113,36 @@ define('admin/manage/group', [
var action = btnEl.attr('data-action');
switch (action) {
case 'toggleOwnership':
socket.emit('groups.' + (isOwner ? 'rescind' : 'grant'), {
toUid: uid,
case 'toggleOwnership':
socket.emit('groups.' + (isOwner ? 'rescind' : 'grant'), {
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,
}, function (err) {
if (err) {
return app.alertError(err.message);
}
ownerFlagEl.toggleClass('invisible');
userRow.slideUp().remove();
});
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,
}, function (err) {
if (err) {
return app.alertError(err.message);
}
userRow.slideUp().remove();
});
});
break;
default:
break;
});
break;
default:
break;
}
});

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

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

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

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

@ -290,11 +290,11 @@ define('forum/topic/posts', [
var images = components.get('post/content').find('img[data-state="unloaded"]');
var visible = images.filter(function () {
return utils.isElementInViewport(this);
});
return utils.isElementInViewport(this);
});
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 adjusting = false;
var adjustQueue = [];

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

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

@ -24,41 +24,41 @@ define('iconSelect', function () {
html.find('.fa-icons').prepend($('<i class="fa fa-nbb-none"></i>'));
var picker = bootbox.dialog({
onEscape: true,
backdrop: true,
show: false,
message: html,
title: 'Select an Icon',
buttons: {
noIcon: {
label: 'No Icon',
className: 'btn-default',
callback: function () {
el.attr('class', 'fa ' + (doubleSize ? 'fa-2x ' : ''));
el.val('');
el.attr('value', '');
onModified(el);
},
onEscape: true,
backdrop: true,
show: false,
message: html,
title: 'Select an Icon',
buttons: {
noIcon: {
label: 'No Icon',
className: 'btn-default',
callback: function () {
el.attr('class', 'fa ' + (doubleSize ? 'fa-2x ' : ''));
el.val('');
el.attr('value', '');
onModified(el);
},
success: {
label: 'Select',
className: 'btn-primary',
callback: function (confirm) {
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);
el.val(categoryIconClass);
el.attr('value', categoryIconClass);
}
onModified(el);
},
},
success: {
label: 'Select',
className: 'btn-primary',
callback: function (confirm) {
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);
el.val(categoryIconClass);
el.attr('value', categoryIconClass);
}
onModified(el);
},
},
});
},
});
picker.on('show.bs.modal', function () {
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();
templates.parse('modals/crop_picture', {url: data.url}, function (cropperHtml) {
translator.translate(cropperHtml, function (translated) {

@ -491,26 +491,26 @@
// and correct NodeBB language codes to timeago codes, if necessary
var languageCode = void 0;
switch (config.userLang) {
case 'en-GB':
case 'en-US':
languageCode = 'en';
break;
case 'fa-IR':
languageCode = 'fa';
break;
case 'pt-BR':
languageCode = 'pt-br';
break;
case 'nb':
languageCode = 'no';
break;
default:
languageCode = config.userLang;
break;
case 'en-GB':
case 'en-US':
languageCode = 'en';
break;
case 'fa-IR':
languageCode = 'fa';
break;
case 'pt-BR':
languageCode = 'pt-br';
break;
case 'nb':
languageCode = 'no';
break;
default:
languageCode = config.userLang;
break;
}
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;
switch (url_parts[0]) {
case 'user':
room = 'user/' + (ajaxify.data ? ajaxify.data.theirid : 0);
case 'user':
room = 'user/' + (ajaxify.data ? ajaxify.data.theirid : 0);
break;
case 'topic':
room = 'topic_' + url_parts[1];
case 'topic':
room = 'topic_' + url_parts[1];
break;
case 'category':
room = 'category_' + url_parts[1];
case 'category':
room = 'category_' + url_parts[1];
break;
case 'recent':
room = 'recent_topics';
case 'recent':
room = 'recent_topics';
break;
case 'unread':
room = 'unread_topics';
case 'unread':
room = 'unread_topics';
break;
case 'popular':
room = 'popular_topics';
case 'popular':
room = 'popular_topics';
break;
case 'admin':
room = 'admin';
case 'admin':
room = 'admin';
break;
case 'categories':
room = 'categories';
case 'categories':
room = 'categories';
break;
}
app.currentRoom = '';

@ -30,8 +30,8 @@ pluginsController.get = function (req, res, next) {
return next(err);
}
var compatiblePkgNames = payload.compatible.map(function (pkgData) {
return pkgData.name;
});
return pkgData.name;
});
res.render('admin/extend/plugins', {
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';
switch (req.params.term) {
case 'email':
renderEmail(req, res, next);
break;
case 'email':
renderEmail(req, res, next);
break;
default:
res.render('admin/settings/' + term);
default:
res.render('admin/settings/' + term);
}
};

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -57,21 +57,21 @@ start.start = function () {
], function (err) {
if (err) {
switch (err.message) {
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(' ./nodebb upgrade');
break;
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(' ./nodebb upgrade');
break;
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(' ./nodebb upgrade');
break;
default:
winston.error(err);
break;
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(' ./nodebb upgrade');
break;
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(' ./nodebb upgrade');
break;
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(' ./nodebb upgrade');
break;
default:
winston.error(err);
break;
}
// Either way, bad stuff happened. Abort start.
@ -125,8 +125,8 @@ function addProcessHandlers() {
var meta = require('./meta');
switch (message.action) {
case 'reload':
meta.reload();
case 'reload':
meta.reload();
break;
}
});

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

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

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

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

@ -562,11 +562,11 @@ describe('Topic\'s', function () {
var originalBookmark = 5;
function postReply(next) {
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.ok(result);
replies.push(result);
next();
}
assert.equal(err, null, 'was created with error');
assert.ok(result);
replies.push(result);
next();
}
);
}

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

Loading…
Cancel
Save