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