From 694b8086cd5d7bec4a288334ff1b3920edf686d3 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Wed, 26 Oct 2022 22:43:56 +0200 Subject: [PATCH] luci-theme-openwrt-2020: convert Lua templates to ucode Convert the theme's Lua templates to ucode to avoid the implicit dependency on the luci-lua-runtime package. Signed-off-by: Jo-Philipp Wich --- .../luasrc/view/themes/openwrt2020/header.htm | 79 ------------------- .../template/themes/openwrt2020/footer.ut} | 7 +- .../template/themes/openwrt2020/header.ut | 72 +++++++++++++++++ 3 files changed, 75 insertions(+), 83 deletions(-) delete mode 100644 themes/luci-theme-openwrt-2020/luasrc/view/themes/openwrt2020/header.htm rename themes/luci-theme-openwrt-2020/{luasrc/view/themes/openwrt2020/footer.htm => ucode/template/themes/openwrt2020/footer.ut} (67%) create mode 100644 themes/luci-theme-openwrt-2020/ucode/template/themes/openwrt2020/header.ut diff --git a/themes/luci-theme-openwrt-2020/luasrc/view/themes/openwrt2020/header.htm b/themes/luci-theme-openwrt-2020/luasrc/view/themes/openwrt2020/header.htm deleted file mode 100644 index ba0945a172..0000000000 --- a/themes/luci-theme-openwrt-2020/luasrc/view/themes/openwrt2020/header.htm +++ /dev/null @@ -1,79 +0,0 @@ -<%# - Copyright 2020 Jo-Philipp Wich - Licensed to the public under the Apache License 2.0. --%> - -<% - local sys = require "luci.sys" - local util = require "luci.util" - local http = require "luci.http" - local disp = require "luci.dispatcher" - local ver = require "luci.version" - - local boardinfo = util.ubus("system", "board") or { } - - local node = disp.context.dispatched - local path = table.concat(disp.context.path, "-") - - http.prepare_content("text/html; charset=UTF-8") --%> - - - - - - - - - - - - -<%=striptags( (boardinfo.hostname or "?") .. ( (node and node.title) and ' - ' .. translate(node.title) or '')) %> - LuCI -<% if css then %> -<% end -%> - - - - - - - - - -
- - -
- <%- if luci.sys.process.info("uid") == 0 and luci.sys.user.getuser("root") and not luci.sys.user.getpasswd("root") and path ~= "admin-system-admin-password" then -%> -
-

<%:No password set!%>

-

<%:There is no password set on this router. Please configure a root password to protect the web interface.%>

- <% if disp.lookup("admin/system/admin") then %> - - <% end %> -
- <%- end -%> - - <%- if boardinfo.rootfs_type == "initramfs" then -%> -
-

<%:System running in recovery (initramfs) mode.%>

-

<%:No changes to settings will be stored and are lost after rebooting. This mode should only be used to install a firmware upgrade%>

- <% if disp.lookup("admin/system/flash") then %> - - <% end %> -
- <%- end -%> - - diff --git a/themes/luci-theme-openwrt-2020/luasrc/view/themes/openwrt2020/footer.htm b/themes/luci-theme-openwrt-2020/ucode/template/themes/openwrt2020/footer.ut similarity index 67% rename from themes/luci-theme-openwrt-2020/luasrc/view/themes/openwrt2020/footer.htm rename to themes/luci-theme-openwrt-2020/ucode/template/themes/openwrt2020/footer.ut index e9122f0b5c..5899f2a9dd 100644 --- a/themes/luci-theme-openwrt-2020/luasrc/view/themes/openwrt2020/footer.htm +++ b/themes/luci-theme-openwrt-2020/ucode/template/themes/openwrt2020/footer.ut @@ -1,14 +1,13 @@ -<%# +{# Copyright 2020 Jo-Philipp Wich Licensed to the public under the Apache License 2.0. --%> +-#}

- <% local ver = require "luci.version" -%> - Powered by <%= ver.luciname %> (<%= ver.luciversion %>) + Powered by {{ version.luciname }} ({{ version.luciversion }})

diff --git a/themes/luci-theme-openwrt-2020/ucode/template/themes/openwrt2020/header.ut b/themes/luci-theme-openwrt-2020/ucode/template/themes/openwrt2020/header.ut new file mode 100644 index 0000000000..2b7c581387 --- /dev/null +++ b/themes/luci-theme-openwrt-2020/ucode/template/themes/openwrt2020/header.ut @@ -0,0 +1,72 @@ +{# + Copyright 2020 Jo-Philipp Wich + Licensed to the public under the Apache License 2.0. +-#} + +{% + import { getuid, getspnam } from 'luci.core'; + + const boardinfo = ubus.call('system', 'board'); + + http.prepare_content('text/html; charset=UTF-8'); +-%} + + + + + + + + + + + + + +{{ striptags(`${boardinfo.hostname ?? '?'}${node ? ` - ${node.title}` : ''}`) }} - LuCI +{% if (css): %} + +{% endif %} + + + + + + + + + +
+ + +
+ {% if (getuid() == 0 && getspnam('root')?.pwdp === '' && join('-', ctx.request_path) != 'admin-system-admin'): %} +
+

{{ _('No password set!') }}

+

{{ _('There is no password set on this router. Please configure a root password to protect the web interface.') }}

+ {% if (dispatcher.lookup("admin/system/admin")): %} + + {% endif %} +
+ {% endif %} + + {% if (boardinfo.rootfs_type == "initramfs"): %} +
+

{{ _('System running in recovery (initramfs) mode.') }}

+

{{ _('No changes to settings will be stored and are lost after rebooting. This mode should only be used to install a firmware upgrade') }}

+ {% if (dispatcher.lookup("admin/system/flash")): %} + + {% endif %} +
+ {% endif %} + + -- 2.30.2