luci-base, luci-lua-runtime: fix "dispatched" and "requested" properties
Ensure to properly emulate the "dispatched" and "requested" properties which refer to the executed and initially resolved menu node respectivey. Also stop exposing a `node` property in Lua context to maintain full compatibility with the old Lua runtime. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
parent
c4d86c9f67
commit
08ae8d40a9
2 changed files with 3 additions and 4 deletions
|
@ -856,7 +856,7 @@ dispatch = function(_http, path) {
|
||||||
let version = determine_version();
|
let version = determine_version();
|
||||||
let lang = determine_request_language();
|
let lang = determine_request_language();
|
||||||
|
|
||||||
runtime = LuCIRuntime({
|
runtime = runtime || LuCIRuntime({
|
||||||
http,
|
http,
|
||||||
ubus,
|
ubus,
|
||||||
uci,
|
uci,
|
||||||
|
@ -892,7 +892,8 @@ dispatch = function(_http, path) {
|
||||||
let resolved = resolve_page(menu, path);
|
let resolved = resolve_page(menu, path);
|
||||||
|
|
||||||
runtime.env.ctx = resolved.ctx;
|
runtime.env.ctx = resolved.ctx;
|
||||||
runtime.env.node = resolved.node;
|
runtime.env.dispatched = resolved.node;
|
||||||
|
runtime.env.requested ??= resolved.node;
|
||||||
|
|
||||||
if (length(resolved.ctx.auth)) {
|
if (length(resolved.ctx.auth)) {
|
||||||
let session = is_authenticated(resolved.ctx.auth);
|
let session = is_authenticated(resolved.ctx.auth);
|
||||||
|
|
|
@ -12,8 +12,6 @@ context = setmetatable({}, {
|
||||||
return _G.L.ctx.request_path
|
return _G.L.ctx.request_path
|
||||||
elseif k == "requestargs" then
|
elseif k == "requestargs" then
|
||||||
return _G.L.ctx.request_args
|
return _G.L.ctx.request_args
|
||||||
elseif k == "requested" or k == "dispatched" then
|
|
||||||
return _G.L.node
|
|
||||||
else
|
else
|
||||||
return _G.L.ctx[k]
|
return _G.L.ctx[k]
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue