diff --git a/content/templates/jinja2/allwidgets.html b/content/templates/jinja2/allwidgets.html index dcc18fc..166ffd4 100644 --- a/content/templates/jinja2/allwidgets.html +++ b/content/templates/jinja2/allwidgets.html @@ -19,7 +19,7 @@
diff --git a/jssg/default_metadata.txt b/jssg/default_metadata.txt new file mode 100644 index 0000000..e69de29 diff --git a/jssg/models.py b/jssg/models.py index e8e5b15..d958da9 100644 --- a/jssg/models.py +++ b/jssg/models.py @@ -21,6 +21,7 @@ from typing import Iterator, Mapping, Optional, List import markdown2 +import re from django.conf import settings from django.template import Context, Template, engines from django.utils.text import slugify @@ -58,7 +59,6 @@ def content(self) -> str: :return: the rendered document """ - import re # INFO DA 2024-02-18 - Replace "{{{ }}}" pattern into one-line pattern # this is usefull in order to exploit multi-line includes # {{{ include "block.html" with @@ -118,11 +118,16 @@ def load(cls, path: Path) -> "Document": :return: The loaded document """ _path = path - metadata = {} + metadata = settings.JFME_DEFAULT_METADATA_DICT.copy() data = {} json_data = "" content = StringIO() + with settings.JFME_DEFAULT_METADATA_PATH.open() as f: + for line in f : + key, value = map(str.strip, re.split("[\s]", line, maxsplit=1)) + metadata[key] = value + with path.open() as f: # States: # 0: search the metadata start block @@ -152,7 +157,6 @@ def load(cls, path: Path) -> "Document": # Parse a metadata key value pair # key, value = map(str.strip, line.split("", maxsplit=1)) - import re key, value = map(str.strip, re.split("[\s]", line, maxsplit=1)) # FIXME print("KEY {} : {} (line is: {})".format(key, value, line)) metadata[key] = value diff --git a/jssg/settings.py b/jssg/settings.py index a0ce03b..89fa47f 100644 --- a/jssg/settings.py +++ b/jssg/settings.py @@ -52,7 +52,8 @@ JFME_POSTS_DIRS = [path / "posts" for path in JFME_CONTENT_DIRS] JFME_TEMPLATES_DIRS = [path / "templates" for path in JFME_CONTENT_DIRS] JFME_STATIC_DIRS = [path / "static" for path in JFME_CONTENT_DIRS] - +JFME_DEFAULT_METADATA_DICT = {"slug": "index", } +JFME_DEFAULT_METADATA_PATH = BASE_DIR / "jssg" / "default_metadata.txt" # Application definition