blog-markdown #31
|
@ -68,6 +68,12 @@ class BlogPost(Searchable):
|
||||||
DATA_DIR = "/app/blog/data/articles"
|
DATA_DIR = "/app/blog/data/articles"
|
||||||
DEFAULT_LANGS = {'en': False, 'de': False}
|
DEFAULT_LANGS = {'en': False, 'de': False}
|
||||||
|
|
||||||
|
def key_words(self) -> bool:
|
||||||
|
"""
|
||||||
|
check if the post has keywords
|
||||||
|
"""
|
||||||
|
return False
|
||||||
|
|
||||||
def regenerate(self):
|
def regenerate(self):
|
||||||
"""
|
"""
|
||||||
regenerate a object
|
regenerate a object
|
||||||
|
@ -123,6 +129,8 @@ class BlogPost(Searchable):
|
||||||
logger.debug(f"category of {self}: {category}")
|
logger.debug(f"category of {self}: {category}")
|
||||||
self.category = category
|
self.category = category
|
||||||
|
|
||||||
|
self.keywords = None
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
f"could not generate metadata {self.slug} from markdown: {e}")
|
f"could not generate metadata {self.slug} from markdown: {e}")
|
||||||
|
|
|
@ -1,39 +1,30 @@
|
||||||
{% load i18n %} {% get_current_language as LANGUAGE_CODE %}
|
{% load i18n %}
|
||||||
|
{% get_current_language as LANGUAGE_CODE %}
|
||||||
<div class="container-lg mt-5">
|
<div class="container-lg mt-5">
|
||||||
<h4 class="">{% trans "Featured" %}</h4>
|
<h4 class="">{% trans "Featured" %}</h4>
|
||||||
<div class="row row-cols-1 row-cols-md-5 my-4">
|
<div class="row row-cols-1 row-cols-md-5 my-4">
|
||||||
{% for post in featured_posts %}
|
{% for post in featured_posts %}
|
||||||
<div class="card col m-2 p-0">
|
<div class="card col m-2 p-0">
|
||||||
<a
|
<a class="text-reset link-offset-2 link-underline link-underline-opacity-0"
|
||||||
class="text-reset link-offset-2 link-underline link-underline-opacity-0"
|
href=" {% url 'blog:post' post.category.slug post.slug %}">
|
||||||
href=" {% url 'blog:post' post.category.slug post.slug %}"
|
<img src="{{ post.thumbnail.url }}"
|
||||||
>
|
|
||||||
<img
|
|
||||||
src="{{ post.thumbnail.url }}"
|
|
||||||
class="card-img-top img-fluid"
|
class="card-img-top img-fluid"
|
||||||
style="max-height: 150px"
|
style="max-height: 150px"
|
||||||
alt="thumbnail"
|
alt="thumbnail" />
|
||||||
/>
|
|
||||||
<div class="card-body" style="height: 100px">
|
<div class="card-body" style="height: 100px">
|
||||||
{% if LANGUAGE_CODE == "de" %}
|
{% if LANGUAGE_CODE == "de" %}
|
||||||
<h5 class="card-title">
|
<h5 class="card-title">
|
||||||
{{ post.title_de }}<small class="text-body-secondary"
|
{{ post.title_de }}<small class="text-body-secondary">{{ post.subtitle }}</small>
|
||||||
>{{ post.subtitle }}</small
|
|
||||||
>
|
|
||||||
</h5>
|
</h5>
|
||||||
<p class="card-text">{{ post.desc_de }}</p>
|
<p class="card-text">{{ post.desc_de }}</p>
|
||||||
{% elif LANGUAGE_CODE == "en" %}
|
{% elif LANGUAGE_CODE == "en" %}
|
||||||
<h5 class="card-title">
|
<h5 class="card-title">
|
||||||
{{ post.title_en }}<small class="text-body-secondary"
|
{{ post.title_en }}<small class="text-body-secondary">{{ post.subtitle }}</small>
|
||||||
>{{ post.subtitle }}</small
|
|
||||||
>
|
|
||||||
</h5>
|
</h5>
|
||||||
<p class="card-text">{{ post.desc_en }}</p>
|
<p class="card-text">{{ post.desc_en }}</p>
|
||||||
{% else %}
|
{% else %}
|
||||||
<h5 class="card-title">
|
<h5 class="card-title">
|
||||||
{{ post.title_en }}<small class="text-body-secondary"
|
{{ post.title_en }}<small class="text-body-secondary">{{ post.subtitle }}</small>
|
||||||
>{{ post.subtitle }}</small
|
|
||||||
>
|
|
||||||
</h5>
|
</h5>
|
||||||
<p class="card-text">{{ post.desc_en }}</p>
|
<p class="card-text">{{ post.desc_en }}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -43,14 +34,17 @@
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
{% translate "category" %}: <b>{{ post.category.name }}</b>
|
{% translate "category" %}: <b>{{ post.category.name }}</b>
|
||||||
</li>
|
</li>
|
||||||
{% for keyword in post.keywords.all %} {% if LANGUAGE_CODE == "de"
|
{% if post.has_keywords %}
|
||||||
%}
|
{% for keyword in post.keywords.all %}
|
||||||
|
{% if LANGUAGE_CODE == "de" %}
|
||||||
<li class="list-group-item">{{ keyword.text_de }}</li>
|
<li class="list-group-item">{{ keyword.text_de }}</li>
|
||||||
{% elif LANGUAGE_CODE == "en" %}
|
{% elif LANGUAGE_CODE == "en" %}
|
||||||
<li class="list-group-item">{{ keyword.text_en }}</li>
|
<li class="list-group-item">{{ keyword.text_en }}</li>
|
||||||
{% else %}
|
{% else %}
|
||||||
<li class="list-group-item">{{ keyword.text_en }}</li>
|
<li class="list-group-item">{{ keyword.text_en }}</li>
|
||||||
{% endif %} {% endfor %}
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -23,6 +23,7 @@ def change_lang(context, lang="de", *args, **kwargs):
|
||||||
|
|
||||||
logger.debug(f"changing lang from '{lang}'")
|
logger.debug(f"changing lang from '{lang}'")
|
||||||
|
|
||||||
|
try:
|
||||||
path = context['request'].get_raw_uri()
|
path = context['request'].get_raw_uri()
|
||||||
url = path
|
url = path
|
||||||
try:
|
try:
|
||||||
|
@ -36,3 +37,5 @@ def change_lang(context, lang="de", *args, **kwargs):
|
||||||
finally:
|
finally:
|
||||||
activate(lang)
|
activate(lang)
|
||||||
return "%s" % url
|
return "%s" % url
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"passing error chain: {e}")
|
||||||
|
|
Loading…
Reference in New Issue