* CBI updates
* Made dispatching paths unambiguous
This commit is contained in:
parent
c8426cfa3c
commit
93c55f3c5d
9 changed files with 52 additions and 31 deletions
|
@ -86,6 +86,12 @@ function Node.render(self)
|
||||||
ffluci.template.render(self.template, {self=self})
|
ffluci.template.render(self.template, {self=self})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Node.render_children(self)
|
||||||
|
for k, node in ipairs(self.children) do
|
||||||
|
node:render()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
Map - A map describing a configuration file
|
Map - A map describing a configuration file
|
||||||
|
@ -175,6 +181,23 @@ function TypedSection.__init__(self, ...)
|
||||||
self.valid = nil
|
self.valid = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function TypedSection.render_children(self, section)
|
||||||
|
for k, node in ipairs(self.children) do
|
||||||
|
node.section = section
|
||||||
|
node:render()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function TypedSection.ucisections(self)
|
||||||
|
local sections = {}
|
||||||
|
for k, v in pairs(self.map:read()) do
|
||||||
|
if v[".type"] == self.sectiontype then
|
||||||
|
sections[k] = v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return sections
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
AbstractValue - An abstract Value Type
|
AbstractValue - An abstract Value Type
|
||||||
|
|
|
@ -167,13 +167,15 @@ function cbi(request)
|
||||||
local tmpl = require("ffluci.template")
|
local tmpl = require("ffluci.template")
|
||||||
local cbi = require("ffluci.cbi")
|
local cbi = require("ffluci.cbi")
|
||||||
|
|
||||||
|
local path = request.category.."_"..request.module.."/"..request.action
|
||||||
|
|
||||||
i18n.loadc(request.module)
|
i18n.loadc(request.module)
|
||||||
|
|
||||||
stat, map = pcall(cbi.load, request.module.."/"..request.action)
|
stat, map = pcall(cbi.load, path)
|
||||||
if stat then
|
if stat then
|
||||||
tmpl.render("header")
|
tmpl.render("cbi/header")
|
||||||
map:render()
|
map:render()
|
||||||
tmpl.render("footer")
|
tmpl.render("cbi/footer")
|
||||||
else
|
else
|
||||||
disp.error404()
|
disp.error404()
|
||||||
end
|
end
|
||||||
|
@ -195,15 +197,16 @@ function dynamic(request)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if pcall(tmpl.render, request.module .. "/" .. request.action) then
|
local path = request.category.."_"..request.module.."/"..request.action
|
||||||
|
if pcall(tmpl.render, path) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
stat, map = pcall(cbi.load, request.module.."/"..request.action)
|
stat, map = pcall(cbi.load, path)
|
||||||
if stat then
|
if stat then
|
||||||
tmpl.render("header")
|
tmpl.render("cbi/header")
|
||||||
map:render()
|
map:render()
|
||||||
tmpl.render("footer")
|
tmpl.render("cbi/footer")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -217,8 +220,10 @@ function simpleview(request)
|
||||||
local tmpl = require("ffluci.template")
|
local tmpl = require("ffluci.template")
|
||||||
local disp = require("ffluci.dispatcher")
|
local disp = require("ffluci.dispatcher")
|
||||||
|
|
||||||
|
local path = request.category.."_"..request.module.."/"..request.action
|
||||||
|
|
||||||
i18n.loadc(request.module)
|
i18n.loadc(request.module)
|
||||||
if not pcall(tmpl.render, request.module .. "/" .. request.action) then
|
if not pcall(tmpl.render, path) then
|
||||||
disp.error404()
|
disp.error404()
|
||||||
end
|
end
|
||||||
end
|
end
|
2
src/ffluci/view/cbi/footer.htm
Normal file
2
src/ffluci/view/cbi/footer.htm
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
</form>
|
||||||
|
<%+footer%>
|
2
src/ffluci/view/cbi/header.htm
Normal file
2
src/ffluci/view/cbi/header.htm
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
<%+header%>
|
||||||
|
<form method="post" action="<%=os.getenv("REQUEST_URI")%>">
|
|
@ -1,10 +1,8 @@
|
||||||
<div class="cbi-map" id="cbi-<%=self.config%>">
|
<div class="cbi-map" id="cbi-<%=self.config%>">
|
||||||
<form method="post" action="<%=os.getenv("REQUEST_URI")%>">
|
|
||||||
<h1><%=self.title%></h1>
|
<h1><%=self.title%></h1>
|
||||||
<div class="cbi-map-descr"><%=self.description%></div>
|
<div class="cbi-map-descr"><%=self.description%></div>
|
||||||
<br />
|
<br />
|
||||||
<% for k, node in ipairs(self.children) do node:render() end %>
|
<% self:render_children() %>
|
||||||
<br />
|
<br />
|
||||||
<input type="submit" /> <input type="reset" />
|
<input type="submit" /> <input type="reset" />
|
||||||
</form>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
|
@ -2,6 +2,6 @@
|
||||||
<h2><%=self.title%></h2>
|
<h2><%=self.title%></h2>
|
||||||
<div class="cbi-nsection-descr"><%=self.description%></div>
|
<div class="cbi-nsection-descr"><%=self.description%></div>
|
||||||
<div class="cbi-nsection-options">
|
<div class="cbi-nsection-options">
|
||||||
<% for k, node in ipairs(self.children) do node:render() end %>
|
<% self:render_children() %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,21 +1,11 @@
|
||||||
<%
|
|
||||||
local allsections = self.map:read()
|
|
||||||
local sections = {}
|
|
||||||
for k, v in pairs(allsections) do
|
|
||||||
if v[".type"] == self.sectiontype then
|
|
||||||
sections[k] = v
|
|
||||||
end
|
|
||||||
end
|
|
||||||
%>
|
|
||||||
<div class="cbi-tsection" id="cbi-<%=self.config%>-<%=self.sectiontype%>">
|
<div class="cbi-tsection" id="cbi-<%=self.config%>-<%=self.sectiontype%>">
|
||||||
<h2><%=self.title%></h2>
|
<h2><%=self.title%></h2>
|
||||||
<div class="cbi-tsection-descr"><%=self.description%></div>
|
<div class="cbi-tsection-descr"><%=self.description%></div>
|
||||||
<% for k, v in pairs(sections) do %>
|
<% for k, v in pairs(self:ucisections()) do%>
|
||||||
<div class="cbi-tsection-node" id="cbi-<%=self.config%>-<%=k%>">
|
<fieldset class="cbi-tsection-node" id="cbi-<%=self.config%>-<%=k%>">
|
||||||
<% for i, node in ipairs(self.children) do
|
<% if not self.anonymous then %><legend><%=k%></legend><% end %>
|
||||||
node.section = k
|
<% self:render_children(k) %>
|
||||||
node:render()
|
</fieldset>
|
||||||
end %>
|
<br />
|
||||||
</div>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -10,6 +10,7 @@ require("ffluci.http").htmlheader()
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
<link rel="stylesheet" type="text/css" href="<%=media%>/cascade.css" />
|
<link rel="stylesheet" type="text/css" href="<%=media%>/cascade.css" />
|
||||||
|
<link rel="stylesheet" type="text/css" href="<%=media%>/css/<%=req.category%>_<%=req.module%>.css" />
|
||||||
<title>FFLuCI</title>
|
<title>FFLuCI</title>
|
||||||
<% if addheaders then write(addheaders) end %>
|
<% if addheaders then write(addheaders) end %>
|
||||||
</head>
|
</head>
|
||||||
|
@ -56,4 +57,4 @@ require("ffluci.http").htmlheader()
|
||||||
<div>Konfiguration<ul><li>x Änderungen</li><li>Anwenden</li><li>Zurücksetzen</li></ul></div>
|
<div>Konfiguration<ul><li>x Änderungen</li><li>Anwenden</li><li>Zurücksetzen</li></ul></div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<div id="content">
|
<div id="content">
|
Loading…
Reference in a new issue