# 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
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.
http://www.apache.org/licenses/LICENSE-2.0
-$Id$
-
]]--
module("luci.controller.luci_statistics.luci_statistics", package.seeall)
-- create toplevel menu nodes
local st = entry({"admin", "statistics"}, template("admin_statistics/index"), _("Statistics"), 80)
st.index = true
-
+
entry({"admin", "statistics", "collectd"}, cbi("luci_statistics/collectd"), _("Collectd"), 10).subindex = true
-
+
-- populate collectd plugin menu
local index = 1
-- 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 )
-- 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
local hosts = graph.tree:host_instances()
local is_index = false
+ local i, p, inst, idx
-- deliver image
if vars.img then
-- 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
$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"
+++ /dev/null
-#!/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
+++ /dev/null
-#!/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;
-}
Description:
Several common useful Lua functions
-FileId:
-$Id$
-
License:
Copyright 2008 Steven Barth <steven@midlink.org>
function _sortiter( t, f )
local keys = { }
+ local k, v
for k, v in pairs(t) do
keys[#keys+1] = k
end
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
#!/bin/sh
-. /etc/functions.sh
+. /lib/functions.sh
apply_config() {
config_get init "$1" init
%> />  
<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 %>(
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
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');
'<%=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>';
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
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
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
keepconfig=(keep_avail and http.formvalue("keepcfg") == "1")
} )
end
-end
\ No newline at end of file
+end
msgstr ""
msgid "preallocation"
-msgstr ""
+msgstr "磁盘预分配"
msgid "uTP enabled"
msgstr ""
cursor: not-allowed;
}
-:-moz-placeholder {
+::-moz-placeholder {
color: #bfbfbf;
}
right: 0;
z-index: 10000;
overflow: visible;
- color: #BFBFBF
+ color: #BFBFBF;
}
header a {
}
: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 {