9611f5ae7e55dc862222bbdd7890a8203427d330
[project/luci.git] / modules / admin-full / luasrc / controller / admin / index.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.admin.index", package.seeall)
15
16 function index()
17 luci.i18n.loadc("admin-core")
18 local i18n = luci.i18n.translate
19
20 local root = node()
21 if not root.target then
22 root.target = alias("admin")
23 root.index = true
24 end
25
26 entry({"about"}, template("about")).i18n = "admin-core"
27
28 local page = node("admin")
29 page.target = alias("admin", "index")
30 page.title = i18n("Administration")
31 page.order = 10
32 page.i18n = "admin-core"
33 page.sysauth = "root"
34 page.sysauth_authenticator = "htmlauth"
35 page.ucidata = true
36 page.index = true
37
38 local page = node("admin", "index")
39 page.target = template("admin_index/index")
40 page.title = i18n("Overview")
41 page.order = 10
42 page.index = true
43
44 local page = node("admin", "index", "luci")
45 page.target = cbi("admin_index/luci")
46 page.title = i18n("User Interface")
47 page.order = 10
48
49 entry({"admin", "index", "components"}, call("redir_components"), i18n("LuCI Components"), 20)
50 entry({"admin", "index", "logout"}, call("action_logout"), i18n("Logout"), 90)
51 end
52
53 function redir_components()
54 luci.http.redirect(luci.dispatcher.build_url("admin", "system", "packages")..'?update=1&query=luci')
55 end
56
57 function action_logout()
58 local dsp = require "luci.dispatcher"
59 local sauth = require "luci.sauth"
60 if dsp.context.authsession then
61 sauth.kill(dsp.context.authsession)
62 dsp.context.urltoken.stok = nil
63 end
64
65 luci.http.header("Set-Cookie", "sysauth=; path=" .. dsp.build_url())
66 luci.http.redirect(luci.dispatcher.build_url())
67 end