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