From 8cb03884166b2ffc223b888d722ef7e8ebe9b577 Mon Sep 17 00:00:00 2001
From: Matthias Schiffer <mschiffer@universe-factory.net>
Date: Sat, 20 Jan 2018 05:32:18 +0100
Subject: [PATCH] scripts/check_site.lua: enable in_site()/in_domain() checks

---
 scripts/check_site.lua | 34 +++++++++++++++++++++-------------
 1 file changed, 21 insertions(+), 13 deletions(-)

diff --git a/scripts/check_site.lua b/scripts/check_site.lua
index 0972fd70c..6d1603a04 100644
--- a/scripts/check_site.lua
+++ b/scripts/check_site.lua
@@ -63,19 +63,6 @@ local function merge(a, b)
 end
 
 
-function in_site(var)
-	return var
-end
-
-function in_domain(var)
-	return var
-end
-
-function this_domain()
-	return domain_code
-end
-
-
 local function path_to_string(path)
 	return table.concat(path, '/')
 end
@@ -118,6 +105,27 @@ local function var_error(path, val, msg)
 end
 
 
+function in_site(path)
+	if has_domains and loadpath(nil, domain, unpack(path)) ~= nil then
+		exit_error(domain_src(), '%s is allowed in site configuration only', path_to_string(path))
+	end
+
+	return path
+end
+
+function in_domain(path)
+	if has_domains and loadpath(nil, site, unpack(path)) ~= nil then
+		exit_error(site_src(), '%s is allowed in domain configuration only', path_to_string(path))
+	end
+
+	return path
+end
+
+function this_domain()
+	return domain_code
+end
+
+
 function extend(path, c)
 	if not path then return nil end
 
-- 
GitLab