From bf48a64dfdba3d363bb94fffbcbc8b436cd529ec Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sun, 1 Dec 2019 20:18:21 +0100 Subject: [PATCH] luci-theme-openwrt: render menu on client side Signed-off-by: Jo-Philipp Wich (cherry picked from commit ebc99a6ab30d1b563b1e073df93006504cdc80ae) --- .../luci-static/openwrt.org/cascade.css | 4 + .../luasrc/view/themes/openwrt.org/header.htm | 285 +++++++++--------- 2 files changed, 143 insertions(+), 146 deletions(-) diff --git a/themes/luci-theme-openwrt/htdocs/luci-static/openwrt.org/cascade.css b/themes/luci-theme-openwrt/htdocs/luci-static/openwrt.org/cascade.css index f59958494..a1b85f658 100644 --- a/themes/luci-theme-openwrt/htdocs/luci-static/openwrt.org/cascade.css +++ b/themes/luci-theme-openwrt/htdocs/luci-static/openwrt.org/cascade.css @@ -1016,6 +1016,10 @@ ul.cbi-tabmenu { border-bottom: 1px solid #bbb; } +#tabmenu > ul.cbi-tabmenu { + margin: 0 !important; +} + ul.cbi-tabmenu li { display: inline-flex; margin: 0 5px -1px 0; diff --git a/themes/luci-theme-openwrt/luasrc/view/themes/openwrt.org/header.htm b/themes/luci-theme-openwrt/luasrc/view/themes/openwrt.org/header.htm index e5a69f8a6..0a29f3ad3 100644 --- a/themes/luci-theme-openwrt/luasrc/view/themes/openwrt.org/header.htm +++ b/themes/luci-theme-openwrt/luasrc/view/themes/openwrt.org/header.htm @@ -15,116 +15,9 @@ local loadinfo = sysinfo.load or { 0, 0, 0 } local boardinfo = util.ubus("system", "board") or { } - local request = disp.context.path - local request2 = disp.context.request - - local category = request[1] - local cattree = category and disp.node(category) - - local leaf = request2[#request2] - - local tree = disp.node() local node = disp.context.dispatched - local categories = disp.node_childs(tree) - - local c = tree - local i, r - - -- tag all nodes leading to this page - for i, r in ipairs(request) do - if c.nodes and c.nodes[r] then - c = c.nodes[r] - c._menu_selected = true - end - end - http.prepare_content("application/xhtml+xml") - - local function nodeurl(prefix, name, query) - local u = url(prefix, name) - if query then - u = u .. http.build_querystring(query) - end - return pcdata(u) - end - - local function render_menu(prefix, node, level) - if not level then - level = 1 - end - - local childs = disp.node_childs(node) - if #childs > 0 then - write('') - end - end - - 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 - if level == 3 then - write('
') - end - write('
    ') - end - - local selected_node - local selected_name - local i, v - - for i, v in ipairs(childs) do - local nnode = node.nodes[v] - if nnode._menu_selected then - selected_node = nnode - selected_name = v - end - - if level > 2 then - write('
  • %s
  • ' %{ - v, (nnode._menu_selected or (node.leaf and v == leaf)) and 'cbi-tab' or '', - nodeurl(prefix, v, nnode.query), - striptags(translate(nnode.title)) - }) - end - end - - if level > 2 then - write('
') - if level == 3 then - write('
') - end - end - - if selected_node then - render_tabmenu(prefix .. "/" .. selected_name, selected_node, level + 1) - end - end - end -%> @@ -145,45 +38,153 @@ <%=striptags( (boardinfo.hostname or "?") .. ( (node and node.title) and ' - ' .. translate(node.title) or '')) %> - LuCI @@ -207,24 +208,16 @@ -<% if #categories > 1 then %> - -<% end %> +
- +
- <% if category then render_tabmenu(category, cattree) end %> +