themes: entity fixes for theme headers
[project/luci.git] / themes / openwrt.org-oxygen / luasrc / view / themes / openwrt.org-oxygen / header.htm
1 a<%#
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 disp     = node
24 local hostname = luci.sys.hostname()
25
26 local c = tree
27 for i,r in ipairs(request) do
28         if c.nodes and c.nodes[r] then
29                 c = c.nodes[r]
30                 c._menu_selected = true
31         end
32 end
33
34 require("luci.i18n").loadc("default")
35 require("luci.http").prepare_content("application/xhtml+xml")
36
37 -%>
38
39 <?xml version="1.0" encoding="utf-8"?>
40 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
41 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<%=luci.i18n.context.lang%>" lang="<%=luci.i18n.context.lang%>">
42 <head>
43 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
44 <meta http-equiv="Content-Script-Type" content="text/javascript" />
45 <link rel="stylesheet" type="text/css" media="screen" href="<%=media%>/cascade.css" />
46 <link rel="stylesheet" type="text/css" media="screen" href="<%=media%>/dashboard.css" />
47 <!--[if lt IE 7]><link rel="stylesheet" type="text/css" media="screen" href="<%=media%>/ie6.css" /><![endif]-->
48 <!--[if IE 7]><link rel="stylesheet" type="text/css" media="screen" href="<%=media%>/ie7.css" /><![endif]-->
49 <% if node and node.css then %><link rel="stylesheet" type="text/css" media="screen" href="<%=resource%>/<%=node.css%>" />
50 <% end -%>
51 <script type="text/javascript" src="<%=resource%>/VarType.js"></script>
52 <script type="text/javascript" src="<%=resource%>/XHTML1.js"></script>
53 <script type="text/javascript" src="<%=resource%>/Dropdowns.js"></script>
54 <title><%=striptags( hostname .. ( (node and node.title) and ' - ' .. node.title or '')) %> - LuCI</title>
55 </head>
56 <body class="lang_<%=luci.i18n.context.lang%>">
57
58 <p class="skiplink">
59 <span id="skiplink1"><a href="#navigation"><%:skiplink1 Skip to navigation%></a></span>
60 <span id="skiplink2"><a href="#content"><%:skiplink2 Skip to content%></a></span>
61 </p>
62
63 <div id="header">
64 <h1><%=luci.version.distname%></h1>
65 <p>
66 <%=luci.version.distversion%><br />
67 <%:Load%>: <%="%.2f" % load1%> <%="%.2f" % load5%> <%="%.2f" % load15%><br />
68 <%:Hostname%>: <%=hostname%>
69 </p>
70 </div>
71
72 <div id="menubar">
73 <h2 class="navigation"><a id="navigation" name="navigation"><%:Navigation%></a></h2>
74 <ul id="mainmenu" class="dropdowns">
75 <%-
76 local function submenu(prefix, node)
77         if not node.nodes or node.hidden then
78                 return false
79         end
80         local index = {}
81         local count = 0
82         for k, n in pairs(node.nodes) do
83                 if n.title and n.target then
84                         table.insert(index, {name=k, order=n.order or 100})
85                         count = count + 1
86                 end
87         end
88
89         table.sort(index, function(a, b) return a.order < b.order end)
90
91         if count > 0 then
92 %>
93 <ul id="submenu_<%=string.gsub(string.gsub(prefix, "/", "_"), "^_(.-)_$", "%1")%>">
94 <%-
95                 for j, v in pairs(index) do
96                         if #v.name > 0 then
97                                 local nnode = node.nodes[v.name]
98                                 local href = controller .. prefix .. v.name .. "/"
99                                 href = (nnode.query) and href .. luci.http.build_querystring(nnode.query) or href
100 %>
101 <li><a<% if nnode._menu_selected then %> class="active"<%end%> href="<%=pcdata(href)%>"><%=pcdata(striptags(nnode.title))%></a><%-
102 submenu(prefix .. v.name .. "/", nnode)
103 %></li>
104 <%-
105                         end
106                 end
107 %>
108 </ul>
109 <%
110         end
111 end
112
113 if cattree and cattree.nodes then
114         local index = {}
115         for k, node in pairs(cattree.nodes) do
116                 table.insert(index, {name=k, order=node.order or 100})
117         end
118
119         table.sort(index, function(a, b) return a.order < b.order end)
120
121         for i, k in ipairs(index) do
122                 node = cattree.nodes[k.name]
123                 if node.title and node.target and not node.hidden then
124                         local href = controller.."/"..category.."/"..k.name.."/"
125                         href = (k.query) and href .. luci.http.build_querystring(k.query) or href
126 %>
127 <li><a<% if node._menu_selected then %> class="preactive"<%end%> href="<%=pcdata(href)%>"><%=pcdata(striptags(node.title))%></a><%
128 submenu("/" .. category .. "/" .. k.name .. "/", node)
129 %></li><% end
130         end
131 end
132 %>
133 </ul>
134
135 <ul id="modemenu"><%
136 for k,node in pairs(tree.nodes) do
137         if node.title and not node.hidden then %>
138 <li><a<% if request[1] == k then %> class="active"<%end%> href="<%=controller%>/<%=k%>/"><%=pcdata(striptags(node.title))%></a></li><%
139         end
140 end
141 %>
142 </ul>
143
144 <%
145 if tree.nodes[category] and tree.nodes[category].ucidata then
146         local ucic = 0
147         for i, j in pairs(require("luci.model.uci").cursor():changes()) do
148                 for k, l in pairs(j) do
149                         for m, n in pairs(l) do
150                                 ucic = ucic + 1;
151                         end
152                 end
153         end
154 -%>
155 <ul id="savemenu" class="dropdowns">
156 <li><% if ucic > 0 then %><a class="warning" href="<%=controller%>/<%=category%>/uci/changes/"><%:Unsaved Changes%>: <%=ucic%></a><%
157 submenu("/" .. category .. "/uci/", tree.nodes[category].nodes["uci"])
158 else -%>
159 <a href="#"><%:Changes%>: 0</a><% end -%>
160 </li>
161 </ul><% end %>
162
163 <div class="clear"></div>
164 </div>
165 <div id="maincontent">
166 <% if disp and disp.subindex then %><%+themes/openwrt.org-oxygen/dashboard%><% end %>