modules/admin-full: make logout a toplevel item, remove overview menu
[project/luci.git] / modules / admin-full / luasrc / model / cbi / admin_index / luci.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2008 Steven Barth <steven@midlink.org>
5 Copyright 2010 Jo-Philipp Wich <xm@subsignal.org>
6
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
10
11 http://www.apache.org/licenses/LICENSE-2.0
12
13 $Id$
14 ]]--
15
16 require("luci.config")
17 m = Map("luci", translate("Web <abbr title=\"User Interface\">UI</abbr>"), translate("Here you can customize the settings and the functionality of <abbr title=\"Lua Configuration Interface\">LuCI</abbr>."))
18
19 local fs = require "nixio.fs"
20
21 -- force reload of global luci config namespace to reflect the changes
22 function m.commit_handler(self)
23 package.loaded["luci.config"] = nil
24 require("luci.config")
25 end
26
27
28 c = m:section(NamedSection, "main", "core", translate("General"))
29
30 l = c:option(ListValue, "lang", translate("Language"))
31 l:value("auto")
32
33 local i18ndir = luci.i18n.i18ndir .. "base."
34 for k, v in luci.util.kspairs(luci.config.languages) do
35 local file = i18ndir .. k:gsub("_", "-")
36 if k:sub(1, 1) ~= "." and fs.access(file .. ".lmo") then
37 l:value(k, v)
38 end
39 end
40
41 t = c:option(ListValue, "mediaurlbase", translate("Design"))
42 for k, v in pairs(luci.config.themes) do
43 if k:sub(1, 1) ~= "." then
44 t:value(v, k)
45 end
46 end
47
48 u = m:section(NamedSection, "uci_oncommit", "event", translate("Post-commit actions"),
49 translate("These commands will be executed automatically when a given <abbr title=\"Unified Configuration Interface\">UCI</abbr> configuration is committed allowing changes to be applied instantly."))
50 u.dynamic = true
51
52
53 f = m:section(NamedSection, "main", "core", translate("Files to be kept when flashing a new firmware"))
54
55 f:tab("detected", translate("Detected Files"),
56 translate("The following files are detected by the system and will be kept automatically during sysupgrade"))
57
58 f:tab("custom", translate("Custom Files"),
59 translate("This is a list of shell glob patterns for matching files and directories to include during sysupgrade"))
60
61 d = f:taboption("detected", DummyValue, "_detected", translate("Detected files"))
62 d.rawhtml = true
63 d.cfgvalue = function(s)
64 local list = io.popen(
65 "( find $(sed -ne '/^[[:space:]]*$/d; /^#/d; p' /etc/sysupgrade.conf " ..
66 "/lib/upgrade/keep.d/* 2>/dev/null) -type f 2>/dev/null; " ..
67 "opkg list-changed-conffiles ) | sort -u"
68 )
69
70 if list then
71 local files = { "<ul>" }
72
73 while true do
74 local ln = list:read("*l")
75 if not ln then
76 break
77 else
78 files[#files+1] = "<li>"
79 files[#files+1] = luci.util.pcdata(ln)
80 files[#files+1] = "</li>"
81 end
82 end
83
84 list:close()
85 files[#files+1] = "</ul>"
86
87 return table.concat(files, "")
88 end
89
90 return "<em>" .. translate("No files found") .. "</em>"
91 end
92
93 c = f:taboption("custom", TextValue, "_custom", translate("Custom files"))
94 c.rmempty = false
95 c.cols = 70
96 c.rows = 30
97
98 c.cfgvalue = function(self, section)
99 return nixio.fs.readfile("/etc/sysupgrade.conf")
100 end
101
102 c.write = function(self, section, value)
103 value = value:gsub("\r\n?", "\n")
104 return nixio.fs.writefile("/etc/sysupgrade.conf", value)
105 end
106
107 return m