themes/freifunk-generic: show warning when no root password is set
[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 $Id: header.htm 4079 2009-01-17 17:59:11Z Cyrus $
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 = luci.model.uci.cursor():get_all("freifunk", "community")
26
27 if c and c.name then
28 community = c.name
29 else
30 community = "Freifunk"
31 end
32
33 if c and c.homepage then
34 homepage = c.homepage
35 else
36 homepage = "http://freifunk.net"
37 end
38
39 local c = tree
40 for i,r in ipairs(request) do
41 if c.nodes and c.nodes[r] then
42 c = c.nodes[r]
43 c._menu_selected = true
44 end
45 end
46
47 require("luci.i18n").loadc("default")
48 require("luci.http").prepare_content("application/xhtml+xml")
49
50 -%>
51
52 <?xml version="1.0" encoding="utf-8"?>
53 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
54 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<%=luci.i18n.context.lang%>" lang="<%=luci.i18n.context.lang%>">
55 <head>
56 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
57 <meta http-equiv="Content-Script-Type" content="text/javascript" />
58 <link rel="stylesheet" type="text/css" media="screen" href="<%=media%>/cascade.css" />
59 <!--[if IE 7]><link rel="stylesheet" type="text/css" media="screen" href="<%=media%>/ie7.css" /><![endif]-->
60 <% if node and node.css then %><link rel="stylesheet" type="text/css" media="screen" href="<%=resource%>/<%=node.css%>" />
61 <% end -%>
62 <script type="text/javascript" src="<%=resource%>/xhr.js"></script>
63
64 <title><%=striptags( hostname .. ( (node and node.title) and ' - ' .. node.title or '')) %> - LuCI</title>
65 </head>
66
67 <body class="lang_<%=luci.i18n.context.lang%>">
68
69 <div class="wrapper">
70
71 <!--[if lt IE 7]>
72 <div class="warning"><div style="background-color: #cccccc;padding: 2px 10px 2px 10px">
73 <%: 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.%>
74 </div></div>
75 <![endif]-->
76
77 <%- if luci.sys.user.getuser("root") and not luci.sys.user.getpasswd("root") then -%>
78 <div class="warning">
79 <strong><%:No password set!%></strong><br />
80 <%:There is no password set on this router. Please configure a root password to protect the web interface and enable SSH.%>
81 </div>
82 <%- end -%>
83
84 <p class="skiplink">
85 <span id="skiplink1"><a href="#navigation"><%:skiplink1 Skip to navigation%></a></span>
86 <span id="skiplink2"><a href="#content"><%:skiplink2 Skip to content%></a></span>
87 </p>
88
89 <div id="header">
90 <span id="header_left">
91 <a href="<%=homepage%>"><img src="/luci-static/freifunk-generic/logo.jpg" alt="FF Logo" /></a>
92 <a href="<%=homepage%>"><%=community%></a>
93 </span>
94 <p>
95 <%=luci.version.distversion%><br />
96 <%:Load%>: <%="%.2f" % load1%> <%="%.2f" % load5%> <%="%.2f" % load15%><br />
97 <%:Hostname%>: <%=hostname%><br />
98 </p>
99 </div>
100
101 <div id="menubar">
102 <h2 class="navigation"><a id="navigation" name="navigation"><%:navigation Navigation%></a></h2>
103 <ul id="mainmenu" class="dropdowns">
104 <%-
105 local function submenu(prefix, node)
106 if not node.nodes or node.hidden then
107 return false
108 end
109 local index = {}
110 local count = 0
111 for k, n in pairs(node.nodes) do
112 if n.title and n.target then
113 table.insert(index, {name=k, order=n.order or 100})
114 count = count + 1
115 end
116 end
117
118 table.sort(index, function(a, b) return a.order < b.order end)
119
120 if count > 0 then
121 %>
122 <ul id="submenu_<%=string.gsub(string.gsub(prefix, "/", "_"), "^_(.-)_$", "%1")%>">
123 <%-
124 for j, v in pairs(index) do
125 if #v.name > 0 then
126 local nnode = node.nodes[v.name]
127 local href = controller .. prefix .. v.name .. "/"
128 href = (nnode.query) and href .. luci.http.build_querystring(nnode.query) or href
129 %>
130 <li><a<% if nnode._menu_selected then %> class="active"<%end%> href="<%=luci.util.pcdata(href)%>"><%=nnode.title%></a><%-
131 submenu(prefix .. v.name .. "/", nnode)
132 %></li>
133 <%-
134 end
135 end
136 %>
137 </ul>
138 <%
139 end
140 end
141
142 if cattree and cattree.nodes then
143 local index = {}
144 for k, node in pairs(cattree.nodes) do
145 table.insert(index, {name=k, order=node.order or 100})
146 end
147
148 table.sort(index, function(a, b) return a.order < b.order end)
149
150 for i, k in ipairs(index) do
151 node = cattree.nodes[k.name]
152 if node.title and node.target and not node.hidden then
153 local href = controller.."/"..category.."/"..k.name.."/"
154 href = (k.query) and href .. luci.http.build_querystring(k.query) or href
155 %>
156 <li><a<% if node._menu_selected then %> class="preactive"<%end%> href="<%=href%>"><%=node.title%></a><%
157 submenu("/" .. category .. "/" .. k.name .. "/", node)
158 %></li><% end
159 end
160 end
161 %>
162 </ul>
163
164 <ul id="modemenu"><%
165 for k,node in pairs(tree.nodes) do
166 if node.title and not node.hidden then %>
167 <li><a<% if request[1] == k then %> class="active"<%end%> href="<%=controller%>/<%=k%>/"><%=node.title%></a></li><%
168 end
169 end
170 %>
171 </ul>
172
173 <%
174 if tree.nodes[category] and tree.nodes[category].ucidata then
175 local ucic = 0
176 for i, j in pairs(require("luci.model.uci").cursor():changes()) do
177 for k, l in pairs(j) do
178 for m, n in pairs(l) do
179 ucic = ucic + 1;
180 end
181 end
182 end
183 -%>
184
185 <div id="savemenu">
186 <% if ucic > 0 then %>
187 <a class="warning" href="<%=controller%>/<%=category%>/uci/changes/?redir=<%=luci.http.urlencode(tree.nodes[category].nodes["uci"].query)%>"><%:Unsaved Changes%>: <%=ucic%></a>
188 <% end -%>
189 </div><% end %>
190
191 <div class="clear"></div>
192 </div>
193 <div id="maincontent">
194 <% if category ~= "freifunk" and category ~= "splash" then %>
195 <noscript>
196 <div class="errorbox">
197 <strong><%:Java Script required!%></strong><br />
198 <%:You must enable Java Script in your browser or LuCI will not work properly.%>
199 </div>
200 </noscript>
201 <% end %>