aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas HABEGGER <andreas.habegger@bfh.ch>2023-11-19 22:36:34 +0100
committerAndreas HABEGGER <andreas.habegger@bfh.ch>2023-11-19 22:36:34 +0100
commit12caf5a526eb0f72627f6849ba96895dd505ec18 (patch)
treed12fbb635d3bb3393ac552f02f177a2603f43f1c
parent218f02cfc0453a0d4cc067ba9256123a675040ce (diff)
downloadwww_shared-12caf5a526eb0f72627f6849ba96895dd505ec18.tar.gz
www_shared-12caf5a526eb0f72627f6849ba96895dd505ec18.zip
FC: YAML multifile read; Added global variable to configure properties file
-rw-r--r--sitegen/site.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/sitegen/site.py b/sitegen/site.py
index e2b20c0..6139d1c 100644
--- a/sitegen/site.py
+++ b/sitegen/site.py
@@ -34,6 +34,8 @@ import sitegen.i18nfix as i18nfix
34from sitegen.timeutil import time_rfc822, time_now, conv_date_rfc822 34from sitegen.timeutil import time_rfc822, time_now, conv_date_rfc822
35 35
36 36
37PROPERTIES_YML = "properties.yml"
38
37def html2text(html_str): 39def html2text(html_str):
38 class extractText(html.parser.HTMLParser): 40 class extractText(html.parser.HTMLParser):
39 def __init__(self): 41 def __init__(self):
@@ -195,9 +197,16 @@ class SiteGenerator:
195 env.filters["extract_body"] = extract_body 197 env.filters["extract_body"] = extract_body
196 env.newstyle_gettext = True 198 env.newstyle_gettext = True
197 self.env = env 199 self.env = env
200 # NOTE : read-in properties.yml and afterwards all *.yml in properties.d
201 properties = {}
198 yaml = YAML(typ="safe") 202 yaml = YAML(typ="safe")
199 site_configfile = self.root / "www.yml" 203 yaml.preserve_quotes = True
200 self.config = yaml.load(site_configfile) 204 properties.update(yaml.load(self.root/PROPERTIES_YML))
205 properties_dir = PROPERTIES_YML.removesuffix('.yml') + '.d'
206 for filepath in Path(self.root/properties_dir).glob('*.yml'):
207 properties.update(yaml.load(filepath))
208 self.config = properties
209
201 self.baseurl = os.environ.get("BASEURL") 210 self.baseurl = os.environ.get("BASEURL")
202 if not self.baseurl: 211 if not self.baseurl:
203 self.baseurl = self.config["siteconf"].get("baseurl") 212 self.baseurl = self.config["siteconf"].get("baseurl")