gluon-core: add domain aliases and pretty name
Based-on-patch-by: lemoer <git@irrelefant.net>
This commit is contained in:
parent
2ef0af5fe8
commit
6ae067cb37
@ -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) .. '$')
|
||||
|
@ -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
|
||||
|
||||
|
13
scripts/domain_aliases.lua
Normal file
13
scripts/domain_aliases.lua
Normal 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
|
Loading…
Reference in New Issue
Block a user