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