themes/freifunk-generic: Add changes from r7585
[project/luci.git] / themes / freifunk-generic / luasrc / view / themes / freifunk-generic / 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
13 <%
14 require("luci.sys")
15 local uci = require "luci.model.uci".cursor()
16 local fs = require "luci.fs"
17
18 local load1, load5, load15 = luci.sys.loadavg()
19 local request  = require("luci.dispatcher").context.path
20 local category = request[1]
21 local tree     = luci.dispatcher.node()
22 local cattree  = category and luci.dispatcher.node(category)
23 local node     = luci.dispatcher.context.dispatched
24 local hostname = luci.sys.hostname()
25 local ff = uci:get("freifunk", "community", "name") or ""
26 local co = "profile_" .. ff
27 local community = uci:get_first(co, "community", "name") or "Freifunk"
28 local hp = uci:get_first(co, "community", "homepage") or "http://www.freifunk.net"
29 local logo = "/luci-static/freifunk-generic/logo.jpg"
30 local banner = false
31 local show_comm = true
32
33 local lo = fs.glob("/www/luci-static/resources/custom_logo.*")
34 if lo[1] then
35         logo = string.gsub(lo[1], "/www", "")
36 end
37
38 local lon = fs.glob("/www/luci-static/resources/custom_logo_only.*")
39 if lon[1] then
40         logo = string.gsub(lon[1], "/www", "")
41         show_comm = false
42 end
43
44 local hea = fs.glob("/www/luci-static/resources/custom_header.*")
45 if hea[1] then
46         logo = string.gsub(hea[1], "/www", "")
47         show_comm = false
48         banner = true
49 end 
50
51 local c = tree
52 for i,r in ipairs(request) do
53         if c.nodes and c.nodes[r] then
54                 c = c.nodes[r]
55                 c._menu_selected = true
56         end
57 end
58
59 require("luci.i18n").loadc("default")
60 require("luci.http").prepare_content("application/xhtml+xml")
61
62 -%>
63
64 <?xml version="1.0" encoding="utf-8"?>
65 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
66 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<%=luci.i18n.context.lang%>" lang="<%=luci.i18n.context.lang%>">
67 <head>
68 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
69 <meta http-equiv="Content-Script-Type" content="text/javascript" />
70 <link rel="stylesheet" type="text/css" media="screen" href="<%=media%>/cascade.css" />
71 <link rel="stylesheet" media="only screen and (max-device-width: 480px)" href="<%=media%>/mobile.css" type="text/css" />
72 <link rel="stylesheet" media="handheld" href="<%=media%>/mobile.css" type="text/css" /> 
73 <!--[if IE 7]><link rel="stylesheet" type="text/css" media="screen" href="<%=media%>/ie7.css" /><![endif]-->
74 <% if node and node.css then %><link rel="stylesheet" type="text/css" media="screen" href="<%=resource%>/<%=node.css%>" />
75 <% end -%>
76 <script type="text/javascript" src="<%=resource%>/xhr.js"></script>
77
78 <title><%=striptags( hostname .. ( (node and node.title) and ' - ' .. translate(node.title) or '')) %> - LuCI</title>
79 </head>
80
81 <body class="lang_<%=luci.i18n.context.lang%>">
82
83 <div class="wrapper">
84
85 <!--[if lt IE 7]>
86 <div class="warning"><div style="background-color: #cccccc;padding: 2px 10px 2px 10px">
87 <%: Your Internet Explorer is too old to display this page correctly. Please upgrade it to at least version 7 or use another browser like Firefox, Opera or Safari.%>
88 </div></div>
89 <![endif]-->
90
91 <%- if luci.sys.user.getuser("root") and not luci.sys.user.getpasswd("root") then -%>
92         <div class="warning">
93                 <strong><%:No password set!%></strong><br />
94                 <%:There is no password set on this router. Please configure a root password to protect the web interface and enable SSH.%>
95         </div>
96 <%- end -%>
97
98 <p class="skiplink">
99 <span id="skiplink1"><a href="#navigation"><%:skiplink1 Skip to navigation%></a></span>
100 <span id="skiplink2"><a href="#content"><%:skiplink2 Skip to content%></a></span>
101 </p>
102
103 <div id="header">
104         <%if banner then%>
105                 <div class="header_banner">
106                         <a href="<%=hp%>"><img src="<%=logo%>" alt="Header" /></a>
107                 </div>
108         <%else%>
109                 <div class="header_left">
110                         <a href="<%=hp%>"><img src="<%=logo%>" alt="Logo" /></a>
111                         <%if show_comm then%>
112                                 <a href="<%=hp%>"><%=community%></a>
113                                 <br/>
114                         <%end%>
115                 <div class = "spacer"></div>
116                 </div>
117                 <div class="header_right">
118                         <%=luci.version.distversion%><br />
119                         <%:Load%>: <%="%.2f" % load1%> <%="%.2f" % load5%> <%="%.2f" % load15%><br />
120                         <%:Hostname%>: <%=hostname%><br />
121                         <span id="xhr_poll_status" style="display:none" onclick="XHR.running() ? XHR.halt() : XHR.run()"> 
122                                 | <%:Auto Refresh%>: 
123                                 <span id="xhr_poll_status_on"><%:on%></span> 
124                                 <span id="xhr_poll_status_off" style="display:none"><%:off%></span> 
125                         </span> 
126                 </div>
127         <%end%>
128 </div>
129
130 <div id="menubar">
131 <h2 class="navigation"><a id="navigation" name="navigation"><%:navigation Navigation%></a></h2>
132 <ul id="mainmenu" class="dropdowns">
133 <%-
134 local function submenu(prefix, node)
135         if not node.nodes or node.hidden then
136                 return false
137         end
138         local index = {}
139         local count = 0
140         for k, n in pairs(node.nodes) do
141                 if n.title and n.target then
142                         table.insert(index, {name=k, order=n.order or 100})
143                         count = count + 1
144                 end
145         end
146
147         table.sort(index, function(a, b) return a.order < b.order end)
148
149         if count > 0 then
150 %>
151 <ul id="submenu_<%=string.gsub(string.gsub(prefix, "/", "_"), "^_(.-)_$", "%1")%>">
152 <%-
153                 for j, v in pairs(index) do
154                         if #v.name > 0 then
155                                 local nnode = node.nodes[v.name]
156                                 local href = controller .. prefix .. v.name .. "/"
157                                 href = (nnode.query) and href .. luci.http.build_querystring(nnode.query) or href
158 %>
159 <li><a<% if nnode._menu_selected then %> class="active"<%end%> href="<%=luci.util.pcdata(href)%>"><%=translate(nnode.title)%></a><%-
160 submenu(prefix .. v.name .. "/", nnode)
161 %></li>
162 <%-
163                         end
164                 end
165 %>
166 </ul>
167 <%
168         end
169 end
170
171 if cattree and cattree.nodes then
172         local index = {}
173         for k, node in pairs(cattree.nodes) do
174                 table.insert(index, {name=k, order=node.order or 100})
175         end
176
177         table.sort(index, function(a, b) return a.order < b.order end)
178
179         for i, k in ipairs(index) do
180                 node = cattree.nodes[k.name]
181                 if node.title and node.target and not node.hidden then
182                         local href = controller.."/"..category.."/"..k.name.."/"
183                         href = (k.query) and href .. luci.http.build_querystring(k.query) or href
184 %>
185 <li><a<% if node._menu_selected then %> class="preactive"<%end%> href="<%=href%>"><%=translate(node.title)%></a><%
186 submenu("/" .. category .. "/" .. k.name .. "/", node)
187 %></li><% end
188         end
189 end
190 %>
191 <li></li></ul>
192
193 <ul id="modemenu"><%
194 for k,node in pairs(tree.nodes) do
195         if node.title and not node.hidden then %>
196 <li><a<% if request[1] == k then %> class="active"<%end%> href="<%=controller%>/<%=k%>/"><%=translate(node.title)%></a></li><%
197         end
198 end
199 %>
200 </ul>
201
202 <%
203 if tree.nodes[category] and tree.nodes[category].ucidata then
204         local ucic = 0
205         for i, j in pairs(require("luci.model.uci").cursor():changes()) do
206                 for k, l in pairs(j) do
207                         for m, n in pairs(l) do
208                                 ucic = ucic + 1;
209                         end
210                 end
211         end
212 -%>
213
214 <div id="savemenu">
215         <% if ucic > 0 then %>
216                 <a class="warning" href="<%=controller%>/<%=category%>/uci/changes/?redir=<%=luci.http.urlencode(luci.http.formvalue("redir") or REQUEST_URI)%>"><%:Unsaved Changes%>: <%=ucic%></a>
217         <% end -%>
218 </div><% end %>
219
220 <div class="clear"></div>
221 </div>
222 <div id="maincontent">
223 <% if category ~= "freifunk" and category ~= "splash" then %>
224 <noscript>
225         <div class="errorbox">
226                 <strong><%:Java Script required!%></strong><br />
227                 <%:You must enable Java Script in your browser or LuCI will not work properly.%>
228         </div>
229 </noscript>
230 <% end %>