summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-lua-runtime
AgeCommit message (Collapse)Author
2022-11-21luci-base, luci-lua-runtime: adjust Lua template environmentJo-Philipp Wich
To maintain full compatibility with the old Lua runtime, templates rendered from a menu `template()` action must implicitly inherit the `luci.dispatcher` namespace as scope while other indirectly included templates must not. Fixes: #6105 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-11-21luci-base, luci-lua-runtime: fix "dispatched" and "requested" propertiesJo-Philipp Wich
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>
2022-11-15luci-lua-runtime: proxy all dispatcher context property accessesJo-Philipp Wich
The ucode side dispatcher environment might not be fully populated yet when the emulated Lua dispatcher is loaded, leading to `context.requested` and some other properties to be `nil`. Expose all properties through metatable `__index` lookups instead to ensure that the Lua side dispatcher always sees the latest values. Fixes: #6100 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-11-11luci-lua-runtime: preload luci.ltn12Jo-Philipp Wich
Some existing legacy code expects the luci.ltn12 namespace to be implicitly available, even without requiring it beforehand. Fixes: #6091 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-11-10luci-lua-runtime: dispatcher.lua: translate legacy node "target" propertyJo-Philipp Wich
Some legacy Lua controllers declare menu entries by first invoking `node()` and then setting the `.target` property on the resulting object. Make sure to properly translate such menu nodes into the internal menu JSON representation. Fixes: #6090 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-11-09luci-lua-runtime: also search luci.dispatcher scope when looking up valuesJo-Philipp Wich
Some legacy templates access dispatcher functions such as `build_url()` without explicit scope, which worked in the old runtime since the template view namespace was instantiated from the dispatcher. Ensure that this continues to function in the emulated runtime. Fixes: #6082 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-11-08lua-runtime: template: fix "tpl" refactoringKarl Palsson
This fixes crashes on "tpl" being undefined. Signed-off-by: Karl Palsson <karlp@etactica.com>
2022-10-26luci-lua-runtime: render cbi header/footer templates via ucode runtimeJo-Philipp Wich
Trigger rendering of CBI header and footer templates via the ucode runtime `include()` in order to ensure that scope data is properly inherited from Lua templates (`cbi/header`) including ucode templates (`header`). This fixes automatic triggering of the config apply flow on legacy Lua CBI forms. Ref: https://github.com/openwrt/luci/pull/6056#issuecomment-1292396588 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-10-26luci-lua-runtime: fix loading header/footer templates for SimpleFormsJo-Philipp Wich
Fixes: #6054 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-10-26luci-lua-runtime: ensure proper forwarding of route arguments to cbi actionJo-Philipp Wich
Ensure that the optional cbi() `config` argument is set to an empty table if unspecified to ensure that the static call argument array is exactly two elements long, otherwise call arguments are shifted and the invoked method might not receive the expected parameter. This fixes, among others, the dispatching of `arcombine()` targets. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-10-25luci-lua-runtime: drop Lua server gateway modulesJo-Philipp Wich
Remove the uhttpd and CGI gateway modules as they're not compatible with the Lua compat stub runtime anymore. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-10-25luci-lua-runtime: preload luci.sysJo-Philipp Wich
Some existing model code expects the luci.sys namespace to be implicitly available, even without requiring it beforehand. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-10-25luci-lua-runtime: add compatibility template for legacy Lua status includesJo-Philipp Wich
Add a compatibility template containing legacy Lua logic extracted from the luci-mod-status main status page in order to free the status module from any explicit or implicit Lua dependencies. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-10-25luci.mk: automatically depend on luci-lua-runtimeJo-Philipp Wich
Make packages having a non-empty luasrc/ directory automatically depend on the LuCI Lua runtime package. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-10-25treewide: separate Lua runtime resourcesJo-Philipp Wich
Move classes required for Lua runtime support into a new `luci-lua-runtime` package. Also replace the `luci.http` and `luci.util` classes in `luci-lib-base` with stubbed versions interacting with the ucode based runtime environment. Finally merge `luci-base-ucode` into the remainders of `luci-base`. Signed-off-by: Jo-Philipp Wich <jo@mein.io>