style changes

v1.18.x
Barış Soner Uşaklı 8 years ago
parent 78005d6124
commit 0f234601f1

@ -1,12 +1,9 @@
'use strict';
var appearanceController = {};
var appearanceController = module.exports;
appearanceController.get = function (req, res) {
var term = req.params.term ? req.params.term : 'themes';
res.render('admin/appearance/' + term, {});
};
module.exports = appearanceController;

@ -1,6 +1,6 @@
'use strict';
var cacheController = {};
var cacheController = module.exports;
cacheController.get = function (req, res) {
var postCache = require('../../posts/cache');
@ -37,6 +37,3 @@ cacheController.get = function (req, res) {
},
});
};
module.exports = cacheController;

@ -7,10 +7,11 @@ var db = require('../../database');
var meta = require('../../meta');
var plugins = require('../../plugins');
var dashboardController = {};
var dashboardController = module.exports;
dashboardController.get = function (req, res, next) {
async.waterfall([
function (next) {
async.parallel({
stats: function (next) {
getStats(next);
@ -40,19 +41,21 @@ dashboardController.get = function (req, res, next) {
plugins.fireHook('filter:admin.notices', notices, next);
},
}, function (err, results) {
if (err) {
return next(err);
}
}, next);
},
function (results) {
res.render('admin/general/dashboard', {
version: nconf.get('version'),
notices: results.notices,
stats: results.stats,
});
});
},
], next);
};
function getStats(callback) {
async.waterfall([
function (next) {
async.parallel([
function (next) {
getStatsForSet('ip:recent', 'uniqueIPCount', next);
@ -66,17 +69,17 @@ function getStats(callback) {
function (next) {
getStatsForSet('topics:tid', 'topicCount', next);
},
], function (err, results) {
if (err) {
return callback(err);
}
], next);
},
function (results, next) {
results[0].name = '[[admin/general/dashboard:unique-visitors]]';
results[1].name = '[[admin/general/dashboard:users]]';
results[2].name = '[[admin/general/dashboard:posts]]';
results[3].name = '[[admin/general/dashboard:topics]]';
callback(null, results);
});
next(null, results);
},
], callback);
}
function getStatsForSet(set, field, callback) {
@ -108,5 +111,3 @@ function getGlobalField(field, callback) {
callback(err, parseInt(count, 10) || 0);
});
}
module.exports = dashboardController;

@ -3,10 +3,11 @@
var async = require('async');
var nconf = require('nconf');
var databaseController = {};
var databaseController = module.exports;
databaseController.get = function (req, res, next) {
async.waterfall([
function (next) {
async.parallel({
redis: function (next) {
if (nconf.get('redis')) {
@ -24,12 +25,10 @@ databaseController.get = function (req, res, next) {
next();
}
},
}, function (err, results) {
if (err) {
return next(err);
}
}, next);
},
function (results) {
res.render('admin/advanced/database', results);
});
},
], next);
};
module.exports = databaseController;

@ -6,33 +6,28 @@ var json2csv = require('json-2-csv').json2csv;
var meta = require('../../meta');
var analytics = require('../../analytics');
var errorsController = {};
var errorsController = module.exports;
errorsController.get = function (req, res, next) {
async.waterfall([
function (next) {
async.parallel({
'not-found': async.apply(meta.errors.get, true),
analytics: async.apply(analytics.getErrorAnalytics),
}, function (err, data) {
if (err) {
return next(err);
}
}, next);
},
function (data) {
res.render('admin/advanced/errors', data);
});
},
], next);
};
errorsController.export = function (req, res, next) {
async.waterfall([
async.apply(meta.errors.get, false),
async.apply(json2csv),
], function (err, csv) {
if (err) {
return next(err);
}
function (csv) {
res.set('Content-Type', 'text/csv').set('Content-Disposition', 'attachment; filename="404.csv"').send(csv);
});
},
], next);
};
module.exports = errorsController;

@ -6,8 +6,7 @@ var db = require('../../database');
var events = require('../../events');
var pagination = require('../../pagination');
var eventsController = {};
var eventsController = module.exports;
eventsController.get = function (req, res, next) {
var page = parseInt(req.query.page, 10) || 1;
@ -15,6 +14,8 @@ eventsController.get = function (req, res, next) {
var start = (page - 1) * itemsPerPage;
var stop = start + itemsPerPage - 1;
async.waterfall([
function (next) {
async.parallel({
eventCount: function (next) {
db.sortedSetCard('events:time', next);
@ -22,11 +23,9 @@ eventsController.get = function (req, res, next) {
events: function (next) {
events.getEvents(start, stop, next);
},
}, function (err, results) {
if (err) {
return next(err);
}
}, next);
},
function (results) {
var pageCount = Math.max(1, Math.ceil(results.eventCount / itemsPerPage));
res.render('admin/advanced/events', {
@ -34,8 +33,7 @@ eventsController.get = function (req, res, next) {
pagination: pagination.create(page, pageCount),
next: 20,
});
});
},
], next);
};
module.exports = eventsController;

@ -7,7 +7,7 @@ var groups = require('../../groups');
var meta = require('../../meta');
var pagination = require('../../pagination');
var groupsController = {};
var groupsController = module.exports;
groupsController.list = function (req, res, next) {
var page = parseInt(req.query.page, 10) || 1;
@ -30,20 +30,14 @@ groupsController.list = function (req, res, next) {
groupNames = groupNames.slice(start, stop + 1);
groups.getGroupsData(groupNames, next);
},
function (groupData, next) {
next(null, { groups: groupData, pagination: pagination.create(page, pageCount) });
},
], function (err, data) {
if (err) {
return next(err);
}
function (groupData) {
res.render('admin/manage/groups', {
groups: data.groups,
pagination: data.pagination,
groups: groupData,
pagination: pagination.create(page, pageCount),
yourid: req.uid,
});
});
},
], next);
};
groupsController.get = function (req, res, callback) {
@ -58,13 +52,12 @@ groupsController.get = function (req, res, callback) {
}
groups.get(groupName, { uid: req.uid, truncateUserList: true, userListCount: 20 }, next);
},
], function (err, group) {
if (err) {
return callback(err);
}
function (group) {
group.isOwner = true;
res.render('admin/manage/group', { group: group, allowPrivateGroups: parseInt(meta.config.allowPrivateGroups, 10) === 1 });
res.render('admin/manage/group', {
group: group,
allowPrivateGroups: parseInt(meta.config.allowPrivateGroups, 10) === 1,
});
},
], callback);
};
module.exports = groupsController;

@ -7,8 +7,7 @@ var categories = require('../../categories');
var privileges = require('../../privileges');
var plugins = require('../../plugins');
var homePageController = {};
var homePageController = module.exports;
homePageController.get = function (req, res, next) {
async.waterfall([
@ -28,12 +27,6 @@ homePageController.get = function (req, res, next) {
name: 'Category: ' + category.name,
};
});
next(null, categoryData);
},
], function (err, categoryData) {
if (err || !categoryData) {
categoryData = [];
}
plugins.fireHook('filter:homepage.get', { routes: [
{
@ -48,19 +41,15 @@ homePageController.get = function (req, res, next) {
route: 'popular',
name: 'Popular',
},
].concat(categoryData) }, function (err, data) {
if (err) {
return next(err);
}
].concat(categoryData) }, next);
},
function (data) {
data.routes.push({
route: '',
name: 'Custom',
});
res.render('admin/general/homepage', data);
});
});
},
], next);
};
module.exports = homePageController;

@ -1,17 +1,18 @@
'use strict';
var async = require('async');
var languages = require('../../languages');
var meta = require('../../meta');
var languagesController = {};
var languagesController = module.exports;
languagesController.get = function (req, res, next) {
languages.list(function (err, languages) {
if (err) {
return next(err);
}
async.waterfall([
function (next) {
languages.list(next);
},
function (languages) {
languages.forEach(function (language) {
language.selected = language.code === (meta.config.defaultLang || 'en-GB');
});
@ -20,7 +21,7 @@ languagesController.get = function (req, res, next) {
languages: languages,
autoDetectLang: parseInt(meta.config.autoDetectLang, 10) === 1,
});
});
},
], next);
};
module.exports = languagesController;

@ -1,9 +1,7 @@
'use strict';
var loggerController = {};
var loggerController = module.exports;
loggerController.get = function (req, res) {
res.render('admin/development/logger', {});
};
module.exports = loggerController;

@ -1,21 +1,23 @@
'use strict';
var async = require('async');
var validator = require('validator');
var meta = require('../../meta');
var meta = require('../../meta');
var logsController = {};
var logsController = module.exports;
logsController.get = function (req, res, next) {
meta.logs.get(function (err, logs) {
if (err) {
return next(err);
}
async.waterfall([
function (next) {
meta.logs.get(next);
},
function (logs) {
res.render('admin/advanced/logs', {
data: validator.escape(logs),
});
});
},
], next);
};

@ -3,9 +3,11 @@
var async = require('async');
var plugins = require('../../plugins');
var pluginsController = {};
var pluginsController = module.exports;
pluginsController.get = function (req, res, next) {
async.waterfall([
function (next) {
async.parallel({
compatible: function (next) {
plugins.list(function (err, plugins) {
@ -25,10 +27,9 @@ pluginsController.get = function (req, res, next) {
next(null, plugins);
});
},
}, function (err, payload) {
if (err) {
return next(err);
}
}, next);
},
function (payload) {
var compatiblePkgNames = payload.compatible.map(function (pkgData) {
return pkgData.name;
});
@ -50,7 +51,6 @@ pluginsController.get = function (req, res, next) {
return compatiblePkgNames.indexOf(plugin.name) === -1;
}),
});
});
},
], next);
};
module.exports = pluginsController;

@ -1,15 +1,18 @@
'use strict';
var rewardsController = {};
var async = require('async');
rewardsController.get = function (req, res, next) {
require('../../rewards/admin').get(function (err, data) {
if (err) {
return next(err);
}
var rewardsController = module.exports;
rewardsController.get = function (req, res, next) {
async.waterfall([
function (next) {
require('../../rewards/admin').get(next);
},
function (data) {
res.render('admin/extend/rewards', data);
});
},
], next);
};

@ -36,11 +36,11 @@ function renderEmail(req, res, next) {
async.map(emails, function (email, next) {
var path = email.replace(emailsPath, '').substr(1).replace('.tpl', '');
fs.readFile(email, function (err, original) {
if (err) {
return next(err);
}
async.waterfall([
function (next) {
fs.readFile(email, next);
},
function (original, next) {
var text = meta.config['email:custom:' + path] ? meta.config['email:custom:' + path] : original.toString();
next(null, {
@ -49,19 +49,17 @@ function renderEmail(req, res, next) {
text: text,
original: original.toString(),
});
});
},
], next);
}, next);
},
], function (err, emails) {
if (err) {
return next(err);
}
function (emails) {
res.render('admin/settings/email', {
emails: emails,
sendable: emails.filter(function (email) {
return email.path.indexOf('_plaintext') === -1 && email.path.indexOf('partials') === -1;
}),
});
});
},
], next);
}

@ -1,9 +1,11 @@
'use strict';
var async = require('async');
var plugins = require('../../plugins');
var meta = require('../../meta');
var soundsController = {};
var soundsController = module.exports;
soundsController.get = function (req, res, next) {
var types = [
@ -11,11 +13,11 @@ soundsController.get = function (req, res, next) {
'chat-incoming',
'chat-outgoing',
];
meta.configs.getFields(types, function (err, settings) {
if (err) {
return next(err);
}
async.waterfall([
function (next) {
meta.configs.getFields(types, next);
},
function (settings) {
settings = settings || {};
var output = {};
@ -41,7 +43,6 @@ soundsController.get = function (req, res, next) {
});
res.render('admin/general/sounds', output);
});
},
], next);
};
module.exports = soundsController;

@ -1,18 +1,18 @@
'use strict';
var async = require('async');
var topics = require('../../topics');
var tagsController = {};
var tagsController = module.exports;
tagsController.get = function (req, res, next) {
topics.getTags(0, 199, function (err, tags) {
if (err) {
return next(err);
}
async.waterfall([
function (next) {
topics.getTags(0, 199, next);
},
function (tags) {
res.render('admin/manage/tags', { tags: tags });
});
},
], next);
};
module.exports = tagsController;

@ -6,28 +6,23 @@ var async = require('async');
var file = require('../../file');
var themesController = {};
var themesController = module.exports;
var defaultScreenshotPath = path.join(__dirname, '../../../public/images/themes/default.png');
themesController.get = function (req, res, next) {
var themeDir = path.join(__dirname, '../../../node_modules', req.params.theme);
var themeConfigPath = path.join(themeDir, 'theme.json');
var screenshotPath;
async.waterfall([
function (next) {
file.exists(themeConfigPath, function (err, exists) {
if (err) {
return next(err);
}
file.exists(themeConfigPath, next);
},
function (exists, next) {
if (!exists) {
return next(Error('invalid-data'));
}
next();
});
},
function (next) {
fs.readFile(themeConfigPath, next);
},
function (themeConfig, next) {
@ -38,16 +33,13 @@ themesController.get = function (req, res, next) {
next(e);
}
},
function (screenshotPath, next) {
file.exists(screenshotPath, function (err, exists) {
if (err) {
return next(err);
}
function (_screenshotPath, next) {
screenshotPath = _screenshotPath;
file.exists(screenshotPath, next);
},
function (exists) {
res.sendFile(exists ? screenshotPath : defaultScreenshotPath);
});
},
], next);
};
module.exports = themesController;

@ -10,7 +10,7 @@ var pagination = require('../../pagination');
var events = require('../../events');
var plugins = require('../../plugins');
var usersController = {};
var usersController = module.exports;
var userFields = ['uid', 'username', 'userslug', 'email', 'postcount', 'joindate', 'banned',
'reputation', 'picture', 'flags', 'lastonline', 'email:confirmed'];
@ -63,6 +63,8 @@ usersController.registrationQueue = function (req, res, next) {
var stop = start + itemsPerPage - 1;
var invitations;
async.waterfall([
function (next) {
async.parallel({
registrationQueueCount: function (next) {
db.sortedSetCard('registration:queue', next);
@ -105,15 +107,15 @@ usersController.registrationQueue = function (req, res, next) {
},
], next);
},
}, function (err, data) {
if (err) {
return next(err);
}
}, next);
},
function (data) {
var pageCount = Math.max(1, Math.ceil(data.registrationQueueCount / itemsPerPage));
data.pagination = pagination.create(page, pageCount);
data.customHeaders = data.customHeaders.headers;
res.render('admin/manage/registration', data);
});
},
], next);
};
function getUsers(set, section, min, max, req, res, next) {
@ -123,6 +125,8 @@ function getUsers(set, section, min, max, req, res, next) {
var stop = start + resultsPerPage - 1;
var byScore = min !== undefined && max !== undefined;
async.waterfall([
function (next) {
async.parallel({
count: function (next) {
if (byScore) {
@ -147,11 +151,9 @@ function getUsers(set, section, min, max, req, res, next) {
},
], next);
},
}, function (err, results) {
if (err) {
return next(err);
}
}, next);
},
function (results) {
results.users = results.users.filter(function (user) {
user.email = validator.escape(String(user.email || ''));
return user && parseInt(user.uid, 10);
@ -163,7 +165,8 @@ function getUsers(set, section, min, max, req, res, next) {
};
data[section] = true;
render(req, res, data);
});
},
], next);
}
function render(req, res, data) {
@ -185,15 +188,14 @@ usersController.getCSV = function (req, res, next) {
uid: req.user.uid,
ip: req.ip,
});
user.getUsersCSV(function (err, data) {
if (err) {
return next(err);
}
async.waterfall([
function (next) {
user.getUsersCSV(next);
},
function (data) {
res.attachment('users.csv');
res.setHeader('Content-Type', 'text/csv');
res.end(data);
});
},
], next);
};
module.exports = usersController;

@ -1,16 +1,16 @@
'use strict';
var widgetsController = {};
var async = require('async');
widgetsController.get = function (req, res, next) {
require('../../widgets/admin').get(function (err, data) {
if (err) {
return next(err);
}
var widgetsController = module.exports;
widgetsController.get = function (req, res, next) {
async.waterfall([
function (next) {
require('../../widgets/admin').get(next);
},
function (data) {
res.render('admin/extend/widgets', data);
});
},
], next);
};
module.exports = widgetsController;

@ -150,6 +150,9 @@ topicsController.get = function (req, res, callback) {
if (req.uid) {
topicData.rssFeedUrl += '?uid=' + req.uid + '&token=' + rssToken;
}
addTags(topicData, req, res);
topicData.postIndex = req.params.post_index;
topicData.pagination = pagination.create(currentPage, pageCount, req.query);
topicData.pagination.rel.forEach(function (rel) {
@ -163,8 +166,6 @@ topicsController.get = function (req, res, callback) {
req.session.tids_viewed[tid] = Date.now();
}
addTags(topicData, req, res);
if (req.uid) {
topics.markAsRead([tid], req.uid, function (err, markedRead) {
if (err) {

Loading…
Cancel
Save