|
|
@ -18,10 +18,17 @@ var user = require('./../user.js'),
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Admin.build_header = function (res) {
|
|
|
|
Admin.build_header = function (res, callback) {
|
|
|
|
return templates['admin/header'].parse({
|
|
|
|
var custom_header = {
|
|
|
|
csrf: res.locals.csrf_token,
|
|
|
|
'plugins': []
|
|
|
|
relative_path: nconf.get('relative_path')
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plugins.fireHook('filter:admin.header.build', custom_header, function(err, custom_header) {
|
|
|
|
|
|
|
|
callback(err, templates['admin/header'].parse({
|
|
|
|
|
|
|
|
csrf: res.locals.csrf_token,
|
|
|
|
|
|
|
|
relative_path: nconf.get('relative_path'),
|
|
|
|
|
|
|
|
plugins: custom_header.plugins
|
|
|
|
|
|
|
|
}));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -38,7 +45,9 @@ var user = require('./../user.js'),
|
|
|
|
for (var i = 0, ii = routes.length; i < ii; i++) {
|
|
|
|
for (var i = 0, ii = routes.length; i < ii; i++) {
|
|
|
|
(function (route) {
|
|
|
|
(function (route) {
|
|
|
|
app.get('/admin/' + route, Admin.isAdmin, function (req, res) {
|
|
|
|
app.get('/admin/' + route, Admin.isAdmin, function (req, res) {
|
|
|
|
res.send(Admin.build_header(res) + app.create_route('admin/' + route) + templates['admin/footer']);
|
|
|
|
Admin.build_header(res, function(err, header) {
|
|
|
|
|
|
|
|
res.send(header + app.create_route('admin/' + route) + templates['admin/footer']);
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}(routes[i]));
|
|
|
|
}(routes[i]));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -48,7 +57,9 @@ var user = require('./../user.js'),
|
|
|
|
for (var i = 0, ii = unit_tests.length; i < ii; i++) {
|
|
|
|
for (var i = 0, ii = unit_tests.length; i < ii; i++) {
|
|
|
|
(function (route) {
|
|
|
|
(function (route) {
|
|
|
|
app.get('/admin/testing/' + route, Admin.isAdmin, function (req, res) {
|
|
|
|
app.get('/admin/testing/' + route, Admin.isAdmin, function (req, res) {
|
|
|
|
res.send(Admin.build_header(res) + app.create_route('admin/testing/' + route) + templates['admin/footer']);
|
|
|
|
Admin.build_header(res, function(err, header) {
|
|
|
|
|
|
|
|
res.send(header + app.create_route('admin/testing/' + route) + templates['admin/footer']);
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}(unit_tests[i]));
|
|
|
|
}(unit_tests[i]));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -57,14 +68,42 @@ var user = require('./../user.js'),
|
|
|
|
|
|
|
|
|
|
|
|
app.namespace('/admin', function () {
|
|
|
|
app.namespace('/admin', function () {
|
|
|
|
app.get('/', Admin.isAdmin, function (req, res) {
|
|
|
|
app.get('/', Admin.isAdmin, function (req, res) {
|
|
|
|
res.send(Admin.build_header(res) + app.create_route('admin/index') + templates['admin/footer']);
|
|
|
|
Admin.build_header(res, function(err, header) {
|
|
|
|
|
|
|
|
res.send(header + app.create_route('admin/index') + templates['admin/footer']);
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
app.get('/index', Admin.isAdmin, function (req, res) {
|
|
|
|
app.get('/index', Admin.isAdmin, function (req, res) {
|
|
|
|
res.send(Admin.build_header(res) + app.create_route('admin/index') + templates['admin/footer']);
|
|
|
|
Admin.build_header(res, function(err, header) {
|
|
|
|
|
|
|
|
res.send(header + app.create_route('admin/index') + templates['admin/footer']);
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var custom_routes = {
|
|
|
|
|
|
|
|
'routes': [],
|
|
|
|
|
|
|
|
'api_methods': []
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plugins.ready(function() {
|
|
|
|
|
|
|
|
plugins.fireHook('filter:admin.create_routes', custom_routes, function(err, custom_routes) {
|
|
|
|
|
|
|
|
var routes = custom_routes.routes;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (var route in routes) {
|
|
|
|
|
|
|
|
if (routes.hasOwnProperty(route)) {
|
|
|
|
|
|
|
|
app[routes[route].method || 'get']('/admin' + routes[route].route, function(req, res) {
|
|
|
|
|
|
|
|
routes[route].options(req, res, function(options) {
|
|
|
|
|
|
|
|
Admin.build_header(res, function (err, header) {
|
|
|
|
|
|
|
|
res.send(header + options.content + templates['admin/footer']);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
app.namespace('/api/admin', function () {
|
|
|
|
app.namespace('/api/admin', function () {
|
|
|
|
app.get('/index', function (req, res) {
|
|
|
|
app.get('/index', function (req, res) {
|
|
|
|
res.json({
|
|
|
|
res.json({
|
|
|
|