mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-10 16:05:49 +01:00
Fix space-before-function-paren linter rule
This commit is contained in:
@@ -10,26 +10,26 @@ var db = require('../database');
|
||||
|
||||
var widgets = {};
|
||||
|
||||
widgets.render = function(uid, area, req, res, callback) {
|
||||
widgets.render = function (uid, area, req, res, callback) {
|
||||
if (!area.locations || !area.template) {
|
||||
return callback(new Error('[[error:invalid-data]]'));
|
||||
}
|
||||
|
||||
widgets.getAreas(['global', area.template], area.locations, function(err, data) {
|
||||
widgets.getAreas(['global', area.template], area.locations, function (err, data) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
var widgetsByLocation = {};
|
||||
|
||||
async.map(area.locations, function(location, done) {
|
||||
async.map(area.locations, function (location, done) {
|
||||
widgetsByLocation[location] = data.global[location].concat(data[area.template][location]);
|
||||
|
||||
if (!widgetsByLocation[location].length) {
|
||||
return done(null, {location: location, widgets: []});
|
||||
}
|
||||
|
||||
async.map(widgetsByLocation[location], function(widget, next) {
|
||||
async.map(widgetsByLocation[location], function (widget, next) {
|
||||
if (!widget || !widget.data ||
|
||||
(!!widget.data['hide-registered'] && uid !== 0) ||
|
||||
(!!widget.data['hide-guests'] && uid === 0) ||
|
||||
@@ -43,7 +43,7 @@ widgets.render = function(uid, area, req, res, callback) {
|
||||
data: widget.data,
|
||||
req: req,
|
||||
res: res
|
||||
}, function(err, html) {
|
||||
}, function (err, html) {
|
||||
if (err || html === null) {
|
||||
return next(err);
|
||||
}
|
||||
@@ -53,7 +53,7 @@ widgets.render = function(uid, area, req, res, callback) {
|
||||
}
|
||||
|
||||
if (widget.data.container && widget.data.container.match('{body}')) {
|
||||
translator.translate(widget.data.title, function(title) {
|
||||
translator.translate(widget.data.title, function (title) {
|
||||
html = templates.parse(widget.data.container, {
|
||||
title: title,
|
||||
body: html
|
||||
@@ -65,27 +65,27 @@ widgets.render = function(uid, area, req, res, callback) {
|
||||
next(null, {html: html});
|
||||
}
|
||||
});
|
||||
}, function(err, result) {
|
||||
}, function (err, result) {
|
||||
done(err, {location: location, widgets: result.filter(Boolean)});
|
||||
});
|
||||
}, callback);
|
||||
});
|
||||
};
|
||||
|
||||
widgets.getAreas = function(templates, locations, callback) {
|
||||
var keys = templates.map(function(tpl) {
|
||||
widgets.getAreas = function (templates, locations, callback) {
|
||||
var keys = templates.map(function (tpl) {
|
||||
return 'widgets:' + tpl;
|
||||
});
|
||||
db.getObjectsFields(keys, locations, function(err, data) {
|
||||
db.getObjectsFields(keys, locations, function (err, data) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
var returnData = {};
|
||||
|
||||
templates.forEach(function(template, index) {
|
||||
templates.forEach(function (template, index) {
|
||||
returnData[template] = returnData[template] || {};
|
||||
locations.forEach(function(location) {
|
||||
locations.forEach(function (location) {
|
||||
if (data && data[index] && data[index][location]) {
|
||||
try {
|
||||
returnData[template][location] = JSON.parse(data[index][location]);
|
||||
@@ -103,8 +103,8 @@ widgets.getAreas = function(templates, locations, callback) {
|
||||
});
|
||||
};
|
||||
|
||||
widgets.getArea = function(template, location, callback) {
|
||||
db.getObjectField('widgets:' + template, location, function(err, result) {
|
||||
widgets.getArea = function (template, location, callback) {
|
||||
db.getObjectField('widgets:' + template, location, function (err, result) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
@@ -121,7 +121,7 @@ widgets.getArea = function(template, location, callback) {
|
||||
});
|
||||
};
|
||||
|
||||
widgets.setArea = function(area, callback) {
|
||||
widgets.setArea = function (area, callback) {
|
||||
if (!area.location || !area.template) {
|
||||
return callback(new Error('Missing location and template data'));
|
||||
}
|
||||
@@ -129,7 +129,7 @@ widgets.setArea = function(area, callback) {
|
||||
db.setObjectField('widgets:' + area.template, area.location, JSON.stringify(area.widgets), callback);
|
||||
};
|
||||
|
||||
widgets.reset = function(callback) {
|
||||
widgets.reset = function (callback) {
|
||||
var defaultAreas = [
|
||||
{ name: 'Draft Zone', template: 'global', location: 'header' },
|
||||
{ name: 'Draft Zone', template: 'global', location: 'footer' },
|
||||
@@ -137,21 +137,21 @@ widgets.reset = function(callback) {
|
||||
];
|
||||
|
||||
async.parallel({
|
||||
areas: function(next) {
|
||||
areas: function (next) {
|
||||
plugins.fireHook('filter:widgets.getAreas', defaultAreas, next);
|
||||
},
|
||||
drafts: function(next) {
|
||||
drafts: function (next) {
|
||||
widgets.getArea('global', 'drafts', next);
|
||||
}
|
||||
}, function(err, results) {
|
||||
}, function (err, results) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
var drafts = results.drafts || [];
|
||||
|
||||
async.each(results.areas, function(area, next) {
|
||||
widgets.getArea(area.template, area.location, function(err, areaData) {
|
||||
async.each(results.areas, function (area, next) {
|
||||
widgets.getArea(area.template, area.location, function (err, areaData) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
@@ -160,7 +160,7 @@ widgets.reset = function(callback) {
|
||||
area.widgets = [];
|
||||
widgets.setArea(area, next);
|
||||
});
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user