Skip to content
Snippets Groups Projects
Unverified Commit 946b42e2 authored by Martin Weinelt's avatar Martin Weinelt Committed by Matthias Schiffer
Browse files

gluon-config-mode-domain-select: allow hiding of individual domain codes

parent 85c0bd6f
No related branches found
No related tags found
No related merge requests found
need_boolean(in_domain({'hide_domain'}), false)
local valid_domain_codes = table_keys(need_table(in_domain({'domain_names'})))
alternatives(function()
need_boolean(in_domain({'hide_domain'}), false)
end, function()
need_array_of(in_domain({'hide_domain'}), valid_domain_codes, false)
end)
return function(form, uci)
local site_i18n = i18n 'gluon-site'
local fs = require 'nixio.fs'
local json = require 'jsonc'
local site = require 'gluon.site'
local util = require 'gluon.util'
local selected_domain = uci:get('gluon', 'core', 'domain')
local configured = uci:get_first('gluon-setup-mode','setup_mode', 'configured') == '1' or (selected_domain ~= site.default_domain())
local function hide_domain_code(domain, code)
if configured and code == selected_domain then
return false
elseif type(domain.hide_domain) == 'table' then
return util.contains(domain.hide_domain, code)
else
return domain.hide_domain
end
end
local function get_domain_list()
local list = {}
for domain_path in fs.glob('/lib/gluon/domains/*.json') do
local domain_code = domain_path:match('([^/]+)%.json$')
local domain = assert(json.load(domain_path))
if not domain.hide_domain or (configured and domain.domain_code == selected_domain) then
if not hide_domain_code(domain, domain_code) then
table.insert(list, {
domain_code = domain_code,
domain_name = domain.domain_names[domain_code],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment