* libs/web: Added support for custom query strings
This commit is contained in:
parent
25ca2d2f20
commit
56a23c609c
3 changed files with 27 additions and 7 deletions
|
@ -34,3 +34,13 @@ if ENV and ENV.HASERLVER then
|
||||||
elseif webuci then
|
elseif webuci then
|
||||||
require("luci.sgi.webuci")
|
require("luci.sgi.webuci")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function build_querystring(table)
|
||||||
|
local s="?"
|
||||||
|
|
||||||
|
for k, v in pairs(table) do
|
||||||
|
s = s .. k .. "=" .. v .. "&"
|
||||||
|
end
|
||||||
|
|
||||||
|
return s
|
||||||
|
end
|
|
@ -73,9 +73,12 @@ local function submenu(prefix, node)
|
||||||
%>
|
%>
|
||||||
<ul>
|
<ul>
|
||||||
<% for j, v in pairs(index) do
|
<% for j, v in pairs(index) do
|
||||||
local nnode = node.nodes[v.name]%>
|
local nnode = node.nodes[v.name]
|
||||||
|
local href = controller .. prefix .. v.name
|
||||||
|
href = (v.query) and href .. luci.http.build_querystring(v.query) or href
|
||||||
|
%>
|
||||||
<li>
|
<li>
|
||||||
<span<% if nnode._menu_selected then %> class="yellowtext"<%end%>><a href="<%=controller .. prefix .. v.name%>"><%=nnode.title%></a></span>
|
<span<% if nnode._menu_selected then %> class="yellowtext"<%end%>><a href="<%=href%>"><%=nnode.title%></a></span>
|
||||||
<% submenu(prefix .. v.name .. "/", nnode) %>
|
<% submenu(prefix .. v.name .. "/", nnode) %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -93,7 +96,9 @@ if cattree and cattree.nodes then
|
||||||
|
|
||||||
for i, k in ipairs(index) do
|
for i, k in ipairs(index) do
|
||||||
node = cattree.nodes[k.name]
|
node = cattree.nodes[k.name]
|
||||||
if node.title then %>
|
if node.title then
|
||||||
|
local href = controller.."/"..category.."/"..k.name
|
||||||
|
href = (k.query) and href .. luci.http.build_querystring(k.query) or href %>
|
||||||
<div<% if node._menu_selected then %> class="yellowtext"<%end%>><a href="<%=controller%>/<%=category%>/<%=k.name%>"><%=node.title%></a>
|
<div<% if node._menu_selected then %> class="yellowtext"<%end%>><a href="<%=controller%>/<%=category%>/<%=k.name%>"><%=node.title%></a>
|
||||||
<%submenu("/" .. category .. "/" .. k.name .. "/", node)%>
|
<%submenu("/" .. category .. "/" .. k.name .. "/", node)%>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -73,9 +73,12 @@ local function submenu(prefix, node)
|
||||||
%>
|
%>
|
||||||
<ul>
|
<ul>
|
||||||
<% for j, v in pairs(index) do
|
<% for j, v in pairs(index) do
|
||||||
local nnode = node.nodes[v.name]%>
|
local nnode = node.nodes[v.name]
|
||||||
|
local href = controller .. prefix .. v.name
|
||||||
|
href = (v.query) and href .. luci.http.build_querystring(v.query) or href
|
||||||
|
%>
|
||||||
<li>
|
<li>
|
||||||
<span<% if nnode._menu_selected then %> class="blacktext"<%end%>><a href="<%=controller .. prefix .. v.name%>"><%=nnode.title%></a></span>
|
<span<% if nnode._menu_selected then %> class="blacktext"<%end%>><a href="<%=href%>"><%=nnode.title%></a></span>
|
||||||
<% submenu(prefix .. v.name .. "/", nnode) %>
|
<% submenu(prefix .. v.name .. "/", nnode) %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -93,8 +96,10 @@ if cattree and cattree.nodes then
|
||||||
|
|
||||||
for i, k in ipairs(index) do
|
for i, k in ipairs(index) do
|
||||||
node = cattree.nodes[k.name]
|
node = cattree.nodes[k.name]
|
||||||
if node.title then %>
|
if node.title then
|
||||||
<div<% if node._menu_selected then %> class="blacktext"<%end%>><a href="<%=controller%>/<%=category%>/<%=k.name%>"><%=node.title%></a>
|
local href = controller.."/"..category.."/"..k.name
|
||||||
|
href = (k.query) and href .. luci.http.build_querystring(k.query) or href %>
|
||||||
|
<div<% if node._menu_selected then %> class="blacktext"<%end%>><a href="<%=href%>"><%=node.title%></a>
|
||||||
<%submenu("/" .. category .. "/" .. k.name .. "/", node)%>
|
<%submenu("/" .. category .. "/" .. k.name .. "/", node)%>
|
||||||
</div>
|
</div>
|
||||||
<% end
|
<% end
|
||||||
|
|
Loading…
Reference in a new issue