* Separated the MVC-Webframework from core
[project/luci.git] / web / src / view / header.htm
1 <%
2 require("luci.sys")
3 local load1, load5, load15 = luci.sys.loadavg()
4
5 local request  = require("luci.dispatcher").request
6 local category = request[1]
7 local tree     = luci.dispatcher.node()
8 local cattree  = category and luci.dispatcher.node(category)
9 local node     = luci.dispatcher.dispatched 
10
11 local c = tree
12 for i,r in ipairs(request) do
13         if c.nodes and c.nodes[r] then 
14                 c = c.nodes[r]
15                 c._menu_selected = true
16         end
17 end
18
19 require("luci.i18n").loadc("default")
20
21 require("luci.http").prepare_content("text/html")
22 %><?xml version="1.0" encoding="utf-8"?>
23 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
24 <html xmlns="http://www.w3.org/1999/xhtml">
25 <head>
26         <link rel="stylesheet" type="text/css" href="<%=media%>/cascade.css" />
27         <% if node and node.css then %><link rel="stylesheet" type="text/css" href="<%=resource%>/<%=node.css%>" /><% end %>
28         <meta http-equiv="content-type" content="text/xhtml+xml; charset=utf-8" />
29         <meta http-equiv="content-script-type" content="text/javascript" />
30         <title>LuCI - Lua Configuration Interface</title>
31 </head>
32 <body>
33 <div id="header">
34         <div class="headerlogo left"><img src="<%=media%>/logo.png" alt="<%=luci.config.brand.title%>" /></div>
35         <div class="whitetext smalltext right">
36         <%=luci.config.brand.firmware%><br />
37         <%=luci.config.brand.distro%><br />
38         <%:load Last%>: <%=load1%> <%=load5%> <%=load15%><br />
39         <%:hostname Hostname%>: <%=luci.sys.hostname()%> 
40         </div>
41         <div>
42                 <span class="headertitle"><%=luci.config.brand.title%></span><br />
43                 <span class="whitetext bold"><%=luci.config.brand.subtitle%></span>
44         </div>
45 </div>
46
47 <div class="separator yellow bold">
48 <%:path Pfad%>: <% 
49 local c = tree
50 local url = controller
51 for k,v in pairs(request) do
52         if c.nodes and c.nodes[v] then
53                 c = c.nodes[v]
54                 url = url .. "/" .. v
55         %><a href="<%=url%>"><%=c.title or v%></a> <% if k ~= #request then %>&#187; <% end
56         end
57 end
58 %>
59 </div>
60
61 <div id="columns"><div id="columnswrapper">
62         <div class="sidebar left">
63 <%
64 local function submenu(prefix, node)
65         if not node._menu_selected or not node.nodes then
66                 return false
67         end
68         local index = {}        
69         for k, n in pairs(node.nodes) do
70                 table.insert(index, {name=k, order=n.order or 100})
71         end
72                 
73         table.sort(index, function(a, b) return a.order < b.order end)
74 %>
75         <ul>
76         <% for j, v in pairs(index) do 
77                 local nnode = node.nodes[v.name]%>
78                 <li>
79                         <span<% if nnode._menu_selected then %> class="yellowtext"<%end%>><a href="<%=controller .. prefix .. v.name%>"><%=nnode.title%></a></span>
80                         <% submenu(prefix .. v.name .. "/", nnode) %>
81                 </li>
82         <% end %>
83                 </ul> 
84 <%       
85 end
86
87 if cattree and cattree.nodes then
88         local index = {}        
89         for k, node in pairs(cattree.nodes) do
90                 table.insert(index, {name=k, order=node.order or 100})
91         end
92         
93         table.sort(index, function(a, b) return a.order < b.order end)
94
95         for i, k in ipairs(index) do
96                 node = cattree.nodes[k.name]
97                 if node.title then %>
98                         <div<% if node._menu_selected then %> class="yellowtext"<%end%>><a href="<%=controller%>/<%=category%>/<%=k.name%>"><%=node.title%></a>                 
99                                 <%submenu("/" .. category .. "/" .. k.name .. "/", node)%>
100                         </div>
101 <%              end
102         end
103 end
104 %>              
105         </div>
106         <div class="sidebar right">
107                 <div><%:webif Weboberfläche%>
108                         <ul><%
109                                 for k,node in pairs(tree.nodes) do
110                                         if node.title then %>
111                                                 <li<% if request[1] == k then %> class="yellowtext"<%end%>><a href="<%=controller%>/<%=k%>"><%=node.title%></a></li>
112 <%                                      end
113                                 end%>
114                         </ul>
115                 </div>
116                 <%
117                         if "admin" == request[1] then
118                                 require("luci.model.uci") 
119                                 local ucic = luci.model.uci.changes()
120                                 if ucic then
121                                         ucic = #luci.util.split(ucic)
122                                 end
123                 %>
124                 <div><%:config Konfiguration%>
125                         <ul>
126                         <% if ucic then %>
127                                 <li><a href="<%=controller%>/admin/uci/changes"><%:changes Änderungen%>: <%=ucic%></a></li>
128                                 <li><a href="<%=controller%>/admin/uci/apply"><%:apply Anwenden%></a></li>
129                                 <li><a href="<%=controller%>/admin/uci/revert"><%:revert Verwerfen%></a></li>
130                         <% else %>
131                                 <li><%:changes Änderungen%>: 0</li>
132                         <% end %>
133                         </ul>
134                 </div>
135                 <% end %>
136         </div>
137         <div id="content">