diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/cbi/luasrc/cbi.lua | 19 | ||||
-rw-r--r-- | libs/cbi/luasrc/view/cbi/map.htm | 13 |
2 files changed, 31 insertions, 1 deletions
diff --git a/libs/cbi/luasrc/cbi.lua b/libs/cbi/luasrc/cbi.lua index b00ccf8d2a..09ba553ec2 100644 --- a/libs/cbi/luasrc/cbi.lua +++ b/libs/cbi/luasrc/cbi.lua @@ -211,6 +211,7 @@ function Map.__init__(self, config, ...) self.config = config self.parsechain = {self.config} self.template = "cbi/map" + self.apply_on_parse = nil self.uci = uci.cursor() self.save = true if not self.uci:load(self.config) then @@ -252,7 +253,14 @@ function Map.parse(self, ...) -- Refresh data because commit changes section names self.uci:load(config) end - self.uci:apply(self.parsechain) + if self.apply_on_parse then + self.uci:apply(self.parsechain) + else + self._apply = function() + local cmd = self.uci:apply(self.parsechain, true) + return io.popen(cmd) + end + end -- Reparse sections Node.parse(self, ...) @@ -264,6 +272,15 @@ function Map.parse(self, ...) end end +function Map.render(self, ...) + Node.render(self, ...) + if self._apply then + local fp = self._apply() + fp:read("*a") + fp:close() + end +end + -- Creates a child section function Map.section(self, class, ...) if instanceof(class, AbstractSection) then diff --git a/libs/cbi/luasrc/view/cbi/map.htm b/libs/cbi/luasrc/view/cbi/map.htm index e29b4fc746..e61f8543ab 100644 --- a/libs/cbi/luasrc/view/cbi/map.htm +++ b/libs/cbi/luasrc/view/cbi/map.htm @@ -16,6 +16,19 @@ $Id$ <div class="cbi-map" id="cbi-<%=self.config%>"> <h1><%=self.title%></h1> <div class="cbi-map-descr"><%=self.description%></div> + <%- if self._apply then -%><code><%:cbi_applying%>: + + <% + local fp = self._apply() + self._apply = nil + local line = fp:read() + while line do + write(line) + line = fp:read() + end + fp:close() + -%> + </code><%- end -%> <%- self:render_children() %> <br /> </div> |