luci-mod-status: transform status page Lua template into ucode template

Transform the only Lua template of the status module into an equivalent
ucode template and make it conditionally include the legacy Lua logic
factored out in a previous commit.

Only if the ucode Lua bridge is installed and loadable, the Lua template
loading the legacy Lua status partials is included.

After this commit, luci-mod-status is free of Lua dependencies.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
Jo-Philipp Wich 2022-09-14 13:30:45 +02:00
parent c7b300e614
commit 97da0baeb6

View file

@ -1,15 +1,15 @@
<%#
{#
Copyright 2008 Steven Barth <steven@midlink.org>
Copyright 2008-2018 Jo-Philipp Wich <jo@mein.io>
Copyright 2008-2022 Jo-Philipp Wich <jo@mein.io>
Licensed to the public under the Apache License 2.0.
-%>
-#}
<%+header%>
{% include('header') %}
<h2 name="content"><%:Status%></h2>
<h2 name="content">{{ _('Status') }}</h2>
<div id="view">
<div class="spinning"><%:Loading view…%></div>
<div class="spinning">{{ _('Loading view…') }}</div>
</div>
<script type="text/javascript">//<![CDATA[
@ -49,24 +49,15 @@ function renderBadge(icon, title) {
//]]></script>
<div class="includes" style="display:none">
<%-
local util = require "luci.util"
local fs = require "nixio.fs"
{%
let lua_available = true;
local incdir = util.libpath() .. "/view/admin_status/index/"
if fs.access(incdir) then
local _, inc
local includes = {}
for inc in fs.dir(incdir) do
if inc:match("%.htm$") then
includes[#includes + 1] = inc:gsub("%.htm$", "")
end
end
for _, inc in luci.util.vspairs(includes) do
include("admin_status/index/" .. inc)
end
end
-%>
try { require('lua'); }
catch(err) { lua_available = false; }
if (lua_available)
include('admin_status/luaindex');
%}
</div>
<script type="text/javascript">
@ -75,4 +66,4 @@ function renderBadge(icon, title) {
});
</script>
<%+footer%>
{% include('footer') %}