gluon-core: add domain aliases and pretty name

Based-on-patch-by: lemoer <git@irrelefant.net>
This commit is contained in:
Matthias Schiffer 2018-01-20 06:22:26 +01:00
parent 2ef0af5fe8
commit 6ae067cb37
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C
3 changed files with 25 additions and 0 deletions

View File

@ -13,6 +13,12 @@ if this_domain() then
end, nil, 'be a valid domain name')
end
need_domain_name(in_site({'default_domain'}))
need_table(in_domain({'domain_names'}), function(domain)
need_alphanumeric_key(domain)
need_string(domain)
end)
need_string(in_domain({'domain_names', this_domain()}))
end
need_string_match(in_domain({'domain_seed'}), '^' .. ('%x'):rep(64) .. '$')

View File

@ -53,9 +53,15 @@ define Build/Compile
$(call GenerateJSON,site)
ifdef CONFIG_GLUON_MULTIDOMAIN
rm -rf $(PKG_BUILD_DIR)/domains
mkdir -p $(PKG_BUILD_DIR)/domains
$(foreach domain,$(patsubst $(GLUON_SITEDIR)/domains/%.conf,%,$(wildcard $(GLUON_SITEDIR)/domains/*.conf)),
[ ! -e '$(PKG_BUILD_DIR)/domains/$(domain).json' ]
$(call GenerateJSON,domains/$(domain))
lua ../../scripts/domain_aliases.lua '$(PKG_BUILD_DIR)/domains/$(domain).json' | while read alias; do \
[ "$$$${alias}" != '$(domain)' ] || continue; \
ln -s '$(domain).json' $(PKG_BUILD_DIR)/domains/$$$${alias}.json || exit 1; \
done
)
endif

View File

@ -0,0 +1,13 @@
local cjson = require 'cjson'
local function load_json(filename)
local f = assert(io.open(filename))
local json = cjson.decode(f:read('*a'))
f:close()
return json
end
local domain = load_json(arg[1])
for k, _ in pairs(domain.domain_names) do
print(k)
end