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