header.htm 4.5 KB

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