From 9252c302c1d2f3d348c1ca693e4a1eb7f1732141 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Fri, 28 Jun 2024 16:13:43 +0200 Subject: [PATCH 1/3] rename engine metadata to template_engine --- content/pages/a_page.md | 2 +- content/pages/another_page.md | 2 +- galae-content/pages/en-index.md | 2 +- galae-content/pages/fr-index.md | 2 +- galae-content/pages/generateur-enregistrements-dns.md | 2 +- galae-content/pages/temoignages-clients.md | 2 +- jssg/models.py | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/content/pages/a_page.md b/content/pages/a_page.md index d58ec84..19c7922 100644 --- a/content/pages/a_page.md +++ b/content/pages/a_page.md @@ -1,7 +1,7 @@ --- title Page1 slug page1 -engine jinja2 +template_engine jinja2 --- { diff --git a/content/pages/another_page.md b/content/pages/another_page.md index 0efd582..9e1c210 100644 --- a/content/pages/another_page.md +++ b/content/pages/another_page.md @@ -1,7 +1,7 @@ --- title Another page slug page2 -engine jinja2 +template_engine jinja2 --- { diff --git a/galae-content/pages/en-index.md b/galae-content/pages/en-index.md index 50187af..5ea1af8 100644 --- a/galae-content/pages/en-index.md +++ b/galae-content/pages/en-index.md @@ -5,7 +5,7 @@ description galae est un service e-mail éthique et libre facturé à l'usage. T language French lang en version .en -engine jinja2 +template_engine jinja2 # open graph metatada og:title galae - ethical and free pay-per-use e-mail og:description galae est un service e-mail éthique et libre facturé à l'usage. Toutes nos offres incluent des boîtes emails et domaines illimités hébergés en France. diff --git a/galae-content/pages/fr-index.md b/galae-content/pages/fr-index.md index 5bde382..2d7fd01 100644 --- a/galae-content/pages/fr-index.md +++ b/galae-content/pages/fr-index.md @@ -4,7 +4,7 @@ slug fr-index description galae est un service e-mail éthique et libre facturé à l'usage. Toutes nos offres incluent des boîtes emails et domaines illimités hébergés en France. language French lang fr -engine jinja2 +template_engine jinja2 version .fr # open graph metatada og:title galae - le service e-mail éthique et libre facturé à l'usage diff --git a/galae-content/pages/generateur-enregistrements-dns.md b/galae-content/pages/generateur-enregistrements-dns.md index a43c5b2..da462cb 100644 --- a/galae-content/pages/generateur-enregistrements-dns.md +++ b/galae-content/pages/generateur-enregistrements-dns.md @@ -4,7 +4,7 @@ description galae est un service e-mail éthique et libre facturé à l'usage. T slug generateur-enregistrements-dns language French lang fr -engine jinja2 +template_engine jinja2 header_version genenrdns og:title galae - le service e-mail éthique et libre facturé à l'usage diff --git a/galae-content/pages/temoignages-clients.md b/galae-content/pages/temoignages-clients.md index ffa64f8..09bd036 100644 --- a/galae-content/pages/temoignages-clients.md +++ b/galae-content/pages/temoignages-clients.md @@ -2,7 +2,7 @@ title Temoignages clients slug temoignages-clients lang fr -engine jinja2 +template_engine jinja2 header_version testimonial --- diff --git a/jssg/models.py b/jssg/models.py index a41f524..fe39c09 100644 --- a/jssg/models.py +++ b/jssg/models.py @@ -91,7 +91,7 @@ def convert_case(match_obj): # extras=["fenced-code-blocks", "tables"], # ) - if "engine" in self.metadata.keys() and self.metadata["engine"] == "jinja2" : + if "template_engine" in self.metadata.keys() and self.metadata["template_engine"] == "jinja2" : return engines["jinja2"].from_string(self.content).render( { "posts": sorted( From ea21ec6193020009345866efe7145a8d3b8f2449 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Mon, 8 Jul 2024 12:03:35 +0200 Subject: [PATCH 2/3] Add Jinja2 as default template engine --- jssg/models.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/jssg/models.py b/jssg/models.py index fe39c09..f27d1b3 100644 --- a/jssg/models.py +++ b/jssg/models.py @@ -91,16 +91,7 @@ def convert_case(match_obj): # extras=["fenced-code-blocks", "tables"], # ) - if "template_engine" in self.metadata.keys() and self.metadata["template_engine"] == "jinja2" : - return engines["jinja2"].from_string(self.content).render( - { - "posts": sorted( - Post.load_glob(), key=lambda p: p.timestamp, reverse=True - ), - "data":self.data - } - ) - else : + if "template_engine" in self.metadata.keys() and self.metadata["template_engine"] == "django" : return Template(self.content).render( Context( { @@ -111,6 +102,15 @@ def convert_case(match_obj): } ) ) + else : + return engines["jinja2"].from_string(self.content).render( + { + "posts": sorted( + Post.load_glob(), key=lambda p: p.timestamp, reverse=True + ), + "data":self.data + } + ) @classmethod def load(cls, path: Path) -> "Document": From 65e6e3967b346faec1934f20b6cdb1754110cc5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Mon, 8 Jul 2024 14:12:00 +0200 Subject: [PATCH 3/3] rename self.content to self.body in content_md method --- jssg/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jssg/models.py b/jssg/models.py index f27d1b3..6730e00 100644 --- a/jssg/models.py +++ b/jssg/models.py @@ -92,7 +92,7 @@ def convert_case(match_obj): # ) if "template_engine" in self.metadata.keys() and self.metadata["template_engine"] == "django" : - return Template(self.content).render( + return Template(self.body).render( Context( { "posts": sorted( @@ -103,7 +103,7 @@ def convert_case(match_obj): ) ) else : - return engines["jinja2"].from_string(self.content).render( + return engines["jinja2"].from_string(self.body).render( { "posts": sorted( Post.load_glob(), key=lambda p: p.timestamp, reverse=True