mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-06 14:06:47 +02:00
Merge branch 'master' into develop
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
var appearanceController = {};
|
||||
|
||||
appearanceController.get = function (req, res, next) {
|
||||
appearanceController.get = function (req, res) {
|
||||
var term = req.params.term ? req.params.term : 'themes';
|
||||
|
||||
res.render('admin/appearance/' + term, {});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
var meta = require('../../meta');
|
||||
|
||||
@@ -11,7 +11,7 @@ blacklistController.get = function (req, res, next) {
|
||||
}
|
||||
res.render('admin/manage/ip-blacklist', {
|
||||
rules: rules,
|
||||
title: '[[pages:ip-blacklist]]'
|
||||
title: '[[pages:ip-blacklist]]',
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
var cacheController = {};
|
||||
|
||||
cacheController.get = function (req, res, next) {
|
||||
cacheController.get = function (req, res) {
|
||||
var postCache = require('../../posts/cache');
|
||||
var groupCache = require('../../groups').cache;
|
||||
|
||||
@@ -19,17 +19,17 @@ cacheController.get = function (req, res, next) {
|
||||
max: postCache.max,
|
||||
itemCount: postCache.itemCount,
|
||||
percentFull: percentFull,
|
||||
avgPostSize: avgPostSize
|
||||
avgPostSize: avgPostSize,
|
||||
},
|
||||
groupCache: {
|
||||
length: groupCache.length,
|
||||
max: groupCache.max,
|
||||
itemCount: groupCache.itemCount,
|
||||
percentFull: ((groupCache.length / groupCache.max) * 100).toFixed(2),
|
||||
dump: req.query.debug ? JSON.stringify(groupCache.dump(), null, 4) : false
|
||||
}
|
||||
dump: req.query.debug ? JSON.stringify(groupCache.dump(), null, 4) : false,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
module.exports = cacheController;
|
||||
module.exports = cacheController;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
var async = require('async');
|
||||
|
||||
@@ -14,7 +14,7 @@ var categoriesController = {};
|
||||
categoriesController.get = function (req, res, next) {
|
||||
async.parallel({
|
||||
category: async.apply(categories.getCategories, [req.params.category_id], req.user.uid),
|
||||
privileges: async.apply(privileges.categories.list, req.params.category_id)
|
||||
privileges: async.apply(privileges.categories.list, req.params.category_id),
|
||||
}, function (err, data) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
@@ -32,13 +32,13 @@ categoriesController.get = function (req, res, next) {
|
||||
data.category.name = translator.escape(String(data.category.name));
|
||||
res.render('admin/manage/category', {
|
||||
category: data.category,
|
||||
privileges: data.privileges
|
||||
privileges: data.privileges,
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
categoriesController.getAll = function (req, res, next) {
|
||||
categoriesController.getAll = function (req, res) {
|
||||
// Categories list will be rendered on client side with recursion, etc.
|
||||
res.render('admin/manage/categories', {});
|
||||
};
|
||||
@@ -46,7 +46,7 @@ categoriesController.getAll = function (req, res, next) {
|
||||
categoriesController.getAnalytics = function (req, res, next) {
|
||||
async.parallel({
|
||||
name: async.apply(categories.getCategoryField, req.params.category_id, 'name'),
|
||||
analytics: async.apply(analytics.getCategoryAnalytics, req.params.category_id)
|
||||
analytics: async.apply(analytics.getCategoryAnalytics, req.params.category_id),
|
||||
}, function (err, data) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
|
||||
@@ -20,26 +20,26 @@ dashboardController.get = function (req, res, next) {
|
||||
{
|
||||
done: !meta.reloadRequired,
|
||||
doneText: '[[admin/general/dashboard:restart-not-required]]',
|
||||
notDoneText:'[[admin/general/dashboard:restart-required]]'
|
||||
notDoneText: '[[admin/general/dashboard:restart-required]]',
|
||||
},
|
||||
{
|
||||
done: plugins.hasListeners('filter:search.query'),
|
||||
doneText: '[[admin/general/dashboard:search-plugin-installed]]',
|
||||
notDoneText:'[[admin/general/dashboard:search-plugin-not-installed]]',
|
||||
notDoneText: '[[admin/general/dashboard:search-plugin-not-installed]]',
|
||||
tooltip: '[[admin/general/dashboard:search-plugin-tooltip]]',
|
||||
link:'/admin/extend/plugins'
|
||||
}
|
||||
link: '/admin/extend/plugins',
|
||||
},
|
||||
];
|
||||
|
||||
if (global.env !== 'production') {
|
||||
notices.push({
|
||||
done: false,
|
||||
notDoneText: '[[admin/general/dashboard:running-in-development]]'
|
||||
notDoneText: '[[admin/general/dashboard:running-in-development]]',
|
||||
});
|
||||
}
|
||||
|
||||
plugins.fireHook('filter:admin.notices', notices, next);
|
||||
}
|
||||
},
|
||||
}, function (err, results) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
@@ -47,7 +47,7 @@ dashboardController.get = function (req, res, next) {
|
||||
res.render('admin/general/dashboard', {
|
||||
version: nconf.get('version'),
|
||||
notices: results.notices,
|
||||
stats: results.stats
|
||||
stats: results.stats,
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -65,7 +65,7 @@ function getStats(callback) {
|
||||
},
|
||||
function (next) {
|
||||
getStatsForSet('topics:tid', 'topicCount', next);
|
||||
}
|
||||
},
|
||||
], function (err, results) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
@@ -83,7 +83,7 @@ function getStatsForSet(set, field, callback) {
|
||||
var terms = {
|
||||
day: 86400000,
|
||||
week: 604800000,
|
||||
month: 2592000000
|
||||
month: 2592000000,
|
||||
};
|
||||
|
||||
var now = Date.now();
|
||||
@@ -99,7 +99,7 @@ function getStatsForSet(set, field, callback) {
|
||||
},
|
||||
alltime: function (next) {
|
||||
getGlobalField(field, next);
|
||||
}
|
||||
},
|
||||
}, callback);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ var nconf = require('nconf');
|
||||
var databaseController = {};
|
||||
|
||||
|
||||
|
||||
databaseController.get = function (req, res, next) {
|
||||
async.parallel({
|
||||
redis: function (next) {
|
||||
@@ -24,7 +23,7 @@ databaseController.get = function (req, res, next) {
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
}
|
||||
},
|
||||
}, function (err, results) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
@@ -33,4 +32,4 @@ databaseController.get = function (req, res, next) {
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = databaseController;
|
||||
module.exports = databaseController;
|
||||
|
||||
@@ -11,7 +11,7 @@ var errorsController = {};
|
||||
errorsController.get = function (req, res, next) {
|
||||
async.parallel({
|
||||
'not-found': async.apply(meta.errors.get, true),
|
||||
analytics: async.apply(analytics.getErrorAnalytics)
|
||||
analytics: async.apply(analytics.getErrorAnalytics),
|
||||
}, function (err, data) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
@@ -24,7 +24,7 @@ errorsController.get = function (req, res, next) {
|
||||
errorsController.export = function (req, res, next) {
|
||||
async.waterfall([
|
||||
async.apply(meta.errors.get, false),
|
||||
async.apply(json2csv)
|
||||
async.apply(json2csv),
|
||||
], function (err, csv) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
@@ -35,4 +35,4 @@ errorsController.export = function (req, res, next) {
|
||||
};
|
||||
|
||||
|
||||
module.exports = errorsController;
|
||||
module.exports = errorsController;
|
||||
|
||||
@@ -10,7 +10,6 @@ var eventsController = {};
|
||||
|
||||
|
||||
eventsController.get = function (req, res, next) {
|
||||
|
||||
var page = parseInt(req.query.page, 10) || 1;
|
||||
var itemsPerPage = 20;
|
||||
var start = (page - 1) * itemsPerPage;
|
||||
@@ -22,7 +21,7 @@ eventsController.get = function (req, res, next) {
|
||||
},
|
||||
events: function (next) {
|
||||
events.getEvents(start, stop, next);
|
||||
}
|
||||
},
|
||||
}, function (err, results) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
@@ -33,10 +32,10 @@ eventsController.get = function (req, res, next) {
|
||||
res.render('admin/advanced/events', {
|
||||
events: results.events,
|
||||
pagination: pagination.create(page, pageCount),
|
||||
next: 20
|
||||
next: 20,
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
module.exports = eventsController;
|
||||
module.exports = eventsController;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
var async = require('async');
|
||||
|
||||
@@ -6,12 +6,9 @@ var db = require('../../database');
|
||||
var groups = require('../../groups');
|
||||
var meta = require('../../meta');
|
||||
var pagination = require('../../pagination');
|
||||
var helpers = require('../helpers');
|
||||
|
||||
|
||||
var groupsController = {};
|
||||
|
||||
|
||||
groupsController.list = function (req, res, next) {
|
||||
var page = parseInt(req.query.page, 10) || 1;
|
||||
var groupsPerPage = 20;
|
||||
@@ -28,14 +25,14 @@ groupsController.list = function (req, res, next) {
|
||||
pageCount = Math.ceil(groupNames.length / groupsPerPage);
|
||||
|
||||
var start = (page - 1) * groupsPerPage;
|
||||
var stop = start + groupsPerPage - 1;
|
||||
var stop = start + groupsPerPage - 1;
|
||||
|
||||
groupNames = groupNames.slice(start, stop + 1);
|
||||
groups.getGroupsData(groupNames, next);
|
||||
},
|
||||
function (groupData, next) {
|
||||
next(null, {groups: groupData, pagination: pagination.create(page, pageCount)});
|
||||
}
|
||||
next(null, { groups: groupData, pagination: pagination.create(page, pageCount) });
|
||||
},
|
||||
], function (err, data) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
@@ -44,7 +41,7 @@ groupsController.list = function (req, res, next) {
|
||||
res.render('admin/manage/groups', {
|
||||
groups: data.groups,
|
||||
pagination: data.pagination,
|
||||
yourid: req.uid
|
||||
yourid: req.uid,
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -59,14 +56,14 @@ groupsController.get = function (req, res, callback) {
|
||||
if (!exists) {
|
||||
return callback();
|
||||
}
|
||||
groups.get(groupName, {uid: req.uid, truncateUserList: true, userListCount: 20}, next);
|
||||
}
|
||||
groups.get(groupName, { uid: req.uid, truncateUserList: true, userListCount: 20 }, next);
|
||||
},
|
||||
], function (err, group) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
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 });
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -25,37 +25,37 @@ homePageController.get = function (req, res, next) {
|
||||
categoryData = categoryData.map(function (category) {
|
||||
return {
|
||||
route: 'category/' + category.slug,
|
||||
name: 'Category: ' + category.name
|
||||
name: 'Category: ' + category.name,
|
||||
};
|
||||
});
|
||||
next(null, categoryData);
|
||||
}
|
||||
},
|
||||
], function (err, categoryData) {
|
||||
if (err || !categoryData) {
|
||||
categoryData = [];
|
||||
}
|
||||
|
||||
plugins.fireHook('filter:homepage.get', {routes: [
|
||||
plugins.fireHook('filter:homepage.get', { routes: [
|
||||
{
|
||||
route: 'categories',
|
||||
name: 'Categories'
|
||||
name: 'Categories',
|
||||
},
|
||||
{
|
||||
route: 'recent',
|
||||
name: 'Recent'
|
||||
name: 'Recent',
|
||||
},
|
||||
{
|
||||
route: 'popular',
|
||||
name: 'Popular'
|
||||
}
|
||||
].concat(categoryData)}, function (err, data) {
|
||||
name: 'Popular',
|
||||
},
|
||||
].concat(categoryData) }, function (err, data) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
data.routes.push({
|
||||
route: '',
|
||||
name: 'Custom'
|
||||
name: 'Custom',
|
||||
});
|
||||
|
||||
res.render('admin/general/homepage', data);
|
||||
@@ -63,4 +63,4 @@ homePageController.get = function (req, res, next) {
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = homePageController;
|
||||
module.exports = homePageController;
|
||||
|
||||
@@ -13,7 +13,7 @@ var infoController = {};
|
||||
|
||||
var info = {};
|
||||
|
||||
infoController.get = function (req, res, next) {
|
||||
infoController.get = function (req, res) {
|
||||
info = {};
|
||||
pubsub.publish('sync:node:info:start');
|
||||
setTimeout(function () {
|
||||
@@ -22,9 +22,15 @@ infoController.get = function (req, res, next) {
|
||||
data.push(info[key]);
|
||||
});
|
||||
data.sort(function (a, b) {
|
||||
return (a.os.hostname < b.os.hostname) ? -1 : (a.os.hostname > b.os.hostname) ? 1 : 0;
|
||||
if (a.os.hostname < b.os.hostname) {
|
||||
return -1;
|
||||
}
|
||||
if (a.os.hostname > b.os.hostname) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
res.render('admin/development/info', {info: data, infoJSON: JSON.stringify(data, null, 4), host: os.hostname(), port: nconf.get('port')});
|
||||
res.render('admin/development/info', { info: data, infoJSON: JSON.stringify(data, null, 4), host: os.hostname(), port: nconf.get('port') });
|
||||
}, 500);
|
||||
};
|
||||
|
||||
@@ -33,7 +39,7 @@ pubsub.on('sync:node:info:start', function () {
|
||||
if (err) {
|
||||
return winston.error(err);
|
||||
}
|
||||
pubsub.publish('sync:node:info:end', {data: data, id: os.hostname() + ':' + nconf.get('port')});
|
||||
pubsub.publish('sync:node:info:end', { data: data, id: os.hostname() + ':' + nconf.get('port') });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -49,7 +55,7 @@ function getNodeInfo(callback) {
|
||||
title: process.title,
|
||||
version: process.version,
|
||||
memoryUsage: process.memoryUsage(),
|
||||
uptime: process.uptime()
|
||||
uptime: process.uptime(),
|
||||
},
|
||||
os: {
|
||||
hostname: os.hostname(),
|
||||
@@ -57,8 +63,8 @@ function getNodeInfo(callback) {
|
||||
platform: os.platform(),
|
||||
arch: os.arch(),
|
||||
release: os.release(),
|
||||
load: os.loadavg().map(function (load) { return load.toFixed(2); }).join(', ')
|
||||
}
|
||||
load: os.loadavg().map(function (load) { return load.toFixed(2); }).join(', '),
|
||||
},
|
||||
};
|
||||
|
||||
async.parallel({
|
||||
@@ -67,7 +73,7 @@ function getNodeInfo(callback) {
|
||||
},
|
||||
gitInfo: function (next) {
|
||||
getGitInfo(next);
|
||||
}
|
||||
},
|
||||
}, function (err, results) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
@@ -79,7 +85,7 @@ function getNodeInfo(callback) {
|
||||
}
|
||||
|
||||
function getGitInfo(callback) {
|
||||
function get(cmd, callback) {
|
||||
function get(cmd, callback) {
|
||||
exec(cmd, function (err, stdout) {
|
||||
if (err) {
|
||||
winston.error(err);
|
||||
@@ -93,8 +99,8 @@ function getGitInfo(callback) {
|
||||
},
|
||||
branch: function (next) {
|
||||
get('git rev-parse --abbrev-ref HEAD', next);
|
||||
}
|
||||
},
|
||||
}, callback);
|
||||
}
|
||||
|
||||
module.exports = infoController;
|
||||
module.exports = infoController;
|
||||
|
||||
@@ -17,9 +17,9 @@ languagesController.get = function (req, res, next) {
|
||||
});
|
||||
|
||||
res.render('admin/general/languages', {
|
||||
languages: languages
|
||||
languages: languages,
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = languagesController;
|
||||
module.exports = languagesController;
|
||||
|
||||
@@ -6,4 +6,4 @@ loggerController.get = function (req, res) {
|
||||
res.render('admin/development/logger', {});
|
||||
};
|
||||
|
||||
module.exports = loggerController;
|
||||
module.exports = loggerController;
|
||||
|
||||
@@ -13,10 +13,10 @@ logsController.get = function (req, res, next) {
|
||||
}
|
||||
|
||||
res.render('admin/advanced/logs', {
|
||||
data: validator.escape(logs)
|
||||
data: validator.escape(logs),
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
module.exports = logsController;
|
||||
module.exports = logsController;
|
||||
|
||||
@@ -20,4 +20,4 @@ navigationController.get = function (req, res, next) {
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = navigationController;
|
||||
module.exports = navigationController;
|
||||
|
||||
@@ -24,22 +24,22 @@ pluginsController.get = function (req, res, next) {
|
||||
|
||||
next(null, plugins);
|
||||
});
|
||||
}
|
||||
},
|
||||
}, function (err, payload) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
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) {
|
||||
return plugin.installed;
|
||||
}),
|
||||
upgradeCount: payload.compatible.reduce(function (count, current) {
|
||||
if (current.installed && current.outdated) {
|
||||
++count;
|
||||
count += 1;
|
||||
}
|
||||
return count;
|
||||
}, 0),
|
||||
@@ -48,9 +48,9 @@ pluginsController.get = function (req, res, next) {
|
||||
}),
|
||||
incompatible: payload.all.filter(function (plugin) {
|
||||
return compatiblePkgNames.indexOf(plugin.name) === -1;
|
||||
})
|
||||
}),
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = pluginsController;
|
||||
module.exports = pluginsController;
|
||||
|
||||
@@ -13,5 +13,4 @@ rewardsController.get = function (req, res, next) {
|
||||
};
|
||||
|
||||
|
||||
|
||||
module.exports = rewardsController;
|
||||
module.exports = rewardsController;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -47,11 +47,11 @@ function renderEmail(req, res, next) {
|
||||
path: path,
|
||||
fullpath: email,
|
||||
text: text,
|
||||
original: original.toString()
|
||||
original: original.toString(),
|
||||
});
|
||||
});
|
||||
}, next);
|
||||
}
|
||||
},
|
||||
], function (err, emails) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
@@ -61,7 +61,7 @@ function renderEmail(req, res, next) {
|
||||
emails: emails,
|
||||
sendable: emails.filter(function (email) {
|
||||
return email.path.indexOf('_plaintext') === -1 && email.path.indexOf('partials') === -1;
|
||||
})
|
||||
}),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -12,9 +12,9 @@ socialController.get = function (req, res, next) {
|
||||
}
|
||||
|
||||
res.render('admin/general/social', {
|
||||
posts: posts
|
||||
posts: posts,
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = socialController;
|
||||
module.exports = socialController;
|
||||
|
||||
@@ -10,7 +10,7 @@ soundsController.get = function (req, res, next) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
|
||||
settings = settings || {};
|
||||
|
||||
var types = [
|
||||
@@ -44,4 +44,4 @@ soundsController.get = function (req, res, next) {
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = soundsController;
|
||||
module.exports = soundsController;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
var topics = require('../../topics');
|
||||
|
||||
@@ -10,7 +10,7 @@ tagsController.get = function (req, res, next) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
res.render('admin/manage/tags', {tags: tags});
|
||||
res.render('admin/manage/tags', { tags: tags });
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ themesController.get = function (req, res, next) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
var themeConfig = require(path.join(themeDir, 'theme.json')),
|
||||
screenshotPath = path.join(themeDir, themeConfig.screenshot);
|
||||
var themeConfig = require(path.join(themeDir, 'theme.json'));
|
||||
var screenshotPath = path.join(themeDir, themeConfig.screenshot);
|
||||
if (themeConfig.screenshot && file.existsSync(screenshotPath)) {
|
||||
res.sendFile(screenshotPath);
|
||||
} else {
|
||||
@@ -22,4 +22,4 @@ themesController.get = function (req, res, next) {
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = themesController;
|
||||
module.exports = themesController;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
@@ -31,7 +31,7 @@ uploadsController.uploadCategoryPicture = function (req, res, next) {
|
||||
}
|
||||
|
||||
if (validateUpload(req, res, next, uploadedFile, allowedImageTypes)) {
|
||||
var filename = 'category-' + params.cid + path.extname(uploadedFile.name);
|
||||
var filename = 'category-' + params.cid + path.extname(uploadedFile.name);
|
||||
uploadImage(filename, 'category', uploadedFile, req, res, next);
|
||||
}
|
||||
};
|
||||
@@ -51,15 +51,15 @@ uploadsController.uploadFavicon = function (req, res, next) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
res.json([{name: uploadedFile.name, url: image.url}]);
|
||||
res.json([{ name: uploadedFile.name, url: image.url }]);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
uploadsController.uploadTouchIcon = function (req, res, next) {
|
||||
var uploadedFile = req.files.files[0],
|
||||
allowedTypes = ['image/png'],
|
||||
sizes = [36, 48, 72, 96, 144, 192];
|
||||
var uploadedFile = req.files.files[0];
|
||||
var allowedTypes = ['image/png'];
|
||||
var sizes = [36, 48, 72, 96, 144, 192];
|
||||
|
||||
if (validateUpload(req, res, next, uploadedFile, allowedTypes)) {
|
||||
file.saveFileToLocal('touchicon-orig.png', 'system', uploadedFile.path, function (err, imageObj) {
|
||||
@@ -75,8 +75,8 @@ uploadsController.uploadTouchIcon = function (req, res, next) {
|
||||
path: path.join(nconf.get('upload_path'), 'system', 'touchicon-' + size + '.png'),
|
||||
extension: 'png',
|
||||
width: size,
|
||||
height: size
|
||||
})
|
||||
height: size,
|
||||
}),
|
||||
], next);
|
||||
}, function (err) {
|
||||
fs.unlink(uploadedFile.path, function (err) {
|
||||
@@ -89,7 +89,7 @@ uploadsController.uploadTouchIcon = function (req, res, next) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
res.json([{name: uploadedFile.name, url: imageObj.url}]);
|
||||
res.json([{ name: uploadedFile.name, url: imageObj.url }]);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -142,7 +142,7 @@ function validateUpload(req, res, next, uploadedFile, allowedTypes) {
|
||||
}
|
||||
});
|
||||
|
||||
res.json({error: '[[error:invalid-image-type, ' + allowedTypes.join(', ') + ']]'});
|
||||
res.json({ error: '[[error:invalid-image-type, ' + allowedTypes.join(', ') + ']]' });
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -160,11 +160,11 @@ function uploadImage(filename, folder, uploadedFile, req, res, next) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
res.json([{name: uploadedFile.name, url: image.url.startsWith('http') ? image.url : nconf.get('relative_path') + image.url}]);
|
||||
res.json([{ name: uploadedFile.name, url: image.url.startsWith('http') ? image.url : nconf.get('relative_path') + image.url }]);
|
||||
}
|
||||
|
||||
if (plugins.hasListeners('filter:uploadImage')) {
|
||||
plugins.fireHook('filter:uploadImage', {image: uploadedFile, uid: req.user.uid}, done);
|
||||
plugins.fireHook('filter:uploadImage', { image: uploadedFile, uid: req.user.uid }, done);
|
||||
} else {
|
||||
file.saveFileToLocal(filename, folder, uploadedFile.path, done);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
var async = require('async');
|
||||
var validator = require('validator');
|
||||
@@ -15,10 +15,10 @@ var usersController = {};
|
||||
var userFields = ['uid', 'username', 'userslug', 'email', 'postcount', 'joindate', 'banned',
|
||||
'reputation', 'picture', 'flags', 'lastonline', 'email:confirmed'];
|
||||
|
||||
usersController.search = function (req, res, next) {
|
||||
usersController.search = function (req, res) {
|
||||
res.render('admin/manage/users', {
|
||||
search_display: '',
|
||||
users: []
|
||||
users: [],
|
||||
});
|
||||
};
|
||||
|
||||
@@ -71,7 +71,7 @@ usersController.registrationQueue = function (req, res, next) {
|
||||
user.getRegistrationQueue(start, stop, next);
|
||||
},
|
||||
customHeaders: function (next) {
|
||||
plugins.fireHook('filter:admin.registrationQueue.customHeaders', {headers: []}, next);
|
||||
plugins.fireHook('filter:admin.registrationQueue.customHeaders', { headers: [] }, next);
|
||||
},
|
||||
invites: function (next) {
|
||||
async.waterfall([
|
||||
@@ -97,14 +97,14 @@ usersController.registrationQueue = function (req, res, next) {
|
||||
invites.invitations = invites.invitations.map(function (email, i) {
|
||||
return {
|
||||
email: email,
|
||||
username: usernames[index][i] === '[[global:guest]]' ? '' : usernames[index][i]
|
||||
username: usernames[index][i] === '[[global:guest]]' ? '' : usernames[index][i],
|
||||
};
|
||||
});
|
||||
});
|
||||
next(null, invitations);
|
||||
}
|
||||
},
|
||||
], next);
|
||||
}
|
||||
},
|
||||
}, function (err, data) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
@@ -146,9 +146,9 @@ function getUsers(set, section, min, max, req, res, next) {
|
||||
},
|
||||
function (uids, next) {
|
||||
user.getUsersWithFields(uids, userFields, req.uid, next);
|
||||
}
|
||||
},
|
||||
], next);
|
||||
}
|
||||
},
|
||||
}, function (err, results) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
@@ -161,7 +161,7 @@ function getUsers(set, section, min, max, req, res, next) {
|
||||
var data = {
|
||||
users: results.users,
|
||||
page: page,
|
||||
pageCount: Math.max(1, Math.ceil(results.count / resultsPerPage))
|
||||
pageCount: Math.max(1, Math.ceil(results.count / resultsPerPage)),
|
||||
};
|
||||
data[section] = true;
|
||||
render(req, res, data);
|
||||
@@ -185,7 +185,7 @@ usersController.getCSV = function (req, res, next) {
|
||||
events.log({
|
||||
type: 'getUsersCSV',
|
||||
uid: req.user.uid,
|
||||
ip: req.ip
|
||||
ip: req.ip,
|
||||
});
|
||||
|
||||
user.getUsersCSV(function (err, data) {
|
||||
|
||||
@@ -13,4 +13,4 @@ widgetsController.get = function (req, res, next) {
|
||||
};
|
||||
|
||||
|
||||
module.exports = widgetsController;
|
||||
module.exports = widgetsController;
|
||||
|
||||
Reference in New Issue
Block a user