From 951f62ac8550889527c4421176b9d967a5179aad Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 8 Aug 2017 13:50:41 +0200 Subject: [PATCH] gluon-config-mode-*, gluon-web-admin: use new gluon.site library to avoid 'or {}' syntax --- .../lib/gluon/config-mode/wizard/0500-contact-info.lua | 4 ++-- .../lib/gluon/config-mode/wizard/0400-geo-location.lua | 4 ++-- .../luasrc/lib/gluon/web/model/admin/remote.lua | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package/gluon-config-mode-contact-info/luasrc/lib/gluon/config-mode/wizard/0500-contact-info.lua b/package/gluon-config-mode-contact-info/luasrc/lib/gluon/config-mode/wizard/0500-contact-info.lua index 300c46fa..4a3f3e81 100644 --- a/package/gluon-config-mode-contact-info/luasrc/lib/gluon/config-mode/wizard/0500-contact-info.lua +++ b/package/gluon-config-mode-contact-info/luasrc/lib/gluon/config-mode/wizard/0500-contact-info.lua @@ -1,5 +1,5 @@ return function(form, uci) - local site = require 'gluon.site_config' + local site = require 'gluon.site' local owner = uci:get_first("gluon-node-info", "owner") @@ -12,7 +12,7 @@ return function(form, uci) local o = s:option(Value, "contact", translate("Contact info"), translate("e.g. E-mail or phone number")) o.default = uci:get("gluon-node-info", owner, "contact") - o.optional = not ((site.config_mode or {}).owner or {}).obligatory + o.optional = not site.config_mode.owner.obligatory(false) -- without a minimal length, an empty string will be accepted even with "optional = false" o.datatype = "minlength(1)" function o:write(data) diff --git a/package/gluon-config-mode-geo-location/luasrc/lib/gluon/config-mode/wizard/0400-geo-location.lua b/package/gluon-config-mode-geo-location/luasrc/lib/gluon/config-mode/wizard/0400-geo-location.lua index c283a885..41b346d8 100644 --- a/package/gluon-config-mode-geo-location/luasrc/lib/gluon/config-mode/wizard/0400-geo-location.lua +++ b/package/gluon-config-mode-geo-location/luasrc/lib/gluon/config-mode/wizard/0400-geo-location.lua @@ -1,10 +1,10 @@ return function(form, uci) - local site = require 'gluon.site_config' + local site = require 'gluon.site' local location = uci:get_first("gluon-node-info", "location") local function show_altitude() - if ((site.config_mode or {}).geo_location or {}).show_altitude ~= false then + if site.config_mode.geo_location.show_altitude(true) then return true end diff --git a/package/gluon-web-admin/luasrc/lib/gluon/web/model/admin/remote.lua b/package/gluon-web-admin/luasrc/lib/gluon/web/model/admin/remote.lua index 38abc97a..52c29ab0 100644 --- a/package/gluon-web-admin/luasrc/lib/gluon/web/model/admin/remote.lua +++ b/package/gluon-web-admin/luasrc/lib/gluon/web/model/admin/remote.lua @@ -13,7 +13,7 @@ You may obtain a copy of the License at local nixio = require "nixio" local fs = require "nixio.fs" local util = require "gluon.util" -local site = require 'gluon.site_config' +local site = require "gluon.site" local f_keys = Form(translate("SSH keys"), translate("You can provide your SSH keys here (one per line):"), 'keys') local s = f_keys:section(Section) @@ -31,13 +31,13 @@ function keys:write(value) end end -local config = (site.config_mode or {}).remote_login or {} -if not config.show_password_form then +local config = site.config_mode.remote_login +if not config.show_password_form(false) then -- password login is disabled in site.conf return f_keys end -local min_password_length = config.min_password_length or 12 +local min_password_length = config.min_password_length(12) local mintype = 'minlength(' .. min_password_length .. ')' local length_hint