mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
@@ -11,11 +11,12 @@ var topics = require('../topics');
|
||||
var categories = require('../categories');
|
||||
var privileges = require('../privileges');
|
||||
var plugins = require('../plugins');
|
||||
var widgets = require('../widgets');
|
||||
var translator = require('../translator');
|
||||
|
||||
var apiController = module.exports;
|
||||
|
||||
apiController.loadConfig = function (req, callback) {
|
||||
apiController.getConfig = function (req, res, next) {
|
||||
var config = {};
|
||||
config.environment = process.env.NODE_ENV;
|
||||
config.relative_path = nconf.get('relative_path');
|
||||
@@ -58,7 +59,7 @@ apiController.loadConfig = function (req, callback) {
|
||||
config.requireEmailConfirmation = parseInt(meta.config.requireEmailConfirmation, 10) === 1;
|
||||
config.topicPostSort = meta.config.topicPostSort || 'oldest_to_newest';
|
||||
config.categoryTopicSort = meta.config.categoryTopicSort || 'newest_to_oldest';
|
||||
config.csrf_token = req.csrfToken && req.csrfToken();
|
||||
config.csrf_token = req.csrfToken();
|
||||
config.searchEnabled = plugins.hasListeners('filter:search.query');
|
||||
config.bootswatchSkin = meta.config.bootswatchSkin || 'noskin';
|
||||
config.defaultBootswatchSkin = meta.config.bootswatchSkin || 'noskin';
|
||||
@@ -79,7 +80,7 @@ apiController.loadConfig = function (req, callback) {
|
||||
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
if (!req.uid) {
|
||||
if (!req.user) {
|
||||
return next(null, config);
|
||||
}
|
||||
user.getSettings(req.uid, next);
|
||||
@@ -97,22 +98,41 @@ apiController.loadConfig = function (req, callback) {
|
||||
config.bootswatchSkin = (settings.bootswatchSkin && settings.bootswatchSkin !== 'default') ? settings.bootswatchSkin : config.bootswatchSkin;
|
||||
plugins.fireHook('filter:config.get', config, next);
|
||||
},
|
||||
], callback);
|
||||
], function (err, config) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
if (res.locals.isAPI) {
|
||||
res.json(config);
|
||||
} else {
|
||||
next(null, config);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
apiController.getConfig = function (req, res, next) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
apiController.loadConfig(req, next);
|
||||
|
||||
apiController.renderWidgets = function (req, res, next) {
|
||||
if (!req.query.template || !req.query.locations) {
|
||||
return res.status(200).json({});
|
||||
}
|
||||
|
||||
widgets.render(req.uid,
|
||||
{
|
||||
template: req.query.template,
|
||||
url: req.query.url,
|
||||
locations: req.query.locations,
|
||||
isMobile: req.query.isMobile === 'true',
|
||||
cid: req.query.cid,
|
||||
},
|
||||
function (config, next) {
|
||||
if (res.locals.isAPI) {
|
||||
res.json(config);
|
||||
} else {
|
||||
next(null, config);
|
||||
req,
|
||||
res,
|
||||
function (err, widgets) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
},
|
||||
], next);
|
||||
res.status(200).json(widgets);
|
||||
});
|
||||
};
|
||||
|
||||
apiController.getPostData = function (pid, uid, callback) {
|
||||
|
||||
Reference in New Issue
Block a user