Commit graph

11 commits

Author SHA1 Message Date
Jo-Philipp Wich
fa17c1573f luci-base, luci-lua-runtime: adjust Lua template environment
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-21 12:27:28 +01:00
Jo-Philipp Wich
08ae8d40a9 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>
2022-11-21 12:24:31 +01:00
Jo-Philipp Wich
c4d86c9f67 luci-base: expose sysauth rendering errors
In case a theme shipped sysauth.htm failed to render/execute, expose the
exception error details in the ui theme fallback indicator.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-11-21 12:20:58 +01:00
Jo-Philipp Wich
4b1a074c95 luci-base: dispatcher.uc: only flush HTTP headers after rendering output
Ensure to first completely render the action function before flushing HTTP
headers since the invoked action logic might modify the HTTP headers itself.

Fixes: e7afd0d327 ("luci-base: fix luci.http.close()")
Ref: e7afd0d327 (commitcomment-88736854)
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-11-03 11:17:55 +01:00
Jo-Philipp Wich
e7afd0d327 luci-base: fix luci.http.close()
Ensure that `http.write()` or template rendering operations after a call
to `http.close()` do not produce additional output. This is required for
certain legacy Lua apps which invoke write and close operations in the
middle of a server side cbi rendering process.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-11-03 00:38:00 +01:00
Jo-Philipp Wich
c99602e4ac luci-base: dispatcher.uc: apply ACLs to menu tree JSON
Add menu tree annotations for node readonly and dependency satisfied state
in order to ensure that unreachable menu nodes are hidden from view.

Fixes: ded8ccf93e ("luci-base-ucode: add initial ucode based LuCI runtime")
Ref: https://forum.openwrt.org/t/x/141426/10
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-11-02 10:13:41 +01:00
Jo-Philipp Wich
767acf32d4 luci-base: dispatcher.uc: update uci session ID in Lua context
Make sure that the uci session ID of the `luci.model.uci` module within
the Lua context is updated once we acquire the login session information.

In case legacy themes are used, the probing of the theme header template
might indirectly load the Lua runtime and the Lua side `luci.dispatcher`
module which in turn will load the `luci.model.uci` and set the session
ID there which is not yet initialized at this point in time.

This results in broken uci change handling within legacy Lua applications
when a legacy theme is loaded.

Fixes: #6060
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-10-27 11:14:52 +02:00
Jo-Philipp Wich
70e32f0cb1 luci-base: dispatcher.uc: ensure usage of dashes in language tags
The LuCI uci configuration requires language tags with underscores due
limitations of uci option names but the language catalogs themselves
are designated with dash separated language tags.

Make sure to substitute underscores with dashes when determining the
desired request language in order to fix loading of languages such as
`pt-br` or `zh-cn`.

Ref: https://github.com/openwrt/luci/pull/5976#issuecomment-1290352951
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-10-25 13:01:31 +02:00
Jo-Philipp Wich
adc4ca65bc luci-base: dispatcher.uc: reintroduce support for 'absent' fs depends
The ability to require certain paths to be absent for a menu entry to show
up was lost during the ucode conversion.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-10-25 12:50:37 +02:00
Jo-Philipp Wich
d9dcefd2aa luci-base: dispatcher.uc: support cbi and form action types
Some existing LuCI apps ship menu.d JSON files with `cbi` and `form` typed
dispatch targets, support those as well.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-10-25 01:03:37 +02:00
Jo-Philipp Wich
673f38246a treewide: separate Lua runtime resources
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>
2022-10-25 01:03:37 +02:00
Renamed from modules/luci-base-ucode/ucode/dispatcher.uc (Browse further)