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