gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[www_shared] branch master updated (218f02c -> 72771f1)


From: gnunet
Subject: [www_shared] branch master updated (218f02c -> 72771f1)
Date: Mon, 20 Nov 2023 11:49:02 +0100

This is an automated email from the git hooks/post-receive script.

andreas-habegger pushed a change to branch master
in repository www_shared.

    from 218f02c  abstract extraction: fix whitespacing
     new 12caf5a  FC: YAML multifile read; Added global variable to configure 
properties file
     new 1d496cd  FC: YAML multifile read for translations; Added global 
variable to configure properties file
     new 72771f1  MC: YAML multifile reader for translations and configuration 
properties

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 README          | 10 ++++++++++
 list-languages  | 16 +++++++++++++---
 sitegen/site.py | 13 +++++++++++--
 3 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/README b/README
index d9650ce..04b2e19 100644
--- a/README
+++ b/README
@@ -18,6 +18,16 @@ of one website, ie this affects both websites and if in doubt
 should be tested against both as soon as both websites have
 been switched to this code.
 
+Note
+----
+YAML files are used for both translations and the Site Builder as
+content properties. The collection hierarchy is as follows
+ * First, the file "properties.yml" in the top directory is read.
+ * Second, all YAML files are collected in a directory called "properties.d".
+ * Third, the collected files are fed into the build system as a dictionary.
+Note that the name is controlled by a variable PROPERTIES_YML. The name of
+the file is linked to the name of the directory.
+
 Dependencies
 ------------
 
diff --git a/list-languages b/list-languages
index 9df48ac..c1379d2 100755
--- a/list-languages
+++ b/list-languages
@@ -1,8 +1,18 @@
 #!/usr/bin/env python3
 
-from ruamel.yaml import YAML
 from pathlib import Path
+from ruamel.yaml import YAML
+
+PROPERTIES_YML = "properties.yml"
+
+# NOTE : read-in properties.yml and afterwards all *.yml in properties.d
+properties = {}
 yaml = YAML(typ="safe")
-config = yaml.load(Path("www.yml"))
-langs = config["langs_full"]
+yaml.preserve_quotes = True
+properties.update(yaml.load(Path(PROPERTIES_YML)))
+properties_dir =  PROPERTIES_YML.removesuffix('.yml') + '.d'
+for filepath in Path(properties_dir).glob('*.yml'):
+    properties.update(yaml.load(filepath))
+
+langs = properties["langs_full"]
 print(" ".join(langs))
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
 from sitegen.timeutil import time_rfc822, time_now, conv_date_rfc822
 
 
+PROPERTIES_YML = "properties.yml"
+
 def html2text(html_str):
     class extractText(html.parser.HTMLParser):
         def __init__(self):
@@ -195,9 +197,16 @@ class SiteGenerator:
         env.filters["extract_body"] = extract_body
         env.newstyle_gettext = True
         self.env = env
+        # NOTE : read-in properties.yml and afterwards all *.yml in 
properties.d
+        properties = {}
         yaml = YAML(typ="safe")
-        site_configfile = self.root / "www.yml"
-        self.config = yaml.load(site_configfile)
+        yaml.preserve_quotes = True
+        properties.update(yaml.load(self.root/PROPERTIES_YML))
+        properties_dir =  PROPERTIES_YML.removesuffix('.yml') + '.d'
+        for filepath in Path(self.root/properties_dir).glob('*.yml'):
+            properties.update(yaml.load(filepath))
+        self.config = properties
+
         self.baseurl = os.environ.get("BASEURL")
         if not self.baseurl:
             self.baseurl = self.config["siteconf"].get("baseurl")

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]