* luci-0.8: merge further changes
This commit is contained in:
parent
3f414ad694
commit
d951b66b45
10 changed files with 89 additions and 30 deletions
|
@ -27,7 +27,7 @@ function Luci.__init__(self, limit)
|
||||||
luci.httpd.module.Handler.__init__(self)
|
luci.httpd.module.Handler.__init__(self)
|
||||||
self.limit = limit or 5
|
self.limit = limit or 5
|
||||||
self.running = {}
|
self.running = {}
|
||||||
setmetatable(self.running, {__mode = "v"})
|
setmetatable(self.running, {__mode = "k"})
|
||||||
end
|
end
|
||||||
|
|
||||||
function Luci.handle_head(self, ...)
|
function Luci.handle_head(self, ...)
|
||||||
|
@ -40,19 +40,31 @@ function Luci.handle_post(self, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Luci.handle_get(self, request, sourcein, sinkerr)
|
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
|
for k, v in ipairs(self.running) do
|
||||||
if coroutine.status(v) == "dead" then
|
if coroutine.status(k) == "dead" then
|
||||||
collectgarbage()
|
self.running[k] = nil
|
||||||
break
|
running = running - 1
|
||||||
|
reaped = true
|
||||||
end
|
end
|
||||||
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
|
||||||
end
|
end
|
||||||
table.insert(self.running, coroutine.running())
|
|
||||||
|
self.running[coroutine.running()] = true
|
||||||
|
|
||||||
local r = luci.http.Request(
|
local r = luci.http.Request(
|
||||||
request.env,
|
request.env,
|
||||||
sourcein,
|
sourcein,
|
||||||
|
|
|
@ -591,7 +591,8 @@ function init.names()
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Test whether the given init script is enabled
|
--- 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)
|
function init.enabled(name)
|
||||||
if luci.fs.access(init.dir..name) then
|
if luci.fs.access(init.dir..name) then
|
||||||
return ( call(init.dir..name.." enabled") == 0 )
|
return ( call(init.dir..name.." enabled") == 0 )
|
||||||
|
@ -600,7 +601,8 @@ function init.enabled(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get the index of he given init script
|
--- 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)
|
function init.index(name)
|
||||||
if luci.fs.access(init.dir..name) then
|
if luci.fs.access(init.dir..name) then
|
||||||
return call("source "..init.dir..name.."; exit $START")
|
return call("source "..init.dir..name.."; exit $START")
|
||||||
|
@ -608,7 +610,8 @@ function init.index(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Enable the given init script
|
--- Enable the given init script
|
||||||
-- @return Boolean indicating success
|
-- @param name Name of the init script
|
||||||
|
-- @return Boolean indicating success
|
||||||
function init.enable(name)
|
function init.enable(name)
|
||||||
if luci.fs.access(init.dir..name) then
|
if luci.fs.access(init.dir..name) then
|
||||||
return ( call(init.dir..name.." enable") == 1 )
|
return ( call(init.dir..name.." enable") == 1 )
|
||||||
|
@ -616,7 +619,8 @@ function init.enable(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Disable the given init script
|
--- Disable the given init script
|
||||||
-- @return Boolean indicating success
|
-- @param name Name of the init script
|
||||||
|
-- @return Boolean indicating success
|
||||||
function init.disable(name)
|
function init.disable(name)
|
||||||
if luci.fs.access(init.dir..name) then
|
if luci.fs.access(init.dir..name) then
|
||||||
return ( call(init.dir..name.." disable") == 0 )
|
return ( call(init.dir..name.." disable") == 0 )
|
||||||
|
|
|
@ -12,4 +12,4 @@ You may obtain a copy of the License at
|
||||||
$Id$
|
$Id$
|
||||||
|
|
||||||
-%>
|
-%>
|
||||||
<% include("themes/" .. luci.fs.basename(media) .. "/footer") %>
|
<% include("themes/" .. theme .. "/footer") %>
|
|
@ -16,11 +16,13 @@ module("luci.controller.mini.uci", package.seeall)
|
||||||
|
|
||||||
function index()
|
function index()
|
||||||
local i18n = luci.i18n.translate
|
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"}, nil, i18n("config"))
|
||||||
entry({"mini", "uci", "changes"}, call("action_changes"), i18n("changes"), 30)
|
entry({"mini", "uci", "changes"}, call("action_changes"), i18n("changes"), 30).query = {redir=redir}
|
||||||
entry({"mini", "uci", "revert"}, call("action_revert"), i18n("revert"), 20)
|
entry({"mini", "uci", "revert"}, call("action_revert"), i18n("revert"), 20).query = {redir=redir}
|
||||||
entry({"mini", "uci", "saveapply"}, call("action_apply"), i18n("saveapply"), 10)
|
entry({"mini", "uci", "saveapply"}, call("action_apply"), i18n("saveapply"), 10).query = {redir=redir}
|
||||||
end
|
end
|
||||||
|
|
||||||
function convert_changes(changes)
|
function convert_changes(changes)
|
||||||
|
|
|
@ -15,13 +15,20 @@ $Id$
|
||||||
require("luci.config")
|
require("luci.config")
|
||||||
m = Map("luci", translate("webui"), translate("a_i_luci1"))
|
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"))
|
c = m:section(NamedSection, "main", "core", translate("general"))
|
||||||
|
|
||||||
l = c:option(ListValue, "lang", translate("language"))
|
l = c:option(ListValue, "lang", translate("language"))
|
||||||
|
|
||||||
local i18ndir = luci.i18n.i18ndir .. "default."
|
local i18ndir = luci.i18n.i18ndir .. "default."
|
||||||
for k, v in pairs(luci.config.languages) do
|
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)
|
l:value(k, v)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -33,4 +40,4 @@ for k, v in pairs(luci.config.themes) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return m
|
return m
|
||||||
|
|
|
@ -13,6 +13,11 @@ $Id$
|
||||||
|
|
||||||
-%>
|
-%>
|
||||||
<%+header%>
|
<%+header%>
|
||||||
|
<div>
|
||||||
|
<a href="<%=luci.http.formvalue("redir")%>"><< <%:back%></a>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
</div>
|
||||||
<h2><a id="content" name="content"><%:config%></a></h2>
|
<h2><a id="content" name="content"><%:config%></a></h2>
|
||||||
<p><%:uci_applied%>:</p>
|
<p><%:uci_applied%>:</p>
|
||||||
<code><%=(changes or "-")%>
|
<code><%=(changes or "-")%>
|
||||||
|
@ -26,4 +31,9 @@ while line do
|
||||||
end
|
end
|
||||||
fp:close()
|
fp:close()
|
||||||
%></code>
|
%></code>
|
||||||
|
<div>
|
||||||
|
<a href="<%=luci.http.formvalue("redir")%>"><< <%:back%></a>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
</div>
|
||||||
<%+footer%>
|
<%+footer%>
|
|
@ -13,14 +13,27 @@ $Id$
|
||||||
|
|
||||||
-%>
|
-%>
|
||||||
<%+header%>
|
<%+header%>
|
||||||
|
<div>
|
||||||
|
<a href="<%=luci.http.formvalue("redir")%>"><< <%:back%></a>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
</div>
|
||||||
<h2><a id="content" name="content"><%:config%></a></h2>
|
<h2><a id="content" name="content"><%:config%></a></h2>
|
||||||
<h3><%:changes%></h3>
|
<h3><%:changes%></h3>
|
||||||
<code><%=changes%></code>
|
<code><%=changes%></code>
|
||||||
<br /><br />
|
<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%>" />
|
<input type="submit" value="<%:apply%>" />
|
||||||
</form>
|
</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%>" />
|
<input type="submit" value="<%:revert%>" />
|
||||||
</form>
|
</form>
|
||||||
<%+footer%>
|
|
||||||
|
<div>
|
||||||
|
<br />
|
||||||
|
<a href="<%=luci.http.formvalue("redir")%>"><< <%:back%></a>
|
||||||
|
</div>
|
||||||
|
<%+footer%>
|
|
@ -13,7 +13,17 @@ $Id$
|
||||||
|
|
||||||
-%>
|
-%>
|
||||||
<%+header%>
|
<%+header%>
|
||||||
|
<div>
|
||||||
|
<a href="<%=luci.http.formvalue("redir")%>"><< <%:back%></a>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
</div>
|
||||||
<h2><a id="content" name="content"><%:config%></a></h2>
|
<h2><a id="content" name="content"><%:config%></a></h2>
|
||||||
<p><%:uci_reverted%>:</p>
|
<p><%:uci_reverted%>:</p>
|
||||||
<code><%=(changes or "-")%></code>
|
<code><%=(changes or "-")%></code>
|
||||||
|
<div>
|
||||||
|
<a href="<%=luci.http.formvalue("redir")%>"><< <%:back%></a>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
</div>
|
||||||
<%+footer%>
|
<%+footer%>
|
|
@ -16,7 +16,7 @@ code {
|
||||||
white-space: pre;
|
white-space: pre;
|
||||||
}
|
}
|
||||||
|
|
||||||
div#content ul {
|
div#maincontent ul {
|
||||||
margin-left: 2em;
|
margin-left: 2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ div#content ul {
|
||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
#content {
|
#maincontent {
|
||||||
clear: both;
|
clear: both;
|
||||||
width: 90%;
|
width: 90%;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
|
@ -174,20 +174,20 @@ div#content ul {
|
||||||
font-size: 80%;
|
font-size: 80%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#content h1 {
|
#maincontent h2 {
|
||||||
margin: 0.25em 0 0.5em 0;
|
margin: 0.25em 0 0.5em 0;
|
||||||
font-size: 150%;
|
font-size: 150%;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
#content h2 {
|
#maincontent h3 {
|
||||||
margin: 0.5em 0;
|
margin: 0.5em 0;
|
||||||
font-size: 120%;
|
font-size: 120%;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
#content p {
|
#maincontent p {
|
||||||
margin-bottom: 1em;
|
margin-bottom: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,7 +277,7 @@ input.cbi-input-user {
|
||||||
padding-left: 17px;
|
padding-left: 17px;
|
||||||
}
|
}
|
||||||
|
|
||||||
input.cbi-input-key {
|
input.cbi-input-password {
|
||||||
background: url('../resources/cbi/key.gif') no-repeat scroll 1px center;
|
background: url('../resources/cbi/key.gif') no-repeat scroll 1px center;
|
||||||
background-color: inherit;
|
background-color: inherit;
|
||||||
padding-left: 17px;
|
padding-left: 17px;
|
||||||
|
@ -433,6 +433,7 @@ div.cbi-value:hover div.cbi-value-field > div.cbi-value-description {
|
||||||
|
|
||||||
div.cbi-section-create {
|
div.cbi-section-create {
|
||||||
clear: left;
|
clear: left;
|
||||||
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.cbi-map-descr {
|
div.cbi-map-descr {
|
||||||
|
@ -578,7 +579,7 @@ ul.cbi-apply {
|
||||||
width: 200% !important;
|
width: 200% !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
* html div#content {
|
* html div#maincontent {
|
||||||
margin-left: -80% !important;
|
margin-left: -80% !important;
|
||||||
width: 160% !important;
|
width: 160% !important;
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,4 +177,4 @@ end
|
||||||
|
|
||||||
<br class="clear" />
|
<br class="clear" />
|
||||||
</div>
|
</div>
|
||||||
<div id="content">
|
<div id="maincontent">
|
||||||
|
|
Loading…
Reference in a new issue