Add req
to EJS render args when possible
This makes it possible for EJS templates and `eejsBlock_*` hook functions to access the user's express-session state.
This commit is contained in:
parent
cf43156390
commit
ed5a635f4c
4 changed files with 11 additions and 14 deletions
|
@ -3,7 +3,7 @@ var eejs = require('ep_etherpad-lite/node/eejs');
|
||||||
exports.expressCreateServer = function (hook_name, args, cb) {
|
exports.expressCreateServer = function (hook_name, args, cb) {
|
||||||
args.app.get('/admin', function(req, res) {
|
args.app.get('/admin', function(req, res) {
|
||||||
if('/' != req.path[req.path.length-1]) return res.redirect('./admin/');
|
if('/' != req.path[req.path.length-1]) return res.redirect('./admin/');
|
||||||
res.send( eejs.require("ep_etherpad-lite/templates/admin/index.html", {}) );
|
res.send(eejs.require('ep_etherpad-lite/templates/admin/index.html', {req}));
|
||||||
});
|
});
|
||||||
return cb();
|
return cb();
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,13 +8,12 @@ const UpdateCheck = require('ep_etherpad-lite/node/utils/UpdateCheck');
|
||||||
|
|
||||||
exports.expressCreateServer = function(hook_name, args, cb) {
|
exports.expressCreateServer = function(hook_name, args, cb) {
|
||||||
args.app.get('/admin/plugins', function(req, res) {
|
args.app.get('/admin/plugins', function(req, res) {
|
||||||
var render_args = {
|
res.send(eejs.require('ep_etherpad-lite/templates/admin/plugins.html', {
|
||||||
plugins: plugins.plugins,
|
plugins: plugins.plugins,
|
||||||
|
req,
|
||||||
search_results: {},
|
search_results: {},
|
||||||
errors: [],
|
errors: [],
|
||||||
};
|
}));
|
||||||
|
|
||||||
res.send(eejs.require("ep_etherpad-lite/templates/admin/plugins.html", render_args));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
args.app.get('/admin/plugins/info', function(req, res) {
|
args.app.get('/admin/plugins/info', function(req, res) {
|
||||||
|
@ -24,7 +23,8 @@ exports.expressCreateServer = function(hook_name, args, cb) {
|
||||||
res.send(eejs.require("ep_etherpad-lite/templates/admin/plugins-info.html", {
|
res.send(eejs.require("ep_etherpad-lite/templates/admin/plugins-info.html", {
|
||||||
gitCommit: gitCommit,
|
gitCommit: gitCommit,
|
||||||
epVersion: epVersion,
|
epVersion: epVersion,
|
||||||
latestVersion: UpdateCheck.getLatestVersion()
|
latestVersion: UpdateCheck.getLatestVersion(),
|
||||||
|
req,
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -5,15 +5,12 @@ var fs = require('fs');
|
||||||
|
|
||||||
exports.expressCreateServer = function (hook_name, args, cb) {
|
exports.expressCreateServer = function (hook_name, args, cb) {
|
||||||
args.app.get('/admin/settings', function(req, res) {
|
args.app.get('/admin/settings', function(req, res) {
|
||||||
|
res.send(eejs.require('ep_etherpad-lite/templates/admin/settings.html', {
|
||||||
var render_args = {
|
req,
|
||||||
settings: "",
|
settings: "",
|
||||||
search_results: {},
|
search_results: {},
|
||||||
errors: []
|
errors: []
|
||||||
};
|
}));
|
||||||
|
|
||||||
res.send( eejs.require("ep_etherpad-lite/templates/admin/settings.html", render_args) );
|
|
||||||
|
|
||||||
});
|
});
|
||||||
return cb();
|
return cb();
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,13 +14,13 @@ exports.expressCreateServer = function (hook_name, args, cb) {
|
||||||
//serve index.html under /
|
//serve index.html under /
|
||||||
args.app.get('/', function(req, res)
|
args.app.get('/', function(req, res)
|
||||||
{
|
{
|
||||||
res.send(eejs.require("ep_etherpad-lite/templates/index.html"));
|
res.send(eejs.require('ep_etherpad-lite/templates/index.html', {req}));
|
||||||
});
|
});
|
||||||
|
|
||||||
//serve javascript.html
|
//serve javascript.html
|
||||||
args.app.get('/javascript', function(req, res)
|
args.app.get('/javascript', function(req, res)
|
||||||
{
|
{
|
||||||
res.send(eejs.require("ep_etherpad-lite/templates/javascript.html"));
|
res.send(eejs.require('ep_etherpad-lite/templates/javascript.html'), {req});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue