From 5db4463acec5a672c4e4fcb7c91fb93af8e43387 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sun, 1 Dec 2019 20:11:37 +0100 Subject: luci-theme-bootstrap: render menu on client side Signed-off-by: Jo-Philipp Wich --- .../luasrc/view/themes/bootstrap/footer.htm | 19 +--- .../luasrc/view/themes/bootstrap/header.htm | 119 +-------------------- .../luasrc/view/themes/bootstrap/json-menu.htm | 119 +++++++++++++++++++++ 3 files changed, 126 insertions(+), 131 deletions(-) create mode 100644 themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap/json-menu.htm (limited to 'themes/luci-theme-bootstrap') diff --git a/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap/footer.htm b/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap/footer.htm index e0a41e1bc..ec6895f06 100644 --- a/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap/footer.htm +++ b/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap/footer.htm @@ -5,25 +5,12 @@ Licensed to the public under the Apache License 2.0. -%> -<% - local ver = require "luci.version" - local disp = require "luci.dispatcher" - local request = disp.context.path - local category = request[1] - local tree = disp.node() - local categories = disp.node_childs(tree) -%> +<% local ver = require "luci.version" %> + - 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 de1fd73f0..56a1b230e 100644 --- a/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap/header.htm +++ b/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap/header.htm @@ -13,123 +13,10 @@ local boardinfo = util.ubus("system", "board") - 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 - -- send as HTML5 http.prepare_content("text/html") - - 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_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 - write('') - end - - if selected_node then - render_tabmenu(prefix .. "/" .. selected_name, selected_node, level + 1) - end - end - end - - local function render_submenu(prefix, node) - local childs = disp.node_childs(node) - if #childs > 0 then - write('') - end - end - - local function render_topmenu() - local childs = disp.node_childs(cattree) - if #childs > 0 then - write('') - end - end -%> @@ -149,6 +36,8 @@ + + <% include("themes/bootstrap/json-menu") %> "> @@ -156,7 +45,7 @@
<%=boardinfo.hostname or "?"%> - <% render_topmenu() %> +
- <% if category then render_tabmenu(category, cattree) end %> + diff --git a/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap/json-menu.htm b/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap/json-menu.htm new file mode 100644 index 000000000..b38406f65 --- /dev/null +++ b/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap/json-menu.htm @@ -0,0 +1,119 @@ + -- cgit v1.2.3