header.htm 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <%#
  2. LuCI - Lua Configuration Interface
  3. Copyright 2008 Steven Barth <steven@midlink.org>
  4. Copyright 2008-2010 Jo-Philipp Wich <xm@subsignal.org>
  5. Licensed under the Apache License, Version 2.0 (the "License");
  6. you may not use this file except in compliance with the License.
  7. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. $Id$
  10. -%>
  11. <%
  12. local sys = require "luci.sys"
  13. local http = require "luci.http"
  14. local disp = require "luci.dispatcher"
  15. local uci = require("simple-uci").cursor()
  16. local fs = require "nixio.fs"
  17. local gluon_luci = require "gluon.luci"
  18. local pretty_hostname = require "pretty_hostname"
  19. local hostname = pretty_hostname.get(uci)
  20. local release = fs.readfile("/lib/gluon/release")
  21. local request = disp.context.path
  22. local request2 = disp.context.request
  23. local category = request[1]
  24. local cattree = category and disp.node(category)
  25. local leaf = request2[#request2]
  26. local tree = disp.node()
  27. local node = disp.context.dispatched
  28. local categories = disp.node_childs(tree)
  29. local c = tree
  30. local i, r
  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. http.prepare_content("application/xhtml+xml")
  39. local function nodeurl(prefix, name, query)
  40. local url = controller .. prefix .. name .. "/"
  41. if query then
  42. url = url .. http.build_querystring(query)
  43. end
  44. return pcdata(url)
  45. end
  46. local function subtree(prefix, node, level)
  47. if not level then
  48. level = 1
  49. end
  50. local childs = disp.node_childs(node)
  51. if #childs > 0 then
  52. %>
  53. <div class="tabmenu<%=level%>">
  54. <ul class="tabmenu l<%=level%>">
  55. <%
  56. local selected_node
  57. local selected_name
  58. local i, v
  59. for i, v in ipairs(childs) do
  60. local nnode = node.nodes[v]
  61. if nnode._menu_selected then
  62. selected_node = nnode
  63. selected_name = v
  64. end
  65. %>
  66. <li class="tabmenu-item-<%=v%><% if nnode._menu_selected or (node.leaf and v == leaf) then %> active<% end %>">
  67. <a href="<%=nodeurl(prefix, v, nnode.query)%>"><%=striptags(translate(nnode.title))%></a>
  68. </li>
  69. <%
  70. end
  71. %>
  72. </ul>
  73. <br style="clear:both" />
  74. <%
  75. if selected_node then
  76. subtree(prefix .. selected_name .. "/", selected_node, level + 1)
  77. end
  78. %>
  79. </div>
  80. <%
  81. end
  82. end
  83. -%>
  84. <?xml version="1.0" encoding="utf-8"?>
  85. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  86. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<%=luci.i18n.context.lang%>" lang="<%=luci.i18n.context.lang%>">
  87. <head>
  88. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  89. <meta http-equiv="Content-Script-Type" content="text/javascript" />
  90. <link rel="stylesheet" type="text/css" media="screen" href="<%=media%>/cascade.css" />
  91. <% if node and node.css then %><link rel="stylesheet" type="text/css" media="screen" href="<%=resource%>/<%=node.css%>" />
  92. <% end -%>
  93. <% if css then %><style title="text/css">
  94. <%= css %>
  95. </style>
  96. <% end -%>
  97. <script type="text/javascript" src="<%=resource%>/xhr.js"></script>
  98. <title><%=gluon_luci.escape( hostname .. ( (node and node.title) and ' - ' .. translate(node.title) or '')) %> - LuCI</title>
  99. </head>
  100. <body class="lang_<%=luci.i18n.context.lang%>">
  101. <div id="menubar">
  102. <div class="hostinfo">
  103. <%=gluon_luci.escape(hostname)%>
  104. <% if release then %>
  105. / <%=gluon_luci.escape(release)%>
  106. <% end %>
  107. <span id="xhr_poll_status" style="display:none" onclick="XHR.running() ? XHR.halt() : XHR.run()">
  108. | <%:Auto Refresh%>:
  109. <span id="xhr_poll_status_on"><%:on%></span>
  110. <span id="xhr_poll_status_off" style="display:none"><%:off%></span>
  111. </span>
  112. </div>
  113. <% if #categories > 1 then %>
  114. <ul id="modemenu">
  115. <% for i, r in ipairs(categories) do %>
  116. <li><a<% if request[1] == r then %> class="active"<%end%> href="<%=controller%>/<%=r%>/"><%=striptags(translate(tree.nodes[r].title))%></a></li>
  117. <% end %>
  118. </ul>
  119. <% end %>
  120. <%
  121. if tree.nodes[category] and tree.nodes[category].ucidata then
  122. local ucic = 0
  123. for i, j in pairs(require("simple-uci").cursor():changes()) do
  124. for k, l in pairs(j) do
  125. for m, n in pairs(l) do
  126. ucic = ucic + 1;
  127. end
  128. end
  129. end
  130. -%>
  131. <div id="savemenu">
  132. <% if ucic > 0 then %>
  133. <a class="warning" href="<%=controller%>/<%=category%>/uci/changes/?redir=<%=luci.http.urlencode(luci.http.formvalue("redir") or REQUEST_URI)%>"><%:Unsaved Changes%>: <%=ucic%></a>
  134. <%- else -%>
  135. <a href="#"><%:Changes%>: 0</a>
  136. <% end -%>
  137. </div><% end %>
  138. </div>
  139. <div id="maincontainer">
  140. <% if category then subtree("/" .. category .. "/", cattree) end %>
  141. <div id="maincontent">
  142. <noscript>
  143. <div class="errorbox">
  144. <strong><%:Java Script required!%></strong><br />
  145. <%:You must enable Java Script in your browser or LuCI will not work properly.%>
  146. </div>
  147. </noscript>