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