From b3c69b123a698e596a5df4797378d976718247f0 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sun, 17 Jan 2016 17:59:37 +0100 Subject: luci-theme-bootstrap: fix menu url generation (#625) Also untangle Lua code and markup for better readability, use tabs for indentation and build_url() to construct paths instead of concatenating them manually. Signed-off-by: Jo-Philipp Wich --- .../luasrc/view/themes/bootstrap/header.htm | 238 +++++++++++---------- 1 file changed, 120 insertions(+), 118 deletions(-) (limited to 'themes') diff --git a/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap/header.htm b/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap/header.htm index 3b40ad438..d4d0a2b12 100644 --- a/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap/header.htm +++ b/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap/header.htm @@ -1,6 +1,6 @@ <%# Copyright 2008 Steven Barth - Copyright 2008 Jo-Philipp Wich + Copyright 2008-2016 Jo-Philipp Wich Copyright 2012 David Menting Licensed to the public under the Apache License 2.0. -%> @@ -36,31 +36,28 @@ c._menu_selected = true end end - - -- send as HTML5 + + -- send as HTML5 http.prepare_content("text/html") local function nodeurl(prefix, name, query) - local url = controller .. prefix .. name .. "/" + local u = url(prefix, name) if query then - url = url .. http.build_querystring(query) + u = u .. http.build_querystring(query) end - return pcdata(url) + return pcdata(u) end - local function subtree(prefix, node, level) + local function render_tabmenu(prefix, node, level) if not level then level = 1 end local childs = disp.node_childs(node) if #childs > 0 then - - if level > 2 then -%> -
    - <% - end + if level > 2 then + write('
      ') + end local selected_node local selected_name @@ -72,99 +69,70 @@ selected_node = nnode selected_name = v end - if level > 2 then - %> -
    • - <%=striptags(translate(nnode.title))%> -
    • - <% end + + if level > 2 then + write('
    • %s
    • ' %{ + v, (nnode._menu_selected or (node.leaf and v == leaf)) and 'active' or '', + nodeurl(prefix, v, nnode.query), + striptags(translate(nnode.title)) + }) + end + end + + if level > 2 then + write('
    ') end - - if level > 2 then - %> -
-<% end if selected_node then - subtree(prefix .. selected_name .. "/", selected_node, level + 1) + render_tabmenu(prefix .. "/" .. selected_name, selected_node, level + 1) end end end --%> - - - - - <%=striptags( (boardinfo.hostname or "?") .. ( (node and node.title) and ' - ' .. translate(node.title) or '')) %> - LuCI - - - - - - <% if node and node.css then %> - <% end -%> - <% if css then %> - <% end -%> - - - - -
-
-
- <%=boardinfo.hostname or "?"%> - + end - <% - -- calculate the number of unsaved changes + local function render_changes() + -- calculate the number of unsaved changes if tree.nodes[category] and tree.nodes[category].ucidata then local ucichanges = 0 @@ -175,30 +143,64 @@ end end end - %> -
- <% if ucichanges > 0 then %> - "><%:Unsaved Changes%>: <%=ucichanges%> - <% end %> - -
- <% end %> -
-
-
- -<%- if luci.sys.process.info("uid") == 0 and luci.sys.user.getuser("root") and not luci.sys.user.getpasswd("root") then -%> -
-
-

<%:No password set!%>

- <%:There is no password set on this router. Please configure a root password to protect the web interface and enable SSH.%>
- "><%:Go to password configuration...%> -
-
-<%- end -%> - -
-<% if category then subtree("/" .. category .. "/", cattree) end %> + + if ucichanges > 0 then + write('%s: %d' %{ + url(category, 'uci/changes'), + http.urlencode(http.formvalue('redir') or REQUEST_URI), + translate('Unsaved Changes'), + ucichanges + }) + end + end + end +-%> + + + + + <%=striptags( (boardinfo.hostname or "?") .. ( (node and node.title) and ' - ' .. translate(node.title) or '')) %> - LuCI + + + + + + <% if node and node.css then %> + + <% end -%> + <% if css then %> + + <% end -%> + + + + + +
+
+
+ <%=boardinfo.hostname or "?"%> + <% render_topmenu() %> +
+ <% render_changes() %> + +
+
+
+
+ + <%- if luci.sys.process.info("uid") == 0 and luci.sys.user.getuser("root") and not luci.sys.user.getpasswd("root") then -%> +
+
+

<%:No password set!%>

+ <%:There is no password set on this router. Please configure a root password to protect the web interface and enable SSH.%>
+ "><%:Go to password configuration...%> +
+
+ <%- end -%> + +
+ <% if category then render_tabmenu(category, cattree) end %> -- cgit v1.2.3