mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-29 10:06:13 +01:00
get rid of app.exposeConfigToTemplates
This commit is contained in:
@@ -214,8 +214,10 @@ $(document).ready(function() {
|
|||||||
if (!data) {
|
if (!data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ajaxify.data = data;
|
ajaxify.data = data;
|
||||||
data.relative_path = RELATIVE_PATH;
|
data.config = config;
|
||||||
|
|
||||||
$(window).trigger('action:ajaxify.dataLoaded', {url: url, data: data});
|
$(window).trigger('action:ajaxify.dataLoaded', {url: url, data: data});
|
||||||
|
|
||||||
if (callback) {
|
if (callback) {
|
||||||
|
|||||||
@@ -406,18 +406,6 @@ app.cacheBuster = null;
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
app.exposeConfigToTemplates = function() {
|
|
||||||
$(document).ready(function() {
|
|
||||||
templates.setGlobal('loggedIn', config.loggedIn);
|
|
||||||
templates.setGlobal('relative_path', RELATIVE_PATH);
|
|
||||||
for(var key in config) {
|
|
||||||
if (config.hasOwnProperty(key)) {
|
|
||||||
templates.setGlobal('config.' + key, config[key]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
function createHeaderTooltips() {
|
function createHeaderTooltips() {
|
||||||
var env = utils.findBootstrapEnvironment();
|
var env = utils.findBootstrapEnvironment();
|
||||||
if (env === 'xs' || env === 'sm') {
|
if (env === 'xs' || env === 'sm') {
|
||||||
@@ -651,8 +639,6 @@ app.cacheBuster = null;
|
|||||||
|
|
||||||
showWelcomeMessage = window.location.href.indexOf('loggedin') !== -1;
|
showWelcomeMessage = window.location.href.indexOf('loggedin') !== -1;
|
||||||
|
|
||||||
app.exposeConfigToTemplates();
|
|
||||||
|
|
||||||
socketIOConnect();
|
socketIOConnect();
|
||||||
|
|
||||||
app.cacheBuster = config['cache-buster'];
|
app.cacheBuster = config['cache-buster'];
|
||||||
|
|||||||
@@ -70,8 +70,8 @@ apiController.getConfig = function(req, res, next) {
|
|||||||
config.environment = process.env.NODE_ENV;
|
config.environment = process.env.NODE_ENV;
|
||||||
config.loggedIn = !!req.user;
|
config.loggedIn = !!req.user;
|
||||||
config['cache-buster'] = meta.config['cache-buster'] || '';
|
config['cache-buster'] = meta.config['cache-buster'] || '';
|
||||||
config['script-buster'] = meta.js.hash;
|
config['script-buster'] = meta.js.hash || '';
|
||||||
config['css-buster'] = meta.css.hash;
|
config['css-buster'] = meta.css.hash || '';
|
||||||
config.requireEmailConfirmation = parseInt(meta.config.requireEmailConfirmation, 10) === 1;
|
config.requireEmailConfirmation = parseInt(meta.config.requireEmailConfirmation, 10) === 1;
|
||||||
config.topicPostSort = meta.config.topicPostSort || 'oldest_to_newest';
|
config.topicPostSort = meta.config.topicPostSort || 'oldest_to_newest';
|
||||||
config.categoryTopicSort = meta.config.categoryTopicSort || 'newest_to_oldest';
|
config.categoryTopicSort = meta.config.categoryTopicSort || 'newest_to_oldest';
|
||||||
|
|||||||
@@ -93,15 +93,16 @@ middleware.renderHeader = function(req, res, data, next) {
|
|||||||
res.locals.config = results.config;
|
res.locals.config = results.config;
|
||||||
|
|
||||||
var templateValues = {
|
var templateValues = {
|
||||||
relative_path: nconf.get('relative_path'),
|
config: results.config,
|
||||||
configJSON: JSON.stringify(results.config),
|
configJSON: JSON.stringify(results.config),
|
||||||
|
relative_path: results.config.relative_path,
|
||||||
user: userData,
|
user: userData,
|
||||||
userJSON: JSON.stringify(userData).replace(/'/g, "\\'"),
|
userJSON: JSON.stringify(userData).replace(/'/g, "\\'"),
|
||||||
plugins: results.custom_header.plugins,
|
plugins: results.custom_header.plugins,
|
||||||
authentication: results.custom_header.authentication,
|
authentication: results.custom_header.authentication,
|
||||||
scripts: results.scripts,
|
scripts: results.scripts,
|
||||||
'cache-buster': meta.config['cache-buster'] ? 'v=' + meta.config['cache-buster'] : '',
|
'cache-buster': meta.config['cache-buster'] ? 'v=' + meta.config['cache-buster'] : '',
|
||||||
env: process.env.NODE_ENV ? true : false,
|
env: process.env.NODE_ENV ? true : false
|
||||||
};
|
};
|
||||||
|
|
||||||
templateValues.template = {name: res.locals.template};
|
templateValues.template = {name: res.locals.template};
|
||||||
|
|||||||
@@ -214,15 +214,11 @@ middleware.renderHeader = function(req, res, data, callback) {
|
|||||||
'brand:logo:alt': meta.config['brand:logo:alt'] || '',
|
'brand:logo:alt': meta.config['brand:logo:alt'] || '',
|
||||||
'brand:logo:display': meta.config['brand:logo']?'':'hide',
|
'brand:logo:display': meta.config['brand:logo']?'':'hide',
|
||||||
allowRegistration: registrationType === 'normal' || registrationType === 'admin-approval',
|
allowRegistration: registrationType === 'normal' || registrationType === 'admin-approval',
|
||||||
searchEnabled: plugins.hasListeners('filter:search.query')
|
searchEnabled: plugins.hasListeners('filter:search.query'),
|
||||||
|
config: res.locals.config,
|
||||||
|
relative_path: res.locals.config.relative_path
|
||||||
};
|
};
|
||||||
|
|
||||||
for (var key in res.locals.config) {
|
|
||||||
if (res.locals.config.hasOwnProperty(key)) {
|
|
||||||
templateValues[key] = res.locals.config[key];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
templateValues.configJSON = JSON.stringify(res.locals.config);
|
templateValues.configJSON = JSON.stringify(res.locals.config);
|
||||||
|
|
||||||
async.parallel({
|
async.parallel({
|
||||||
@@ -337,6 +333,7 @@ middleware.processRender = function(req, res, next) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
options.loggedIn = req.user ? parseInt(req.user.uid, 10) !== 0 : false;
|
options.loggedIn = req.user ? parseInt(req.user.uid, 10) !== 0 : false;
|
||||||
|
options.relative_path = nconf.get('relative_path');
|
||||||
options.template = {name: template};
|
options.template = {name: template};
|
||||||
options.template[template] = true;
|
options.template[template] = true;
|
||||||
res.locals.template = template;
|
res.locals.template = template;
|
||||||
|
|||||||
Reference in New Issue
Block a user