51505d081f8fa70a5af678a9b2d74c7f43bbed4b
[project/luci.git] / themes / luci-theme-openwrt / luasrc / view / themes / openwrt.org / header.htm
1 <%#
2  Copyright 2008 Steven Barth <steven@midlink.org>
3  Copyright 2008-2010 Jo-Philipp Wich <jow@openwrt.org>
4  Licensed to the public under the Apache License 2.0.
5 -%>
6
7 <%
8         local sys  = require "luci.sys"
9         local util = require "luci.util"
10         local http = require "luci.http"
11         local disp = require "luci.dispatcher"
12
13         local sysinfo = util.ubus("system", "info") or { }
14         local loadinfo = sysinfo.load or { 0, 0, 0 }
15         local boardinfo = util.ubus("system", "board") or { }
16
17         local request  = disp.context.path
18         local request2 = disp.context.request
19
20         local category = request[1]
21         local cattree  = category and disp.node(category)
22
23         local leaf = request2[#request2]
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("application/xhtml+xml")
42
43         local function nodeurl(prefix, name, query)
44                 local url = controller .. prefix .. name .. "/"
45                 if query then
46                         url = url .. http.build_querystring(query)
47                 end
48                 return pcdata(url)
49         end
50
51         local function subtree(prefix, node, level)
52                 if not level then
53                         level = 1
54                 end
55
56                 local childs = disp.node_childs(node)
57                 if #childs > 0 then
58 %>
59         <div class="tabmenu<%=level%>">
60         <ul class="tabmenu l<%=level%>">
61                 <%
62                         local selected_node
63                         local selected_name
64                         local i, v
65
66                         for i, v in ipairs(childs) do
67                                 local nnode = node.nodes[v]
68                                 if nnode._menu_selected then
69                                         selected_node = nnode
70                                         selected_name = v
71                                 end
72                 %>
73                         <li class="tabmenu-item-<%=v%><% if nnode._menu_selected or (node.leaf and v == leaf) then %> active<% end %>">
74                                 <a href="<%=nodeurl(prefix, v, nnode.query)%>"><%=striptags(translate(nnode.title))%></a>
75                         </li>
76                 <%
77                         end
78                 %>
79         </ul>
80         <br style="clear:both" />
81 <%
82                         if selected_node then
83                                 subtree(prefix .. selected_name .. "/", selected_node, level + 1)
84                         end
85 %>
86         </div>
87 <%
88                 end
89         end
90 -%>
91
92 <?xml version="1.0" encoding="utf-8"?>
93 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
94 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<%=luci.i18n.context.lang%>" lang="<%=luci.i18n.context.lang%>">
95 <head>
96 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
97 <meta http-equiv="Content-Script-Type" content="text/javascript" />
98 <link rel="stylesheet" type="text/css" media="screen" href="<%=media%>/cascade.css" />
99 <!--[if IE 6]><link rel="stylesheet" type="text/css" media="screen" href="<%=media%>/ie6.css" /><![endif]-->
100 <!--[if IE 7]><link rel="stylesheet" type="text/css" media="screen" href="<%=media%>/ie7.css" /><![endif]-->
101 <!--[if IE 8]><link rel="stylesheet" type="text/css" media="screen" href="<%=media%>/ie8.css" /><![endif]-->
102 <% if node and node.css then %><link rel="stylesheet" type="text/css" media="screen" href="<%=resource%>/<%=node.css%>" />
103 <% end -%>
104 <% if css then %><style title="text/css">
105 <%= css %>
106 </style>
107 <% end -%>
108 <script type="text/javascript" src="<%=resource%>/xhr.js"></script>
109 <title><%=striptags( (boardinfo.hostname or "?") .. ( (node and node.title) and ' - ' .. translate(node.title) or '')) %> - LuCI</title>
110 </head>
111 <body class="lang_<%=luci.i18n.context.lang%>">
112
113 <p class="skiplink">
114 <span id="skiplink1"><a href="#navigation"><%:Skip to navigation%></a></span>
115 <span id="skiplink2"><a href="#content"><%:Skip to content%></a></span>
116 </p>
117
118 <div id="menubar">
119 <h2 class="navigation"><a id="navigation" name="navigation"><%:Navigation%></a></h2>
120
121 <div class="hostinfo">
122         <%=(boardinfo.hostname or "?")%> | <%=luci.version.distversion%> |
123         <%:Load%>: <%="%.2f" % loadinfo[1] / 65535.0%> <%="%.2f" % loadinfo[2] / 65535.0%> <%="%.2f" % loadinfo[3] / 65535.0%>
124         <span id="xhr_poll_status" style="display:none" onclick="XHR.running() ? XHR.halt() : XHR.run()">
125                 | <%:Auto Refresh%>:
126                 <span id="xhr_poll_status_on"><%:on%></span>
127                 <span id="xhr_poll_status_off" style="display:none"><%:off%></span>
128         </span>
129 </div>
130
131 <% if #categories > 1 then %>
132         <ul id="modemenu">
133                 <% for i, r in ipairs(categories) do %>
134                         <li><a<% if request[1] == r then %> class="active"<%end%> href="<%=controller%>/<%=r%>/"><%=striptags(translate(tree.nodes[r].title))%></a></li>
135                 <% end %>
136         </ul>
137 <% end %>
138
139 <%
140 if tree.nodes[category] and tree.nodes[category].ucidata then
141         local ucic = 0
142         for i, j in pairs(require("luci.model.uci").cursor():changes()) do
143                 for k, l in pairs(j) do
144                         for m, n in pairs(l) do
145                                 ucic = ucic + 1;
146                         end
147                 end
148         end
149 -%>
150 <div id="savemenu">
151         <% if ucic > 0 then %>
152                 <a class="warning" href="<%=controller%>/<%=category%>/uci/changes/?redir=<%=luci.http.urlencode(luci.http.formvalue("redir") or REQUEST_URI)%>"><%:Unsaved Changes%>: <%=ucic%></a>
153         <%- else -%>
154                 <a href="#"><%:Changes%>: 0</a>
155         <% end -%>
156 </div><% end %>
157
158 <div class="clear"></div>
159 </div>
160
161 <div id="maincontainer">
162         <div id="tabmenu">
163                 <% if category then subtree("/" .. category .. "/", cattree) end %>
164         </div>
165
166         <div id="maincontent">
167                 <noscript>
168                         <div class="errorbox">
169                                 <strong><%:Java Script required!%></strong><br />
170                                 <%:You must enable Java Script in your browser or LuCI will not work properly.%>
171                         </div>
172                 </noscript>
173
174                 <%- if luci.sys.process.info("uid") == 0 and luci.sys.user.getuser("root") and not luci.sys.user.getpasswd("root") and category ~= "failsafe" then -%>
175                 <div class="errorbox">
176                         <strong><%:No password set!%></strong><br />
177                         <%:There is no password set on this router. Please configure a root password to protect the web interface and enable SSH.%><br />
178                         <a href="<%=pcdata(luci.dispatcher.build_url("admin/system/admin"))%>"><%:Go to password configuration...%></a>
179                 </div>
180                 <%- end -%>