diff options
author | Jo-Philipp Wich <jo@mein.io> | 2020-02-06 12:07:08 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2020-02-06 12:54:07 +0100 |
commit | 556e14c74307a9b93291e7c25d5eb71ab3260ab6 (patch) | |
tree | 47facc735b1c06ae201d66375d6778c826cc5fbd /applications/luci-app-statistics/luasrc/controller | |
parent | e6f76f21ba7f0e8f903d5251a620386cd02b524b (diff) |
luci-app-statistics: convert plugin definitions to JSON
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'applications/luci-app-statistics/luasrc/controller')
-rw-r--r-- | applications/luci-app-statistics/luasrc/controller/luci_statistics/luci_statistics.lua | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/applications/luci-app-statistics/luasrc/controller/luci_statistics/luci_statistics.lua b/applications/luci-app-statistics/luasrc/controller/luci_statistics/luci_statistics.lua index 4c5db17d83..529cc2335a 100644 --- a/applications/luci-app-statistics/luasrc/controller/luci_statistics/luci_statistics.lua +++ b/applications/luci-app-statistics/luasrc/controller/luci_statistics/luci_statistics.lua @@ -9,6 +9,7 @@ function index() require("nixio.fs") require("luci.util") require("luci.statistics.datatree") + require("luci.jsonc") -- override entry(): check for existence <plugin>.so where <plugin> is derived from the called path function _entry( path, ... ) @@ -31,14 +32,14 @@ function index() network = { } } - local plugin_dir = "/usr/lib/lua/luci/statistics/plugins/" + local plugin_dir = "/usr/share/luci/statistics/plugins/" for filename in nixio.fs.dir(plugin_dir) do - local plugin_fun = loadfile(plugin_dir .. filename) - setfenv(plugin_fun, { _ = luci.i18n.translate }) - local plugin = plugin_fun() - local name = filename:gsub("%.lua", "") - table.insert(collectd_menu[plugin.category], name) - labels[name] = plugin.label + local plugin_def = luci.jsonc.parse(nixio.fs.readfile(plugin_dir .. filename)) + if type(plugin_def) == "table" then + local name = filename:gsub("%.json", "") + table.insert(collectd_menu[plugin_def.category], name) + labels[name] = plugin_def.title + end end -- create toplevel menu nodes |