* luci-0.8: merge further changes
authorJo-Philipp Wich <jow@openwrt.org>
Wed, 29 Oct 2008 19:54:59 +0000 (19:54 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Wed, 29 Oct 2008 19:54:59 +0000 (19:54 +0000)
libs/httpd/luasrc/httpd/handler/luci.lua
libs/sys/luasrc/sys.lua
modules/admin-core/luasrc/view/footer.htm
modules/admin-mini/luasrc/controller/mini/uci.lua
modules/admin-mini/luasrc/model/cbi/mini/luci.lua
modules/admin-mini/luasrc/view/mini/uci_apply.htm
modules/admin-mini/luasrc/view/mini/uci_changes.htm
modules/admin-mini/luasrc/view/mini/uci_revert.htm
themes/fledermaus/htdocs/luci-static/fledermaus/cascade.css
themes/fledermaus/luasrc/view/themes/fledermaus/header.htm

index c3720ff..6e9c677 100644 (file)
@@ -27,7 +27,7 @@ function Luci.__init__(self, limit)
        luci.httpd.module.Handler.__init__(self)
        self.limit = limit or 5
        self.running = {}
-       setmetatable(self.running, {__mode = "v"})
+       setmetatable(self.running, {__mode = "k"})
 end
 
 function Luci.handle_head(self, ...)
@@ -40,19 +40,31 @@ function Luci.handle_post(self, ...)
 end
 
 function Luci.handle_get(self, request, sourcein, sinkerr)
-       if self.limit and #self.running >= self.limit then
+       local reaped  = false
+       local running = 0
+
+       for _, v in pairs(self.running) do
+               if v then running = running + 1 end
+       end
+
+       if self.limit and running >= self.limit then
                for k, v in ipairs(self.running) do
-                       if coroutine.status(v) == "dead" then
-                               collectgarbage()
-                               break
+                       if coroutine.status(k) == "dead" then
+                               self.running[k] = nil
+                               running = running - 1
+                               reaped  = true
                        end
                end
-               if #self.running >= self.limit then     
-                       return self:failure(503, "Overload")
+
+               if reaped then collectgarbage() end
+
+               if running >= self.limit then
+                       return self:failure(503, "Overload %i/%i" % { running, self.limit } )
                end
        end
-       table.insert(self.running, coroutine.running())
-       
+
+       self.running[coroutine.running()] = true
+
        local r = luci.http.Request(
                request.env,
                sourcein,
index b4d3d2f..e8b5e2c 100644 (file)
@@ -591,7 +591,8 @@ function init.names()
 end
 
 --- Test whether the given init script is enabled
--- @return     Boolean indicating whether init is enabled
+-- @param name Name of the init script
+-- @return             Boolean indicating whether init is enabled
 function init.enabled(name)
        if luci.fs.access(init.dir..name) then
                return ( call(init.dir..name.." enabled") == 0 )
@@ -600,7 +601,8 @@ function init.enabled(name)
 end
 
 --- Get the index of he given init script
--- @return     Numeric index value
+-- @param name Name of the init script
+-- @return             Numeric index value
 function init.index(name)
        if luci.fs.access(init.dir..name) then
                return call("source "..init.dir..name.."; exit $START")
@@ -608,7 +610,8 @@ function init.index(name)
 end
 
 --- Enable the given init script
--- @return     Boolean indicating success
+-- @param name Name of the init script
+-- @return             Boolean indicating success
 function init.enable(name)
        if luci.fs.access(init.dir..name) then
                return ( call(init.dir..name.." enable") == 1 )
@@ -616,7 +619,8 @@ function init.enable(name)
 end
 
 --- Disable the given init script
--- @return     Boolean indicating success
+-- @param name Name of the init script
+-- @return             Boolean indicating success
 function init.disable(name)
        if luci.fs.access(init.dir..name) then
                return ( call(init.dir..name.." disable") == 0 )
index 8428e89..6c6d214 100644 (file)
@@ -12,4 +12,4 @@ You may obtain a copy of the License at
 $Id$
 
 -%>
-<% include("themes/" .. luci.fs.basename(media) .. "/footer") %>
\ No newline at end of file
+<% include("themes/" .. theme .. "/footer") %>
\ No newline at end of file
index 4e92056..4687c83 100644 (file)
@@ -16,11 +16,13 @@ module("luci.controller.mini.uci", package.seeall)
 
 function index()
        local i18n = luci.i18n.translate
+       local redir = luci.http.formvalue("redir", true) or 
+         luci.dispatcher.build_url(unpack(luci.dispatcher.context.request))
        
        entry({"mini", "uci"}, nil, i18n("config"))
-       entry({"mini", "uci", "changes"}, call("action_changes"), i18n("changes"), 30)
-       entry({"mini", "uci", "revert"}, call("action_revert"), i18n("revert"), 20)
-       entry({"mini", "uci", "saveapply"}, call("action_apply"), i18n("saveapply"), 10)
+       entry({"mini", "uci", "changes"}, call("action_changes"), i18n("changes"), 30).query = {redir=redir}
+       entry({"mini", "uci", "revert"}, call("action_revert"), i18n("revert"), 20).query = {redir=redir}
+       entry({"mini", "uci", "saveapply"}, call("action_apply"), i18n("saveapply"), 10).query = {redir=redir}
 end
 
 function convert_changes(changes)
index 1b0f3b1..f9365c9 100644 (file)
@@ -15,13 +15,20 @@ $Id$
 require("luci.config")
 m = Map("luci", translate("webui"), translate("a_i_luci1"))
 
+-- force reload of global luci config namespace to reflect the changes
+function m.commit_handler(self)
+       package.loaded["luci.config"] = nil
+       require("luci.config")
+end
+
+
 c = m:section(NamedSection, "main", "core", translate("general"))
 
 l = c:option(ListValue, "lang", translate("language"))
 
 local i18ndir = luci.i18n.i18ndir .. "default."
 for k, v in pairs(luci.config.languages) do
-       if k:sub(1, 1) ~= "." and luci.fs.isfile(i18ndir .. k .. ".lua") then
+       if k:sub(1, 1) ~= "." and luci.fs.isfile(i18ndir .. k:gsub("_", "-") .. ".lua") then
                l:value(k, v)
        end
 end
@@ -33,4 +40,4 @@ for k, v in pairs(luci.config.themes) do
        end
 end
 
-return m
\ No newline at end of file
+return m
index 8aa09c6..a908b6a 100644 (file)
@@ -13,6 +13,11 @@ $Id$
 
 -%>
 <%+header%>
+<div>
+<a href="<%=luci.http.formvalue("redir")%>">&lt;&lt; <%:back%></a>
+<br />
+<br />
+</div>
 <h2><a id="content" name="content"><%:config%></a></h2>
 <p><%:uci_applied%>:</p>
 <code><%=(changes or "-")%>
@@ -26,4 +31,9 @@ while line do
 end
 fp:close()
 %></code>
+<div>
+<a href="<%=luci.http.formvalue("redir")%>">&lt;&lt; <%:back%></a>
+<br />
+<br />
+</div>
 <%+footer%>
\ No newline at end of file
index 591ae69..89df99d 100644 (file)
@@ -13,14 +13,27 @@ $Id$
 
 -%>
 <%+header%>
+<div>
+<a href="<%=luci.http.formvalue("redir")%>">&lt;&lt; <%:back%></a>
+<br />
+<br />
+</div>
 <h2><a id="content" name="content"><%:config%></a></h2>
 <h3><%:changes%></h3>
 <code><%=changes%></code>
 <br /><br />
-<form class="inline" method="get" action="<%=controller%>/mini/uci/apply">
+<form class="inline" method="get" action="<%=controller%>/admin/uci/apply">
        <input type="submit" value="<%:apply%>" />
 </form>
-<form class="inline" method="get" action="<%=controller%>/mini/uci/revert">
+<form class="inline" method="get" action="<%=controller%>/admin/uci/saveapply">
+       <input type="submit" value="<%:saveapply%>" />
+</form>
+<form class="inline" method="get" action="<%=controller%>/admin/uci/revert">
        <input type="submit" value="<%:revert%>" />
 </form>
-<%+footer%>
+
+<div>
+<br />
+<a href="<%=luci.http.formvalue("redir")%>">&lt;&lt; <%:back%></a>
+</div>
+<%+footer%>
\ No newline at end of file
index 553ec74..e8515dc 100644 (file)
@@ -13,7 +13,17 @@ $Id$
 
 -%>
 <%+header%>
+<div>
+<a href="<%=luci.http.formvalue("redir")%>">&lt;&lt; <%:back%></a>
+<br />
+<br />
+</div>
 <h2><a id="content" name="content"><%:config%></a></h2>
 <p><%:uci_reverted%>:</p>
 <code><%=(changes or "-")%></code>
+<div>
+<a href="<%=luci.http.formvalue("redir")%>">&lt;&lt; <%:back%></a>
+<br />
+<br />
+</div>
 <%+footer%>
\ No newline at end of file
index 70132fd..590e062 100644 (file)
@@ -16,7 +16,7 @@ code {
        white-space: pre;
 }
 
-div#content ul {
+div#maincontent ul {
        margin-left: 2em;
 }
 
@@ -164,7 +164,7 @@ div#content ul {
        float: right;
 }
 
-#content {
+#maincontent {
        clear: both;
        width: 90%;
        margin: 0 auto;
@@ -174,20 +174,20 @@ div#content ul {
        font-size: 80%;
 }
 
-#content h1 {
+#maincontent h2 {
        margin: 0.25em 0 0.5em 0;
        font-size: 150%;
        font-weight: normal;
 }
 
-#content h2 {
+#maincontent h3 {
        margin: 0.5em 0;
        font-size: 120%;
        font-weight: normal;
        text-decoration: underline;
 }
 
-#content p {
+#maincontent p {
        margin-bottom: 1em;
 }
 
@@ -277,7 +277,7 @@ input.cbi-input-user {
        padding-left: 17px;
 }
 
-input.cbi-input-key {
+input.cbi-input-password {
        background: url('../resources/cbi/key.gif') no-repeat scroll 1px center;
        background-color: inherit;
        padding-left: 17px;
@@ -433,6 +433,7 @@ div.cbi-value:hover div.cbi-value-field > div.cbi-value-description {
 
 div.cbi-section-create {
        clear: left;
+       white-space: nowrap;
 }
 
 div.cbi-map-descr {
@@ -578,7 +579,7 @@ ul.cbi-apply {
        width: 200% !important;
 }
 
-* html div#content {
+* html div#maincontent {
        margin-left: -80% !important;
        width: 160% !important;
 }