diff options
author | Steven Barth <steven@midlink.org> | 2008-06-02 20:16:05 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2008-06-02 20:16:05 +0000 |
commit | 561b0cfaa3fb8163d9ec74a3f96fd5b22ad54f33 (patch) | |
tree | 8b4b1765c70bae824bbad3006021cf7a4a775a34 /modules/freifunk/luasrc/controller | |
parent | 953510ccac9b9c6b3c1d8634897c0dddc92913e4 (diff) |
* Moved Freifunk status pages to admin-core and linked them in Freifunk
* luci/web: Added assign() to dispatcher to reference foreign nodes in the dispatching tree
Diffstat (limited to 'modules/freifunk/luasrc/controller')
-rw-r--r-- | modules/freifunk/luasrc/controller/freifunk/freifunk.lua | 13 | ||||
-rw-r--r-- | modules/freifunk/luasrc/controller/freifunk/olsr.lua | 164 |
2 files changed, 4 insertions, 173 deletions
diff --git a/modules/freifunk/luasrc/controller/freifunk/freifunk.lua b/modules/freifunk/luasrc/controller/freifunk/freifunk.lua index 89813b3d8..39ae5fe9a 100644 --- a/modules/freifunk/luasrc/controller/freifunk/freifunk.lua +++ b/modules/freifunk/luasrc/controller/freifunk/freifunk.lua @@ -27,16 +27,11 @@ function index() page.order = 20 page.setuser = false page.setgroup = false - - local page = node("freifunk", "status", "routes") - page.target = template("public_status/routes") - page.title = "Routingtabelle" - page.order = 10 - local page = node("freifunk", "status", "iwscan") - page.target = template("public_status/iwscan") - page.title = "WLAN-Scan" - page.order = 20 + assign({"freifunk", "status", "routes"}, node("admin", "status", "routes"), "Routingtabelle", 10) + assign({"freifunk", "status", "iwscan"}, node("admin", "status", "iwscan"), "WLAN-Scan", 20) + + assign({"freifunk", "olsr"}, node("admin", "status", "olsr"), "OLSR", 30) local page = node("admin", "index", "freifunk") page.target = cbi("freifunk/freifunk") diff --git a/modules/freifunk/luasrc/controller/freifunk/olsr.lua b/modules/freifunk/luasrc/controller/freifunk/olsr.lua deleted file mode 100644 index ac143277d..000000000 --- a/modules/freifunk/luasrc/controller/freifunk/olsr.lua +++ /dev/null @@ -1,164 +0,0 @@ -module("luci.controller.freifunk.olsr", package.seeall) -require("luci.sys") - -function index() - local page = node("freifunk", "olsr") - page.target = call("action_index") - page.title = "OLSR" - page.order = 30 - - local page = node("freifunk", "olsr", "routes") - page.target = call("action_routes") - page.title = "Routen" - page.order = 10 - - local page = node("freifunk", "olsr", "topology") - page.target = call("action_topology") - page.title = "Topologie" - page.order = 20 - - local page = node("freifunk", "olsr", "hna") - page.target = call("action_hna") - page.title = "HNA" - page.order = 30 - - local page = node("freifunk", "olsr", "mid") - page.target = call("action_mid") - page.title = "MID" - page.order = 50 -end - -function action_index() - local data = fetch_txtinfo("links") - - if not data or not data.Links then - luci.template.render("freifunk-olsr/error_olsr") - return nil - end - - local function compare(a, b) - if tonumber(a.ETX) == 0 then - return false - end - - if tonumber(b.ETX) == 0 then - return true - end - - return tonumber(a.ETX) < tonumber(b.ETX) - end - - table.sort(data.Links, compare) - - luci.template.render("freifunk-olsr/index", {links=data.Links}) -end - -function action_routes() - local data = fetch_txtinfo("routes") - - if not data or not data.Routes then - luci.template.render("freifunk-olsr/error_olsr") - return nil - end - - local function compare(a, b) - if tonumber(a.ETX) == 0 then - return false - end - - if tonumber(b.ETX) == 0 then - return true - end - - return tonumber(a.ETX) < tonumber(b.ETX) - end - - table.sort(data.Routes, compare) - - luci.template.render("freifunk-olsr/routes", {routes=data.Routes}) -end - -function action_topology() - local data = fetch_txtinfo("topology") - - if not data or not data.Topology then - luci.template.render("freifunk-olsr/error_olsr") - return nil - end - - local function compare(a, b) - return a["Destination IP"] < b["Destination IP"] - end - - table.sort(data.Topology, compare) - - luci.template.render("freifunk-olsr/topology", {routes=data.Topology}) -end - -function action_hna() - local data = fetch_txtinfo("hna") - - if not data or not data.HNA then - luci.template.render("freifunk-olsr/error_olsr") - return nil - end - - local function compare(a, b) - return a.Network < b.Network - end - - table.sort(data.HNA, compare) - - luci.template.render("freifunk-olsr/hna", {routes=data.HNA}) -end - -function action_mid() - local data = fetch_txtinfo("mid") - - if not data or not data.MID then - luci.template.render("freifunk-olsr/error_olsr") - return nil - end - - local function compare(a, b) - return a.IP < b.IP - end - - table.sort(data.MID, compare) - - luci.template.render("freifunk-olsr/mid", {mids=data.MID}) -end - - --- Internal -function fetch_txtinfo(otable) - otable = otable or "" - local rawdata = luci.sys.httpget("http://127.0.0.1:2006/"..otable) - - if #rawdata == 0 then - return nil - end - - local data = {} - - local tables = luci.util.split(luci.util.trim(rawdata), "\n\n") - - - for i, tbl in ipairs(tables) do - local lines = luci.util.split(tbl, "\n") - local name = table.remove(lines, 1):sub(8) - local keys = luci.util.split(table.remove(lines, 1), "\t") - - data[name] = {} - - for j, line in ipairs(lines) do - local fields = luci.util.split(line, "\t") - data[name][j] = {} - for k, key in pairs(keys) do - data[name][j][key] = fields[k] - end - end - end - - return data -end
\ No newline at end of file |