|
|
@ -3,8 +3,14 @@
|
|
|
|
var app,
|
|
|
|
var app,
|
|
|
|
middleware = {},
|
|
|
|
middleware = {},
|
|
|
|
nconf = require('nconf'),
|
|
|
|
nconf = require('nconf'),
|
|
|
|
|
|
|
|
async = require('async'),
|
|
|
|
user = require('./../user'),
|
|
|
|
user = require('./../user'),
|
|
|
|
plugins = require('./../plugins');
|
|
|
|
meta = require('./../meta'),
|
|
|
|
|
|
|
|
plugins = require('./../plugins'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
controllers = {
|
|
|
|
|
|
|
|
api: require('./../controllers/api')
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
middleware.isAdmin = function (req, res, next) {
|
|
|
|
middleware.isAdmin = function (req, res, next) {
|
|
|
@ -18,7 +24,9 @@ middleware.isAdmin = function (req, res, next) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
middleware.buildHeader = function (req, res, callback) {
|
|
|
|
middleware.buildHeader = function(req, res, next) {
|
|
|
|
|
|
|
|
async.parallel([
|
|
|
|
|
|
|
|
function(next) {
|
|
|
|
var custom_header = {
|
|
|
|
var custom_header = {
|
|
|
|
'plugins': [],
|
|
|
|
'plugins': [],
|
|
|
|
'authentication': []
|
|
|
|
'authentication': []
|
|
|
@ -26,7 +34,7 @@ middleware.buildHeader = function (req, res, callback) {
|
|
|
|
|
|
|
|
|
|
|
|
user.getUserFields(req.user.uid, ['username', 'userslug', 'picture'], function(err, userData) {
|
|
|
|
user.getUserFields(req.user.uid, ['username', 'userslug', 'picture'], function(err, userData) {
|
|
|
|
plugins.fireHook('filter:admin.header.build', custom_header, function(err, custom_header) {
|
|
|
|
plugins.fireHook('filter:admin.header.build', custom_header, function(err, custom_header) {
|
|
|
|
callback(err, templates['admin/header'].parse({
|
|
|
|
var data = {
|
|
|
|
csrf: res.locals.csrf_token,
|
|
|
|
csrf: res.locals.csrf_token,
|
|
|
|
relative_path: nconf.get('relative_path'),
|
|
|
|
relative_path: nconf.get('relative_path'),
|
|
|
|
plugins: custom_header.plugins,
|
|
|
|
plugins: custom_header.plugins,
|
|
|
@ -36,9 +44,30 @@ middleware.buildHeader = function (req, res, callback) {
|
|
|
|
userslug: userData.userslug,
|
|
|
|
userslug: userData.userslug,
|
|
|
|
'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
|
|
|
|
}));
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.render('admin/header', data, function(err, template) {
|
|
|
|
|
|
|
|
res.locals.adminHeader = template;
|
|
|
|
|
|
|
|
next(err);
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
function(next) {
|
|
|
|
|
|
|
|
controllers.api.getConfig(req, res, function(err, config) {
|
|
|
|
|
|
|
|
res.locals.config = config;
|
|
|
|
|
|
|
|
next(err);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
function(next) {
|
|
|
|
|
|
|
|
app.render('footer', {}, function(err, template) {
|
|
|
|
|
|
|
|
res.locals.adminFooter = template;
|
|
|
|
|
|
|
|
next(err);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
], function(err) {
|
|
|
|
|
|
|
|
next();
|
|
|
|
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|