themes/freifunk: port to updated dispatcher api
[project/luci.git] / themes / freifunk / luasrc / view / themes / freifunk / 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 -%>
13 <%
14 local sys = require "luci.sys"
15 local http = require "luci.http"
16 local disp = require "luci.dispatcher"
17
18 local hostname = sys.hostname()
19 local load1, load5, load15 = sys.loadavg()
20
21 local request = disp.context.path
22 local category = request[1]
23 local cattree = category and disp.node(category)
24
25 local tree = disp.node()
26 local node = disp.context.dispatched
27
28 local categories = disp.node_childs(tree)
29
30 local c = tree
31 local i, r
32
33 -- tag all nodes leading to this page
34 for i, r in ipairs(request) do
35 if c.nodes and c.nodes[r] then
36 c = c.nodes[r]
37 c._menu_selected = true
38 end
39 end
40
41 http.prepare_content("text/html")
42 -%>
43
44 <?xml version="1.0" encoding="utf-8"?>
45 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
46 <html xmlns="http://www.w3.org/1999/xhtml">
47 <head>
48 <link rel="stylesheet" type="text/css" href="<%=media%>/cascade.css" />
49 <% if node and node.css then %><link rel="stylesheet" type="text/css" href="<%=resource%>/<%=node.css%>" /><% end %>
50 <link rel="shortcut icon" href="<%=media%>/images/favicon.ico" />
51 <meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />
52 <meta http-equiv="content-script-type" content="text/javascript" />
53 <script type="text/javascript" src="<%=resource%>/xhr.js"></script>
54 <title><%=striptags( hostname .. ( (node and node.title) and ' - ' .. translate(node.title) or '')) %> - LuCI</title>
55
56 <!--[if lt IE 7]>
57 <script type="text/javascript">
58 function setup_hover() {
59 function ie_hover(e) {
60 e.onmouseover = function() { this.className = "hover" }
61 e.onmouseout = function() { this.className = null }
62 }
63
64 var lis = document.getElementById("mainmenu").getElementsByTagName("LI");
65 var divs = document.getElementById("mainmenu").getElementsByTagName("DIV");
66
67 for( var i = 0; i < lis.length; i++ ) ie_hover( lis[i] );
68 for( var i = 0; i < divs.length; i++ ) ie_hover( divs[i] );
69 }
70 </script>
71 <![endif]-->
72 </head>
73 <body onload="if (window.setup_hover) setup_hover()">
74 <div id="all">
75 <center>
76
77 <div id="wrapper">
78 <%- if luci.sys.user.getuser("root") and not luci.sys.user.getpasswd("root") then -%>
79 <div class="warning">
80 <strong><%:No password set!%></strong><br />
81 <%:There is no password set on this router. Please configure a root password to protect the web interface and enable SSH.%>
82 </div>
83 <%- end -%>
84 <div id="main">
85
86
87 <div id="header">
88 <div id="headerleft">
89 <div id="headerright">
90 <div id="headerback">
91 <div id="schriftzug"><img src="<%=media%>/images/schriftzug.png" alt="Freifunk ueberschrift" name="Freifunk_nordost_ueberschrift" border="0"> </div>
92 <div id="logo"><img src="<%=media%>/images/logo.png" alt="Freifunk logo" name="Freifunk_nordost" border="0"></a></div>
93 <div class="clear"></div>
94
95 </div>
96 </div>
97 </div>
98 </div>
99
100 <div class="pathbar separator black whitetext bold">
101 <%:Path%>:
102 <%
103 local c = tree
104 local url = controller
105 for i, r in ipairs(request) do
106 if c.nodes and c.nodes[r] then
107 c = c.nodes[r]
108 url = url .. "/" .. r
109 %>
110 <a href="<%=url%>"><%=pcdata(striptags(translate(c.title) or v))%></a>
111 <% if k ~= #request then %> &#187; <% end %>
112 <%
113 end
114 end
115 %>
116 </div>
117
118 <div class="menubar">
119 <div id="mainmenu" class="mainmenu">
120 <%-
121 local function submenu(prefix, node)
122 local childs = disp.node_childs(node)
123 if #childs > 0 then
124 %>
125 <ul>
126 <%-
127 for i, r in ipairs(childs) do
128 local nnode = node.nodes[r]
129 local href = controller .. prefix .. r ..
130 (nnode.query and http.build_querystring(nnode.query) or "")
131 %>
132 <li>
133 <span<%=ifattr(nnode._menu_selected, "class", "active")%>>
134 <a href="<%=pcdata(href)%>"><%=pcdata(striptags(translate(nnode.title)))%></a>
135 </span>
136 <%- submenu(prefix .. r .. "/", nnode) %>
137 </li>
138 <%-
139 end
140 %>
141 </ul>
142 <%-
143 end
144 end
145
146
147 childs = disp.node_childs(cattree)
148
149 if #childs > 0 then
150 for i, r in ipairs(childs) do
151 local nnode = cattree.nodes[r]
152 local href = controller .. "/" .. category .. "/" .. r ..
153 (nnode.query and http.build_querystring(k.query) or "")
154 %>
155 <div<%=ifattr(nnode._menu_selected, "class", "preactive")%>>
156 <a href="<%=pcdata(href)%>"><%=pcdata(striptags(translate(nnode.title)))%></a>
157 <%- submenu("/" .. category .. "/" .. r .. "/", nnode) %>
158 </div>
159 <%
160 end
161 end
162 %>
163 </div>
164
165 <% if #categories > 1 then %>
166 <div class="modemenu">
167 <ul>
168 <% for i, r in ipairs(categories) do %>
169 <li><a<%=ifattr(request[1] == r, "class", "active")%> href="<%=controller%>/<%=r%>/"><%=striptags(translate(tree.nodes[r].title))%></a></li>
170 <% end %>
171 </ul>
172 </div>
173 <% end %>
174
175 <%
176 if tree.nodes[category] and tree.nodes[category].ucidata then
177 local ucic = 0
178
179 for i, j in pairs(require("luci.model.uci").cursor():changes()) do
180 for k, l in pairs(j) do
181 for m, n in pairs(l) do
182 ucic = ucic + 1;
183 end
184 end
185 end
186 %>
187 <div class="mainmenu" style="float:right; margin-right:2em">
188 <div>
189 <% if ucic > 0 then %>
190 <a class="warning" href="<%=controller%>/<%=category%>/uci/changes"><%:Unsaved Changes%>: <%=ucic%></a>
191 <% submenu("/" .. category .. "/uci/", tree.nodes[category].nodes["uci"]) -%>
192 <% else %>
193 <a href="#"><%:Changes%>: 0</a>
194 <% end %>
195 </div>
196 </div>
197 <% end %>
198
199 <br class="clear" />
200 </div>
201 <div id="maincontent">
202 <% if category ~= "freifunk" and category ~= "splash" then %>
203 <noscript>
204 <div class="warning">
205 <strong><%:Java Script required!%></strong><br />
206 <%:You must enable Java Script in your browser or LuCI will not work properly.%>
207 </div>
208 </noscript>
209 <%end%>