luci-0.11: merge r9559 - r9569

This commit is contained in:
Jo-Philipp Wich 2012-12-25 02:45:42 +00:00
parent 8df855a6ac
commit 60b81d978a
15 changed files with 35 additions and 288 deletions

View file

@ -17,7 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with luci-pbx. If not, see <http://www.gnu.org/licenses/>.
. /etc/functions.sh
. /lib/functions.sh
START=60

View file

@ -2,6 +2,7 @@
Luci statistics - statistics controller module
(c) 2008 Freifunk Leipzig / Jo-Philipp Wich <xm@leipzig.freifunk.net>
(c) 2012 Jo-Philipp Wich <xm@subsignal.org>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -9,8 +10,6 @@ You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
$Id$
]]--
module("luci.controller.luci_statistics.luci_statistics", package.seeall)
@ -106,7 +105,8 @@ function index()
-- get rrd data tree
local tree = luci.statistics.datatree.Instance(host)
for i, plugin in luci.util.vspairs( tree:plugins() ) do
local _, plugin, idx
for _, plugin, idx in luci.util.vspairs( tree:plugins() ) do
-- get plugin instances
local instances = tree:plugin_instances( plugin )
@ -114,16 +114,17 @@ function index()
-- plugin menu entry
entry(
{ "admin", "statistics", "graph", plugin },
call("statistics_render"), labels[plugin], i
call("statistics_render"), labels[plugin], idx
).query = { timespan = span , host = host }
-- if more then one instance is found then generate submenu
if #instances > 1 then
for j, inst in luci.util.vspairs(instances) do
local _, inst, idx2
for _, inst, idx2 in luci.util.vspairs(instances) do
-- instance menu entry
entry(
{ "admin", "statistics", "graph", plugin, inst },
call("statistics_render"), inst, j
call("statistics_render"), inst, idx2
).query = { timespan = span , host = host }
end
end
@ -148,6 +149,7 @@ function statistics_render()
local hosts = graph.tree:host_instances()
local is_index = false
local i, p, inst, idx
-- deliver image
if vars.img then
@ -186,8 +188,8 @@ function statistics_render()
-- render graphs
for i, inst in ipairs( instances ) do
for i, img in ipairs( graph:render( plugin, inst, is_index ) ) do
for i, inst in luci.util.vspairs( instances ) do
for i, img in luci.util.vspairs( graph:render( plugin, inst, is_index ) ) do
table.insert( images, graph:strippngpath( img ) )
images[images[#images]] = inst
end

View file

@ -13,7 +13,7 @@ You may obtain a copy of the License at
$Id$
]]--
m = Map("upnpd", translate("Universal Plug & Play"),
m = Map("upnpd", luci.util.pcdata(translate("Universal Plug & Play")),
translate("UPnP allows clients in the local network to automatically configure the router."))
m:section(SimpleSection).template = "upnp_status"

View file

@ -1,133 +0,0 @@
#!/usr/bin/lua
--[[
LuCI - Lua Configuration Interface
Copyright 2008 Steven Barth <steven@midlink.org>
Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
$Id: index.lua 3548 2008-10-09 20:28:07Z Cyrus $
]]--
local cbi = require "luci.cbi"
local i18n = require "luci.i18n"
local util = require "luci.util"
if not arg[1] then
util.perror("Usage %s path/to/cbi/model.lua [i18nfilename]" % arg[0])
os.exit(1)
end
i18n.load("base", "en")
if arg[2] then
i18n.load(arg[2], "en")
end
if arg[3] then
pcall(function()
require "uci"
require "luci.model.uci".cursor = function(config, save)
return uci.cursor(config or arg[3] .. "/etc/config", save or arg[3] .. "/tmp/.uci")
end
end)
end
local map = cbi.load(arg[1])[1]
assert(map)
print ("package "..map.config)
print ("\nconfig package")
if #map.title > 0 then
print (" option title '%s'" % util.striptags(map.title))
end
if #map.description > 0 then
print (" option description '%s'" % util.striptags(map.description))
end
for i, sec in pairs(map.children) do if util.instanceof(sec, cbi.AbstractSection) then
print ("\nconfig section")
print (" option name '%s'" % sec.sectiontype)
print (" option package '%s'" % map.config)
if #sec.title > 0 then
print (" option title '%s'" % util.striptags(sec.title))
end
if #sec.description > 0 then
print (" option description '%s'" % util.striptags(sec.description))
end
if not sec.addremove then
print (" option unique true")
print (" option required true")
end
if not sec.anonymous then
print (" option named true")
end
if sec.dynamic then
print (" option dynamic true")
end
for j, opt in ipairs(sec.children) do
if opt.option:sub(1,1) ~= "_" or util.instanceof(opt, cbi.Value) then
print ("\nconfig variable")
print (" option name '%s'" % opt.option)
print (" option section '%s.%s'" % {map.config, sec.sectiontype})
if #opt.title > 0 then
print (" option title '%s'" % util.striptags(opt.title))
end
if #opt.description > 0 then
print (" option description '%s'" % util.striptags(opt.description))
end
if not opt.rmempty and not opt.optional then
print (" option required true")
end
if util.instanceof(opt, cbi.Flag) then
print (" option datatype boolean")
elseif util.instanceof(opt, cbi.DynamicList) then
print (" option type list")
elseif util.instanceof(opt, cbi.ListValue) then
print (" option type enum")
util.perror("*** Warning: Please verify '%s.%s.%s' ***" %
{map.config, sec.sectiontype, opt.option} )
end
for i, dep in ipairs(opt.deps) do
if not dep.add or dep.add == "" then
local depstring
for k, v in pairs(dep.deps) do
depstring = (depstring and depstring .. "," or "") .. "%s=%s" % {k, v}
end
print (" list depends '%s'" % depstring)
else
util.perror("*** Warning: Unable to decode dependency '%s' in '%s.%s.%s[%s]' ***" %
{util.serialize_data(dep.deps), map.config, sec.sectiontype, opt.option, dep.add})
end
end
if util.instanceof(opt, cbi.ListValue) then
for k, key in ipairs(opt.keylist) do
print ("\nconfig enum")
print (" option variable '%s.%s.%s'" % {map.config, sec.sectiontype, opt.option})
print (" option value '%s'" % key)
if opt.vallist[k] and opt.vallist[k] ~= opt.keylist[k] then
print (" option title '%s'" % util.striptags(opt.vallist[k]))
end
end
end
end
end
end end

View file

@ -1,120 +0,0 @@
#!/usr/bin/perl
@ARGV >= 2 || die "Usage: $0 <source-dir> <dest-dir> [<target-language>]\n";
my $source_dir = shift @ARGV;
my $target_dir = shift @ARGV;
my $target_lang = shift @ARGV;
my $master_lang = "en";
if( ! -d "$target_dir/" . ( $target_lang || 'templates' ) )
{
system('mkdir', '-p', "$target_dir/" . ( $target_lang || 'templates' ));
}
my %target_strings;
if( $target_lang && open F, "find $source_dir -path '*/luasrc/i18n/*' -name '*.$target_lang.lua' |" )
{
while( chomp( my $file = readline F ) )
{
if( open L, "< $file" )
{
my ( $basename ) = $file =~ m{.+/([^/]+)\.[\w\-]+\.lua$};
$target_strings{$basename} = { };
while( chomp( my $entry = readline L ) )
{
my ( $k, $v );
if( $entry =~ /^\s*(\w+)\s*=\s*\[\[(.+)\]\]/ )
{
( $k, $v ) = ( $1, $2 );
}
elsif( $entry =~ /^\s*(\w+)\s*=\s*'(.+)'/ )
{
( $k, $v ) = ( $1, $2 );
}
elsif( $entry =~ /^\s*(\w+)\s*=\s*"(.+)"/ )
{
( $k, $v ) = ( $1, $2 );
}
if( $k && $v )
{
$v =~ s/"/\\"/g;
$v =~ s/\\\\"/\\"/g;
$target_strings{$basename}{$k} = $v;
}
}
close L;
}
}
close F;
}
if( open F, "find . -path '*/luasrc/i18n/*' -name '*.$master_lang.lua' |" )
{
my $destfile = sprintf '%s/%s/%%s.%s',
$target_dir,
$target_lang || 'templates',
$target_lang ? 'po' : 'pot'
;
while( chomp( my $file = readline F ) )
{
if( open L, "< $file" )
{
my ( $basename ) = $file =~ m{.+/([^/]+)\.\w+\.lua$};
my $filename = sprintf $destfile, $basename;
if( open T, "> $filename" )
{
printf "Generating %-40s ", $filename;
printf T "# %s.%s\n# generated from %s\n\nmsgid \"\"\n" .
"msgstr \"Content-Type: text/plain; charset=UTF-8\"\n\n",
$basename, $target_lang ? 'po' : 'pot', $file;
while( chomp( my $entry = readline L ) )
{
my ( $k, $v );
if( $entry =~ /^\s*(\w+)\s*=\s*\[\[(.+)\]\]/ )
{
( $k, $v ) = ( $1, $2 );
}
elsif( $entry =~ /^\s*(\w+)\s*=\s*'(.+)'/ )
{
( $k, $v ) = ( $1, $2 );
}
elsif( $entry =~ /^\s*(\w+)\s*=\s*"(.+)"/ )
{
( $k, $v ) = ( $1, $2 );
}
if( $k && $v )
{
$v =~ s/"/\\"/g;
$v =~ s/\\\\"/\\"/g;
printf T "#: %s:%d\n#. %s\nmsgid \"%s\"\nmsgstr \"%s\"\n\n",
$file, $., $v, $k,
( $target_strings{$basename} && $target_strings{$basename}{$k} )
? $target_strings{$basename}{$k} : "";
}
}
close T;
print "done\n";
}
close L;
}
}
close F;
}

View file

@ -4,9 +4,6 @@ LuCI - Utility library
Description:
Several common useful Lua functions
FileId:
$Id$
License:
Copyright 2008 Steven Barth <steven@midlink.org>
@ -609,6 +606,7 @@ end
function _sortiter( t, f )
local keys = { }
local k, v
for k, v in pairs(t) do
keys[#keys+1] = k
end
@ -620,7 +618,7 @@ function _sortiter( t, f )
return function()
_pos = _pos + 1
if _pos <= #keys then
return keys[_pos], t[keys[_pos]]
return keys[_pos], t[keys[_pos]], _pos
end
end
end

View file

@ -1,5 +1,5 @@
#!/bin/sh
. /etc/functions.sh
. /lib/functions.sh
apply_config() {
config_get init "$1" init

View file

@ -49,7 +49,7 @@
%> /> &#160;
<label<%=attr("for", cbid .. "." .. iface:name())%>>
<% if link then -%><a href="<%=link%>"><% end -%>
<img title="<%=iface:get_type_i18n()%>" style="width:16px; height:16px; vertical-align:middle" src="<%=resource%>/icons/<%=iface:type()%><%=iface:is_up() and "" or "_disabled"%>.png" />
<img<%=attr("title", iface:get_i18n())%> style="width:16px; height:16px; vertical-align:middle" src="<%=resource%>/icons/<%=iface:type()%><%=iface:is_up() and "" or "_disabled"%>.png" />
<% if link then -%></a><% end -%>
<%=pcdata(iface:get_i18n())%>
<% local ns = iface:get_networks(); if #ns > 0 then %>(

View file

@ -189,7 +189,7 @@ function action_flashops()
local function image_supported()
-- XXX: yay...
return ( 0 == os.execute(
". /etc/functions.sh; " ..
". /lib/functions.sh; " ..
"include /lib/upgrade; " ..
"platform_check_image %q >/dev/null"
% image_tmp

View file

@ -176,14 +176,6 @@ You may obtain a copy of the License at
d.innerHTML = html;
}
else if (d && !ifc.ifname)
{
d.innerHTML = String.format(
'<em><%:Network without interfaces.%></em><br />' +
'<a href="<%=luci.dispatcher.build_url("admin/network/network/%s")%>?tab.network.%s=physical"><%:Assign interfaces...%></a>',
ifc.name, ifc.name
);
}
else if (d && !ifc.proto)
{
var e = document.getElementById(ifc.id + '-ifc-edit');
@ -196,6 +188,14 @@ You may obtain a copy of the License at
'<%=luci.dispatcher.build_url("admin/system/packages")%>?query=luci-proto&display=available'
);
}
else if (d && !ifc.ifname)
{
d.innerHTML = String.format(
'<em><%:Network without interfaces.%></em><br />' +
'<a href="<%=luci.dispatcher.build_url("admin/network/network/%s")%>?tab.network.%s=physical"><%:Assign interfaces...%></a>',
ifc.name, ifc.name
);
}
else if (d)
{
d.innerHTML = '<em><%:Interface not present or not connected yet.%></em>';

View file

@ -81,7 +81,7 @@ function action_upgrade()
local function image_supported()
-- XXX: yay...
return ( 0 == os.execute(
". /etc/functions.sh; " ..
". /lib/functions.sh; " ..
"include /lib/upgrade; " ..
"platform_check_image %q >/dev/null"
% tmpfile

View file

@ -53,7 +53,7 @@ function action_flashops()
local function image_supported()
-- XXX: yay...
return ( 0 == os.execute(
". /etc/functions.sh; " ..
". /lib/functions.sh; " ..
"include /lib/upgrade; " ..
"platform_check_image %q >/dev/null"
% image_tmp

View file

@ -127,7 +127,7 @@ function upgrade()
local function image_supported()
-- XXX: yay...
return ( 0 == os.execute(
". /etc/functions.sh; " ..
". /lib/functions.sh; " ..
"include /lib/upgrade; " ..
"platform_check_image %q >/dev/null"
% tmpfile

View file

@ -274,7 +274,7 @@ msgid "in minutes from midnight"
msgstr ""
msgid "preallocation"
msgstr ""
msgstr "磁盘预分配"
msgid "uTP enabled"
msgstr ""

View file

@ -541,7 +541,7 @@ textarea {
cursor: not-allowed;
}
:-moz-placeholder {
::-moz-placeholder {
color: #bfbfbf;
}
@ -744,7 +744,7 @@ header {
right: 0;
z-index: 10000;
overflow: visible;
color: #BFBFBF
color: #BFBFBF;
}
header a {
@ -1556,7 +1556,7 @@ footer {
}
:root .alert-message, :root .btn {
border-radius: 0 \0;
border-radius: 0 0;
}
button.btn::-moz-focus-inner, input[type=submit].btn::-moz-focus-inner {