luci-app-opkg: convert menu entries to JSON
authorJo-Philipp Wich <jo@mein.io>
Tue, 10 Dec 2019 08:04:39 +0000 (09:04 +0100)
committerJo-Philipp Wich <jo@mein.io>
Mon, 16 Dec 2019 17:07:18 +0000 (18:07 +0100)
Also fix an empty string test in an controller action while we touch it.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
applications/luci-app-opkg/luasrc/controller/opkg.lua
applications/luci-app-opkg/root/usr/share/luci/menu.d/luci-app-opkg.json [new file with mode: 0644]

index 29c9a0864542842173e60f450db963792a5f2202..ebdcf1b09c82a584491934750f50a239c5f808b3 100644 (file)
@@ -3,14 +3,6 @@
 
 module("luci.controller.opkg", package.seeall)
 
-function index()
-       entry({"admin", "system", "opkg"}, template("opkg"), _("Software"), 30)
-       entry({"admin", "system", "opkg", "list"}, call("action_list")).leaf = true
-       entry({"admin", "system", "opkg", "exec"}, post("action_exec")).leaf = true
-       entry({"admin", "system", "opkg", "statvfs"}, call("action_statvfs")).leaf = true
-       entry({"admin", "system", "opkg", "config"}, post_on({ data = true }, "action_config")).leaf = true
-end
-
 function action_list(mode)
        local util = require "luci.util"
        local cmd
@@ -26,7 +18,7 @@ function action_list(mode)
                        fd:close()
                end
 
-               if not lists_dir or #lists_dir == "" then
+               if not lists_dir or #lists_dir == 0 then
                        lists_dir = "/tmp/opkg-lists"
                end
 
diff --git a/applications/luci-app-opkg/root/usr/share/luci/menu.d/luci-app-opkg.json b/applications/luci-app-opkg/root/usr/share/luci/menu.d/luci-app-opkg.json
new file mode 100644 (file)
index 0000000..9356b58
--- /dev/null
@@ -0,0 +1,44 @@
+{
+       "admin/system/opkg": {
+               "title": "Software",
+               "order": 30,
+               "action": {
+                       "type": "template",
+                       "path": "opkg"
+               }
+       },
+
+       "admin/system/opkg/list/*": {
+               "action": {
+                       "type": "call",
+                       "module": "luci.controller.opkg",
+                       "function": "action_list"
+               }
+       },
+
+       "admin/system/opkg/exec/*": {
+               "action": {
+                       "type": "call",
+                       "post": true,
+                       "module": "luci.controller.opkg",
+                       "function": "action_exec"
+               }
+       },
+
+       "admin/system/opkg/statvfs/*": {
+               "action": {
+                       "type": "call",
+                       "module": "luci.controller.opkg",
+                       "function": "action_statvfs"
+               }
+       },
+
+       "admin/system/opkg/config/*": {
+               "action": {
+                       "type": "call",
+                       "post": { "data": true },
+                       "module": "luci.controller.opkg",
+                       "function": "action_config"
+               }
+       }
+}