luci-mod-status: transform status page Lua template into ucode template
authorJo-Philipp Wich <redacted>
Wed, 14 Sep 2022 11:30:45 +0000 (13:30 +0200)
committerJo-Philipp Wich <redacted>
Mon, 24 Oct 2022 23:03:37 +0000 (01:03 +0200)
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 <redacted>
modules/luci-mod-status/ucode/template/admin_status/index.ut [moved from modules/luci-mod-status/luasrc/view/admin_status/index.htm with 69% similarity]

similarity index 69%
rename from modules/luci-mod-status/luasrc/view/admin_status/index.htm
rename to modules/luci-mod-status/ucode/template/admin_status/index.ut
index 7d7a42c2e354c2eca25ba24e7759d33bcac83db3..4d018a3efdcaf19125ed8be882a379e0a3d91515 100644 (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') %}
git clone https://git.99rst.org/PROJECT