From e4960147606af6528f5b92f975e30c61565d53a0 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Mon, 26 Sep 2022 12:26:41 +0200 Subject: [PATCH] luci-theme-material: convert Lua templates to ucode Signed-off-by: Jo-Philipp Wich --- .../luasrc/view/themes/material/header.htm | 101 ------------------ .../templates/material/footer.ut} | 20 ++-- .../ucode/templates/material/header.ut | 96 +++++++++++++++++ 3 files changed, 106 insertions(+), 111 deletions(-) delete mode 100644 themes/luci-theme-material/luasrc/view/themes/material/header.htm rename themes/luci-theme-material/{luasrc/view/themes/material/footer.htm => ucode/templates/material/footer.ut} (62%) create mode 100644 themes/luci-theme-material/ucode/templates/material/header.ut diff --git a/themes/luci-theme-material/luasrc/view/themes/material/header.htm b/themes/luci-theme-material/luasrc/view/themes/material/header.htm deleted file mode 100644 index 48059fe17a..0000000000 --- a/themes/luci-theme-material/luasrc/view/themes/material/header.htm +++ /dev/null @@ -1,101 +0,0 @@ -<%# - Material is a clean HTML5 theme for LuCI. It is based on luci-theme-bootstrap and MUI - - luci-theme-material - Copyright 2015-2017 Lutty Yang - - Have a bug? Please create an issue here on GitHub! - https://github.com/LuttyYang/luci-theme-material/issues - - luci-theme-bootstrap: - Copyright 2008 Steven Barth - Copyright 2008-2016 Jo-Philipp Wich - Copyright 2012 David Menting - - MUI: - https://github.com/muicss/mui - - 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") --%> - - - - - - - - - - - - LuCI"> - - LuCI"> - - -<% if node and node.css then %> - -<% end -%> - - -<%=striptags( (boardinfo.hostname or "?") .. ( (node and node.title) and ' - ' .. translate(node.title) or '')) %> - LuCI -<% if css then %> -<% end -%> - -node-<%= path %><% else %>node-main-login<% end %>" data-page="<%= pcdata(path) %>"> -
- -
-
-
<%:Collecting data...%>
- -
- -
-
-
- <%- 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 -%> - <%- 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-material/luasrc/view/themes/material/footer.htm b/themes/luci-theme-material/ucode/templates/material/footer.ut similarity index 62% rename from themes/luci-theme-material/luasrc/view/themes/material/footer.htm rename to themes/luci-theme-material/ucode/templates/material/footer.ut index f572504f4b..9249427a43 100644 --- a/themes/luci-theme-material/luasrc/view/themes/material/footer.htm +++ b/themes/luci-theme-material/ucode/templates/material/footer.ut @@ -1,4 +1,4 @@ -<%# +{# Material is a clean HTML5 theme for LuCI. It is based on luci-theme-bootstrap and MUI luci-theme-material @@ -16,17 +16,17 @@ https://github.com/muicss/mui Licensed to the public under the Apache License 2.0 --%> - -<% local ver = require "luci.version" %> -
- +-#} + +
+ +
- - + diff --git a/themes/luci-theme-material/ucode/templates/material/header.ut b/themes/luci-theme-material/ucode/templates/material/header.ut new file mode 100644 index 0000000000..24b2c73517 --- /dev/null +++ b/themes/luci-theme-material/ucode/templates/material/header.ut @@ -0,0 +1,96 @@ +{# + Material is a clean HTML5 theme for LuCI. It is based on luci-theme-bootstrap and MUI + + luci-theme-material + Copyright 2015-2017 Lutty Yang + + Have a bug? Please create an issue here on GitHub! + https://github.com/LuttyYang/luci-theme-material/issues + + luci-theme-bootstrap: + Copyright 2008 Steven Barth + Copyright 2008-2016 Jo-Philipp Wich + Copyright 2012 David Menting + + MUI: + https://github.com/muicss/mui + + Licensed to the public under the Apache License 2.0 +-#} + +{% + import { getuid, getspnam } from 'luci.core'; + + const boardinfo = ubus.call('system', 'board'); + const hostname = striptags(boardinfo?.hostname ?? '?'); + + http.prepare_content('text/html; charset=UTF-8'); +-%} + + + + + + + + + + + + + + + +{% if (node?.css): %} + +{% endif %} + + +{{ hostname }}{{ node?.title ? ` - ${striptags(node.title)}` : '' }} - LuCI +{% if (css): %} + +{% endif %} + + +
+
+
+ + + {{ hostname }} + +
+
+
+
+
{{ _('Collecting data...') }}
+ +
+ +
+
+
+ {% if (getuid() == 0 && getspnam('root')?.pwdp === ''): %} + + {% 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