* Core translation
[project/luci.git] / modules / freifunk / luasrc / controller / freifunk / freifunk.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2008 Steven Barth <steven@midlink.org>
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10         http://www.apache.org/licenses/LICENSE-2.0
11
12 $Id$
13 ]]--
14 module("luci.controller.freifunk.freifunk", package.seeall)
15
16 function index()
17         local i18n = luci.i18n.translate
18
19         local page  = node()
20         page.target = alias("freifunk")
21
22         local page    = node("freifunk")
23         page.title    = "Freifunk"
24         page.target   = alias("freifunk", "index")
25         page.order    = 5
26         page.setuser  = "nobody"
27         page.setgroup = "nogroup"
28         
29         local page  = node("freifunk", "index")
30         page.target = template("freifunk/index")
31         page.title  = "Übersicht"
32         page.order  = 10
33         
34         local page  = node("freifunk", "index", "contact")
35         page.target = template("freifunk/contact")
36         page.title  = "Kontakt"
37         
38         
39         local page  = node("freifunk", "status")
40         page.target = call("action_status")
41         page.title  = "Status"
42         page.order  = 20
43         page.setuser  = false
44         page.setgroup = false
45         
46         assign({"freifunk", "status", "routes"}, {"admin", "status", "routes"}, "Routingtabelle", 10)
47         assign({"freifunk", "status", "iwscan"}, {"admin", "status", "iwscan"}, "WLAN-Scan", 20)
48         
49         assign({"freifunk", "olsr"}, {"admin", "status", "olsr"}, "OLSR", 30)
50         
51         if luci.fs.isfile("/etc/config/luci_statistics") then
52                 assign({"freifunk", "statistics"}, {"admin", "statistics", "graph"}, i18n("stat_statistics", "Statistiken"), 40)
53         end
54         
55         local page  = node("admin", "index", "freifunk")
56         page.target = cbi("freifunk/freifunk")
57         page.title  = "Freifunk"
58         page.order  = 30
59         
60         local page  = node("admin", "index", "contact")
61         page.target = cbi("freifunk/contact")
62         page.title  = "Kontakt"
63         page.order  = 40
64 end
65
66 function action_status()
67         local data = {}
68         
69         data.s, data.m, data.r = luci.sys.sysinfo()
70         
71         data.wifi = luci.sys.wifi.getiwconfig()
72         
73         data.routes = {}
74         for i, r in pairs(luci.sys.net.routes()) do
75                 if r.Destination == "00000000" then
76                         table.insert(data.routes, r)
77                 end
78         end
79
80         
81         luci.template.render("public_status/index", data)
82 end