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