df31c010f589608a021fa572f9cc911cb419719c
[project/luci.git] / themes / openwrt.org / luasrc / view / themes / openwrt.org / header.htm
1 <%#
2 LuCI - Lua Configuration Interface
3 Copyright 2008 Steven Barth <steven@midlink.org>
4 Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
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 -%>
15 <%
16 require("luci.sys")
17 local load1, load5, load15 = luci.sys.loadavg()
18 local request  = require("luci.dispatcher").context.path
19 local category = request[1]
20 local tree     = luci.dispatcher.node()
21 local cattree  = category and luci.dispatcher.node(category)
22 local node     = luci.dispatcher.context.dispatched
23
24 local c = tree
25 for i,r in ipairs(request) do
26         if c.nodes and c.nodes[r] then
27                 c = c.nodes[r]
28                 c._menu_selected = true
29         end
30 end
31
32 require("luci.i18n").loadc("default")
33
34 require("luci.http").prepare_content("text/html")
35 %><?xml version="1.0" encoding="utf-8"?>
36 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
37 <html xmlns="http://www.w3.org/1999/xhtml">
38 <head>
39         <link rel="stylesheet" type="text/css" href="<%=media%>/cascade.css" />
40         <% if node and node.css then %><link rel="stylesheet" type="text/css" href="<%=resource%>/<%=node.css%>" /><% end %>
41         <meta http-equiv="content-type" content="text/xhtml+xml; charset=utf-8" />
42         <meta http-equiv="content-script-type" content="text/javascript" />
43         <title>LuCI - Lua Configuration Interface - <%=(node and node.title)%></title>
44 </head>
45 <body>
46 <div id="header">
47         <div class="info whitetext smalltext bold right">
48         <%=luci.config.brand.firmware%><br />
49         <%=luci.config.brand.distro%><br />
50         <%:load%>: <%=load1%> <%=load5%> <%=load15%><br />
51         <%:hostname%>: <%=luci.sys.hostname()%>
52         </div>
53         <div class="title">
54                 <span class="headertitle"><%=luci.config.brand.title%></span><br />
55                 <span class="whitetext bold"><%=luci.config.brand.subtitle%></span>
56         </div>
57 </div>
58
59 <div class="pathbar separator black whitetext bold">
60 <%:path%>: <%
61 local c = tree
62 local url = controller
63 for k,v in pairs(request) do
64         if c.nodes and c.nodes[v] then
65                 c = c.nodes[v]
66                 url = url .. "/" .. v
67         %><a href="<%=url%>"><%=c.title or v%></a> <% if k ~= #request then %>&#187; <% end
68         end
69 end
70 %>
71 </div>
72
73 <div class="menubar">
74         <div class="mainmenu">
75 <%
76 local function submenu(prefix, node)
77         if not node.nodes then
78                 return false
79         end
80         local index = {}
81         for k, n in pairs(node.nodes) do
82                 if n.title and n.target then
83                         table.insert(index, {name=k, order=n.order or 100})
84                 end
85         end
86
87         table.sort(index, function(a, b) return a.order < b.order end)
88 %>
89         <ul>
90         <% for j, v in pairs(index) do
91                 local nnode = node.nodes[v.name]
92                 local href = controller .. prefix .. v.name
93                 href = (nnode.query) and href .. luci.http.build_querystring(nnode.query) or href
94                 %>
95                 <li>
96                         <span<% if nnode._menu_selected then %> class="active"<%end%>><a href="<%=href%>"><%=nnode.title%></a></span>
97                         <% submenu(prefix .. v.name .. "/", nnode) %>
98                 </li>
99         <% end %>
100         </ul>
101 <%
102 end
103
104 if cattree and cattree.nodes then
105         local index = {}
106         for k, node in pairs(cattree.nodes) do
107                 table.insert(index, {name=k, order=node.order or 100})
108         end
109
110         table.sort(index, function(a, b) return a.order < b.order end)
111
112         for i, k in ipairs(index) do
113                 node = cattree.nodes[k.name]
114                 if node.title and node.target then
115                         local href = controller.."/"..category.."/"..k.name
116                         href = (k.query) and href .. luci.http.build_querystring(k.query) or href %>
117                         <div<% if node._menu_selected then %> class="preactive"<%end%>><a href="<%=href%>"><%=node.title%></a>
118                                 <%submenu("/" .. category .. "/" .. k.name .. "/", node)%>
119                         </div>
120 <%              end
121         end
122 end
123 %>
124         </div>
125         <div class="modemenu">
126                 <ul><%
127                         for k,node in pairs(tree.nodes) do
128                                 if node.title then %>
129                                         <li<% if request[1] == k then %> class="active"<%end%>><a href="<%=controller%>/<%=k%>"><%=node.title%></a></li>
130 <%                              end
131                         end%>
132                 </ul>
133
134                 <%
135                         if "admin" == request[1] then
136                                 local ucic = 0
137                                 for i, j in pairs(require("luci.model.uci").changes()) do
138                                         for k, l in pairs(j) do
139                                                 for m, n in pairs(l) do
140                                                         ucic = ucic + 1;
141                                                 end
142                                         end
143                                 end
144                 %>
145                 <div class="mainmenu" style="float:right; margin-right:2em">
146                         <div>
147                                 <% if ucic > 0 then %>
148                                 <a href="<%=controller%>/admin/uci/changes"><%:changes%>: <%=ucic%></a>
149                                 <ul>
150                                         <li><a href="<%=controller%>/admin/uci/apply"><%:apply%></a></li>
151                                         <li><a href="<%=controller%>/admin/uci/revert"><%:revert%></a></li>
152                                 </ul>
153                                 <% else %>
154                                 <a href="#"><%:changes%>: 0</a>
155                                 <% end %>
156                         </div>
157                 </div>
158                 <% end %>
159         </div>
160         <br class="clear" />
161 </div>
162 <div id="content">