From a2fc4eb8b86e1a78d3c658efb9440e1af444ad72 Mon Sep 17 00:00:00 2001 From: PlexSheep Date: Sun, 1 Oct 2023 19:33:43 +0200 Subject: [PATCH] featured filter keywords out --- gawa/blog/models.py | 8 ++ gawa/blog/templates/blog/featured.html | 106 ++++++++++++------------- gawa/start/templatetags/helper_tags.py | 23 +++--- 3 files changed, 71 insertions(+), 66 deletions(-) diff --git a/gawa/blog/models.py b/gawa/blog/models.py index 58cd154..3dc3c88 100644 --- a/gawa/blog/models.py +++ b/gawa/blog/models.py @@ -68,6 +68,12 @@ class BlogPost(Searchable): DATA_DIR = "/app/blog/data/articles" DEFAULT_LANGS = {'en': False, 'de': False} + def key_words(self) -> bool: + """ + check if the post has keywords + """ + return False + def regenerate(self): """ regenerate a object @@ -123,6 +129,8 @@ class BlogPost(Searchable): logger.debug(f"category of {self}: {category}") self.category = category + self.keywords = None + except Exception as e: logger.warning( f"could not generate metadata {self.slug} from markdown: {e}") diff --git a/gawa/blog/templates/blog/featured.html b/gawa/blog/templates/blog/featured.html index cece5d3..0a23c55 100644 --- a/gawa/blog/templates/blog/featured.html +++ b/gawa/blog/templates/blog/featured.html @@ -1,60 +1,54 @@ -{% load i18n %} {% get_current_language as LANGUAGE_CODE %} +{% load i18n %} +{% get_current_language as LANGUAGE_CODE %}
-

{% trans "Featured" %}

- diff --git a/gawa/start/templatetags/helper_tags.py b/gawa/start/templatetags/helper_tags.py index b3d66bb..e467d8a 100644 --- a/gawa/start/templatetags/helper_tags.py +++ b/gawa/start/templatetags/helper_tags.py @@ -23,16 +23,19 @@ def change_lang(context, lang="de", *args, **kwargs): logger.debug(f"changing lang from '{lang}'") - path = context['request'].get_raw_uri() - url = path try: - cur_lang: str = get_language() - url = re.sub(f"/{cur_lang}/", f"/{lang}/", url) + path = context['request'].get_raw_uri() + url = path + try: + cur_lang: str = get_language() + url = re.sub(f"/{cur_lang}/", f"/{lang}/", url) + except Exception as e: + logger.error(f"exception while building language switcher form: {e}") + logger.debug(f"this is the context: {context}") + + finally: + activate(lang) + return "%s" % url except Exception as e: - logger.error(f"exception while building language switcher form: {e}") - logger.debug(f"this is the context: {context}") - - finally: - activate(lang) - return "%s" % url + logger.error(f"passing error chain: {e}")