Skip to content

Commit

Permalink
Add JFME_DEFAULT_METADATA_DICT and JFME_DEFAULT_METADATA_PATH settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Clément committed Jul 18, 2024
1 parent 1b67b84 commit eea17aa
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion content/templates/jinja2/allwidgets.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<div class="navbar__container__right">
<a class="btn btn-sm btn-primary" href="{{ CTA_URL }}"
target="{{ CTA_TARGET }}">{{ CTA_LABEL }}</a>
<a href="{{ url('page', args=[CHANGE_LANG_URL]) }}">
<a href="{{ url_for_slug_path(CHANGE_LANG_URL) }}">
<img class="languageFlag" src="{{ static(CHANGE_LANG_FLAG_URL)}}" alt="{{ CHANGE_LANG_ALT }}"/>
</a>
</div>
Expand Down
Empty file added jssg/default_metadata.txt
Empty file.
10 changes: 7 additions & 3 deletions jssg/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion jssg/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit eea17aa

Please sign in to comment.