treewide: removed trailing whitespaces and extra newlines in 'modules'

Signed-off-by: Giovanni Giacobbi <giovanni@giacobbi.net>
This commit is contained in:
Giovanni Giacobbi 2021-01-16 15:30:03 +01:00 committed by Hannu Nyman
parent d3280e6f5d
commit af422b1924
17 changed files with 59 additions and 62 deletions

View File

@ -61,7 +61,7 @@ function cache_enable(cachepath, mode)
package.loaders[2] = function(mod) package.loaders[2] = function(mod)
local encoded = cachepath .. "/" .. _encode_filename(mod) local encoded = cachepath .. "/" .. _encode_filename(mod)
local modcons = _load_sane(encoded) local modcons = _load_sane(encoded)
if modcons then if modcons then
return modcons return modcons
end end

View File

@ -35,11 +35,11 @@ function run()
limitsource(io.stdin, tonumber(luci.sys.getenv("CONTENT_LENGTH"))), limitsource(io.stdin, tonumber(luci.sys.getenv("CONTENT_LENGTH"))),
ltn12.sink.file(io.stderr) ltn12.sink.file(io.stderr)
) )
local x = coroutine.create(luci.dispatcher.httpdispatch) local x = coroutine.create(luci.dispatcher.httpdispatch)
local hcache = "" local hcache = ""
local active = true local active = true
while coroutine.status(x) ~= "dead" do while coroutine.status(x) ~= "dead" do
local res, id, data1, data2 = coroutine.resume(x, r) local res, id, data1, data2 = coroutine.resume(x, r)

View File

@ -53,7 +53,7 @@ function Template.__init__(self, name, template)
-- Create a new namespace for this template -- Create a new namespace for this template
self.viewns = context.viewns self.viewns = context.viewns
-- If we have a cached template, skip compiling and loading -- If we have a cached template, skip compiling and loading
if not self.template then if not self.template then
@ -84,13 +84,13 @@ end
-- Renders a template -- Renders a template
function Template.render(self, scope) function Template.render(self, scope)
scope = scope or getfenv(2) scope = scope or getfenv(2)
-- Put our predefined objects in the scope of the template -- Put our predefined objects in the scope of the template
setfenv(self.template, setmetatable({}, {__index = setfenv(self.template, setmetatable({}, {__index =
function(tbl, key) function(tbl, key)
return rawget(tbl, key) or self.viewns[key] or scope[key] return rawget(tbl, key) or self.viewns[key] or scope[key]
end})) end}))
-- Now finally render the thing -- Now finally render the thing
local stat, err = util.copcall(self.template) local stat, err = util.copcall(self.template)
if not stat then if not stat then

View File

@ -43,4 +43,3 @@ function proto.contains_interface(self, ifc)
end end
netmod:register_pattern_virtual("^vpn%-%w") netmod:register_pattern_virtual("^vpn%-%w")

View File

@ -14,8 +14,8 @@ function byte_format(byte)
if byte > 1024 and i < 5 then if byte > 1024 and i < 5 then
byte = byte / 1024 byte = byte / 1024
else else
return string.format("%.2f %s", byte, suff[i]) return string.format("%.2f %s", byte, suff[i])
end end
end end
end end
@ -24,23 +24,23 @@ function date_format(secs)
local mins = 0 local mins = 0
local hour = 0 local hour = 0
local days = 0 local days = 0
secs = math.floor(secs) secs = math.floor(secs)
if secs > 60 then if secs > 60 then
mins = math.floor(secs / 60) mins = math.floor(secs / 60)
secs = secs % 60 secs = secs % 60
end end
if mins > 60 then if mins > 60 then
hour = math.floor(mins / 60) hour = math.floor(mins / 60)
mins = mins % 60 mins = mins % 60
end end
if hour > 24 then if hour > 24 then
days = math.floor(hour / 24) days = math.floor(hour / 24)
hour = hour % 24 hour = hour % 24
end end
if days > 0 then if days > 0 then
return string.format("%.0fd %02.0fh %02.0fmin %02.0fs", days, hour, mins, secs) return string.format("%.0fd %02.0fh %02.0fmin %02.0fs", days, hour, mins, secs)
else else
@ -70,15 +70,15 @@ end
function firewall_find_zone(name) function firewall_find_zone(name)
local find local find
luci.model.uci.cursor():foreach("firewall", "zone", luci.model.uci.cursor():foreach("firewall", "zone",
function (section) function (section)
if section.name == name then if section.name == name then
find = section[".name"] find = section[".name"]
end end
end end
) )
return find return find
end end

View File

@ -10,14 +10,14 @@ function index()
root.target = alias("mini") root.target = alias("mini")
root.index = true root.index = true
end end
entry({"about"}, template("about")) entry({"about"}, template("about"))
local page = entry({"mini"}, alias("mini", "index"), _("Essentials"), 10) local page = entry({"mini"}, alias("mini", "index"), _("Essentials"), 10)
page.sysauth = "root" page.sysauth = "root"
page.sysauth_authenticator = "htmlauth" page.sysauth_authenticator = "htmlauth"
page.index = true page.index = true
entry({"mini", "index"}, alias("mini", "index", "index"), _("Overview"), 10).index = true entry({"mini", "index"}, alias("mini", "index", "index"), _("Overview"), 10).index = true
entry({"mini", "index", "index"}, form("mini/index"), _("General"), 1).ignoreindex = true entry({"mini", "index", "index"}, form("mini/index"), _("General"), 1).ignoreindex = true
entry({"mini", "index", "luci"}, cbi("mini/luci", {autoapply=true}), _("Settings"), 10) entry({"mini", "index", "luci"}, cbi("mini/luci", {autoapply=true}), _("Settings"), 10)

View File

@ -17,8 +17,8 @@ function action_backup()
local reset_avail = os.execute([[grep '"rootfs_data"' /proc/mtd >/dev/null 2>&1]]) == 0 local reset_avail = os.execute([[grep '"rootfs_data"' /proc/mtd >/dev/null 2>&1]]) == 0
local restore_cmd = "gunzip | tar -xC/ >/dev/null 2>&1" local restore_cmd = "gunzip | tar -xC/ >/dev/null 2>&1"
local backup_cmd = "tar -c %s | gzip 2>/dev/null" local backup_cmd = "tar -c %s | gzip 2>/dev/null"
local restore_fpi local restore_fpi
luci.http.setfilehandler( luci.http.setfilehandler(
function(meta, chunk, eof) function(meta, chunk, eof)
if not restore_fpi then if not restore_fpi then
@ -32,11 +32,11 @@ function action_backup()
end end
end end
) )
local upload = luci.http.formvalue("archive") local upload = luci.http.formvalue("archive")
local backup = luci.http.formvalue("backup") local backup = luci.http.formvalue("backup")
local reset = reset_avail and luci.http.formvalue("reset") local reset = reset_avail and luci.http.formvalue("reset")
if upload and #upload > 0 then if upload and #upload > 0 then
luci.template.render("mini/applyreboot") luci.template.render("mini/applyreboot")
luci.sys.reboot() luci.sys.reboot()
@ -66,7 +66,7 @@ function action_upgrade()
require("luci.model.uci") require("luci.model.uci")
local tmpfile = "/tmp/firmware.img" local tmpfile = "/tmp/firmware.img"
local function image_supported() local function image_supported()
-- XXX: yay... -- XXX: yay...
return ( 0 == os.execute( return ( 0 == os.execute(
@ -76,11 +76,11 @@ function action_upgrade()
% tmpfile % tmpfile
) ) ) )
end end
local function image_checksum() local function image_checksum()
return (luci.sys.exec("md5sum %q" % tmpfile):match("^([^%s]+)")) return (luci.sys.exec("md5sum %q" % tmpfile):match("^([^%s]+)"))
end end
local function storage_size() local function storage_size()
local size = 0 local size = 0
if nixio.fs.access("/proc/mtd") then if nixio.fs.access("/proc/mtd") then
@ -128,9 +128,9 @@ function action_upgrade()
local has_support = image_supported() local has_support = image_supported()
local has_platform = nixio.fs.access("/lib/upgrade/platform.sh") local has_platform = nixio.fs.access("/lib/upgrade/platform.sh")
local has_upload = luci.http.formvalue("image") local has_upload = luci.http.formvalue("image")
-- This does the actual flashing which is invoked inside an iframe -- This does the actual flashing which is invoked inside an iframe
-- so don't produce meaningful errors here because the the -- so don't produce meaningful errors here because the the
-- previous pages should arrange the stuff as required. -- previous pages should arrange the stuff as required.
if step == 4 then if step == 4 then
if has_platform and has_image and has_support then if has_platform and has_image and has_support then
@ -163,7 +163,7 @@ function action_upgrade()
if has_image then if has_image then
nixio.fs.unlink(tmpfile) nixio.fs.unlink(tmpfile)
end end
luci.template.render("mini/upgrade", { luci.template.render("mini/upgrade", {
step=1, step=1,
bad_image=(has_image and not has_support or false), bad_image=(has_image and not has_support or false),
@ -180,14 +180,14 @@ function action_upgrade()
flashsize=storage_size(), flashsize=storage_size(),
keepconfig=(keep_avail and luci.http.formvalue("keepcfg") == "1") keepconfig=(keep_avail and luci.http.formvalue("keepcfg") == "1")
} ) } )
-- Step 3: load iframe which calls the actual flash procedure -- Step 3: load iframe which calls the actual flash procedure
elseif step == 3 then elseif step == 3 then
luci.template.render("mini/upgrade", { luci.template.render("mini/upgrade", {
step=3, step=3,
keepconfig=(keep_avail and luci.http.formvalue("keepcfg") == "1") keepconfig=(keep_avail and luci.http.formvalue("keepcfg") == "1")
} ) } )
end end
end end
function _keep_pattern() function _keep_pattern()

View File

@ -30,15 +30,15 @@ limit:depends("ignore", "0")
function limit.cfgvalue(self, section) function limit.cfgvalue(self, section)
local value = Value.cfgvalue(self, section) local value = Value.cfgvalue(self, section)
if value then if value then
return tonumber(value) + 1 return tonumber(value) + 1
end end
end end
function limit.write(self, section, value) function limit.write(self, section, value)
value = tonumber(value) - 1 value = tonumber(value) - 1
return Value.write(self, section, value) return Value.write(self, section, value)
end end
limit.rmempty = true limit.rmempty = true
@ -53,7 +53,7 @@ uci:foreach("dhcp", "dnsmasq",
function(section) function(section)
leasefn = section.leasefile leasefn = section.leasefile
end end
) )
local leasefp = leasefn and fs.access(leasefn) and io.lines(leasefn) local leasefp = leasefn and fs.access(leasefn) and io.lines(leasefn)
if leasefp then if leasefp then
leases = {} leases = {}

View File

@ -19,13 +19,13 @@ end
function f.handle(self, state, data) function f.handle(self, state, data)
if state == FORM_VALID then if state == FORM_VALID then
local stat = luci.sys.user.setpasswd("root", data.pw1) == 0 local stat = luci.sys.user.setpasswd("root", data.pw1) == 0
if stat then if stat then
f.message = translate("Password successfully changed") f.message = translate("Password successfully changed")
else else
f.errmessage = translate("Unknown Error") f.errmessage = translate("Unknown Error")
end end
data.pw1 = nil data.pw1 = nil
data.pw2 = nil data.pw2 = nil
end end

View File

@ -242,7 +242,7 @@ if hwtype == "mac80211" then
encr.description = translate( encr.description = translate(
"WPA-Encryption requires wpa_supplicant (for client mode) or hostapd (for AP " .. "WPA-Encryption requires wpa_supplicant (for client mode) or hostapd (for AP " ..
"and ad-hoc mode) to be installed." "and ad-hoc mode) to be installed."
) )
else else
encr.description = translate( encr.description = translate(
"WPA-Encryption requires wpa_supplicant (for client mode) or hostapd (for AP " .. "WPA-Encryption requires wpa_supplicant (for client mode) or hostapd (for AP " ..

View File

@ -284,7 +284,7 @@ return view.extend({
o = s.taboption('general', form.DynamicList, 'address', _('Addresses'), o = s.taboption('general', form.DynamicList, 'address', _('Addresses'),
_('List of domains to force to an IP address.')); _('List of domains to force to an IP address.'));
o.optional = true; o.optional = true;
o.placeholder = '/router.local/192.168.0.1'; o.placeholder = '/router.local/192.168.0.1';

View File

@ -895,7 +895,7 @@ return view.extend({
o = ss.taboption('advanced', CBIWifiCountryValue, 'country', _('Country Code')); o = ss.taboption('advanced', CBIWifiCountryValue, 'country', _('Country Code'));
o.wifiNetwork = radioNet; o.wifiNetwork = radioNet;
o = ss.taboption('advanced', form.ListValue, 'cell_density', _('Coverage cell density'), _('Configures data rates based on the coverage cell density. Normal configures basic rates to 6, 12, 24 Mbps if legacy 802.11b rates are not used else to 5.5, 11 Mbps. High configures basic rates to 12, 24 Mbps if legacy 802.11b rates are not used else to the 11 Mbps rate. Very High configures 24 Mbps as the basic rate. Supported rates lower than the minimum basic rate are not offered.')); o = ss.taboption('advanced', form.ListValue, 'cell_density', _('Coverage cell density'), _('Configures data rates based on the coverage cell density. Normal configures basic rates to 6, 12, 24 Mbps if legacy 802.11b rates are not used else to 5.5, 11 Mbps. High configures basic rates to 12, 24 Mbps if legacy 802.11b rates are not used else to the 11 Mbps rate. Very High configures 24 Mbps as the basic rate. Supported rates lower than the minimum basic rate are not offered.'));
o.value('0', _('Disabled')); o.value('0', _('Disabled'));
o.value('1', _('Normal')); o.value('1', _('Normal'));

View File

@ -7,7 +7,7 @@ require "luci.json"
function resolve(mod, method) function resolve(mod, method)
local path = luci.util.split(method, ".") local path = luci.util.split(method, ".")
for j=1, #path-1 do for j=1, #path-1 do
if not type(mod) == "table" then if not type(mod) == "table" then
break break
@ -29,7 +29,7 @@ function handle(tbl, rawsource, ...)
local json = decoder:get() local json = decoder:get()
local response local response
local success = false local success = false
if stat then if stat then
if type(json.method) == "string" if type(json.method) == "string"
and (not json.params or type(json.params) == "table") then and (not json.params or type(json.params) == "table") then
@ -56,23 +56,23 @@ end
function reply(jsonrpc, id, res, err) function reply(jsonrpc, id, res, err)
require "luci.json" require "luci.json"
id = id or luci.json.null id = id or luci.json.null
-- 1.0 compatibility -- 1.0 compatibility
if jsonrpc ~= "2.0" then if jsonrpc ~= "2.0" then
jsonrpc = nil jsonrpc = nil
res = res or luci.json.null res = res or luci.json.null
err = err or luci.json.null err = err or luci.json.null
end end
return {id=id, result=res, error=err, jsonrpc=jsonrpc} return {id=id, result=res, error=err, jsonrpc=jsonrpc}
end end
function proxy(method, ...) function proxy(method, ...)
local res = {luci.util.copcall(method, ...)} local res = {luci.util.copcall(method, ...)}
local stat = table.remove(res, 1) local stat = table.remove(res, 1)
if not stat then if not stat then
return nil, {code=-32602, message="Invalid params.", data=table.remove(res, 1)} return nil, {code=-32602, message="Invalid params.", data=table.remove(res, 1)}
else else
if #res <= 1 then if #res <= 1 then
return res[1] or luci.json.null return res[1] or luci.json.null

View File

@ -29,19 +29,19 @@ function commit(config)
end end
function delete(config, ...) function delete(config, ...)
uci:load(config) uci:load(config)
return uci:delete(config, ...) and uci:save(config) return uci:delete(config, ...) and uci:save(config)
end end
function delete_all(config, ...) function delete_all(config, ...)
uci:load(config) uci:load(config)
return uci:delete_all(config, ...) and uci:save(config) return uci:delete_all(config, ...) and uci:save(config)
end end
function foreach(config, stype) function foreach(config, stype)
uci:load(config) uci:load(config)
local sections = {} local sections = {}
return uci:foreach(config, stype, function(section) return uci:foreach(config, stype, function(section)
table.insert(sections, section) table.insert(sections, section)
end) and sections end) and sections
@ -80,4 +80,3 @@ function tset(config, ...)
uci:load(config) uci:load(config)
return uci:tset(config, ...) and uci:save(config) return uci:tset(config, ...) and uci:save(config)
end end

View File

@ -388,7 +388,7 @@ return view.extend({
tab: tab, tab: tab,
}; };
this.radios[ifname+freq] = { this.radios[ifname+freq] = {
dev: wifiDevs[ifname].dev, dev: wifiDevs[ifname].dev,
graph: graph_data, graph: graph_data,
table: table, table: table,

View File

@ -29,14 +29,14 @@ return baseclass.extend({
ht = rt.ht, vht = rt.vht, ht = rt.ht, vht = rt.vht,
mhz = rt.mhz, nss = rt.nss, mhz = rt.mhz, nss = rt.nss,
mcs = rt.mcs, sgi = rt.short_gi; mcs = rt.mcs, sgi = rt.short_gi;
if (ht || vht) { if (ht || vht) {
if (vht) s += ', VHT-MCS\xa0%d'.format(mcs); if (vht) s += ', VHT-MCS\xa0%d'.format(mcs);
if (nss) s += ', VHT-NSS\xa0%d'.format(nss); if (nss) s += ', VHT-NSS\xa0%d'.format(nss);
if (ht) s += ', MCS\xa0%s'.format(mcs); if (ht) s += ', MCS\xa0%s'.format(mcs);
if (sgi) s += ', ' + _('Short GI').replace(/ /g, '\xa0'); if (sgi) s += ', ' + _('Short GI').replace(/ /g, '\xa0');
} }
return s; return s;
}, },
@ -99,12 +99,12 @@ return baseclass.extend({
freq = null, freq = null,
rate = null, rate = null,
badges = []; badges = [];
for (var i = 0; i < networks.length; i++) { for (var i = 0; i < networks.length; i++) {
var net = networks[i], var net = networks[i],
is_assoc = (net.getBSSID() != '00:00:00:00:00:00' && net.getChannel() && !net.isDisabled()), is_assoc = (net.getBSSID() != '00:00:00:00:00:00' && net.getChannel() && !net.isDisabled()),
quality = net.getSignalPercent(); quality = net.getSignalPercent();
var icon; var icon;
if (net.isDisabled()) if (net.isDisabled())
icon = L.resource('icons/signal-none.png'); icon = L.resource('icons/signal-none.png');
@ -134,7 +134,7 @@ return baseclass.extend({
}, [ _('Start WPS') ]) }, [ _('Start WPS') ])
} }
} }
var badge = renderBadge( var badge = renderBadge(
icon, icon,
'%s: %d dBm / %s: %d%%'.format(_('Signal'), net.getSignal(), _('Quality'), quality), '%s: %d dBm / %s: %d%%'.format(_('Signal'), net.getSignal(), _('Quality'), quality),
@ -147,14 +147,14 @@ return baseclass.extend({
_('WPS status'), this.WPSTranslateTbl[net.wps_status], _('WPS status'), this.WPSTranslateTbl[net.wps_status],
'', WPS_button '', WPS_button
); );
badges.push(badge); badges.push(badge);
chan = (chan != null) ? chan : net.getChannel(); chan = (chan != null) ? chan : net.getChannel();
freq = (freq != null) ? freq : net.getFrequency(); freq = (freq != null) ? freq : net.getFrequency();
rate = (rate != null) ? rate : net.getBitRate(); rate = (rate != null) ? rate : net.getBitRate();
} }
return E('div', { class: 'ifacebox' }, [ return E('div', { class: 'ifacebox' }, [
E('div', { class: 'ifacebox-head center ' + (radio.isUp() ? 'active' : '') }, E('div', { class: 'ifacebox-head center ' + (radio.isUp() ? 'active' : '') },
E('strong', radio.getName())), E('strong', radio.getName())),
@ -340,7 +340,7 @@ return baseclass.extend({
}).render() }).render()
) )
} }
else { else {
row.push(E('button', { row.push(E('button', {
'class': 'cbi-button cbi-button-remove', 'class': 'cbi-button cbi-button-remove',
'click': L.bind(this.handleDelClient, this, networks[i], bss.mac) 'click': L.bind(this.handleDelClient, this, networks[i], bss.mac)

View File

@ -215,4 +215,3 @@ return view.extend({
handleSave: null, handleSave: null,
handleReset: null handleReset: null
}); });