blog-markdown #31
|
@ -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}")
|
||||
|
|
|
@ -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">
|
||||
<h4 class="">{% trans "Featured" %}</h4>
|
||||
<div class="row row-cols-1 row-cols-md-5 my-4">
|
||||
{% for post in featured_posts %}
|
||||
<div class="card col m-2 p-0">
|
||||
<a
|
||||
class="text-reset link-offset-2 link-underline link-underline-opacity-0"
|
||||
href=" {% url 'blog:post' post.category.slug post.slug %}"
|
||||
>
|
||||
<img
|
||||
src="{{ post.thumbnail.url }}"
|
||||
<a class="text-reset link-offset-2 link-underline link-underline-opacity-0"
|
||||
href=" {% url 'blog:post' post.category.slug post.slug %}">
|
||||
<img src="{{ post.thumbnail.url }}"
|
||||
class="card-img-top img-fluid"
|
||||
style="max-height: 150px"
|
||||
alt="thumbnail"
|
||||
/>
|
||||
alt="thumbnail" />
|
||||
<div class="card-body" style="height: 100px">
|
||||
{% if LANGUAGE_CODE == "de" %}
|
||||
<h5 class="card-title">
|
||||
{{ post.title_de }}<small class="text-body-secondary"
|
||||
>{{ post.subtitle }}</small
|
||||
>
|
||||
{{ post.title_de }}<small class="text-body-secondary">{{ post.subtitle }}</small>
|
||||
</h5>
|
||||
<p class="card-text">{{ post.desc_de }}</p>
|
||||
{% elif LANGUAGE_CODE == "en" %}
|
||||
<h5 class="card-title">
|
||||
{{ post.title_en }}<small class="text-body-secondary"
|
||||
>{{ post.subtitle }}</small
|
||||
>
|
||||
{{ post.title_en }}<small class="text-body-secondary">{{ post.subtitle }}</small>
|
||||
</h5>
|
||||
<p class="card-text">{{ post.desc_en }}</p>
|
||||
{% else %}
|
||||
<h5 class="card-title">
|
||||
{{ post.title_en }}<small class="text-body-secondary"
|
||||
>{{ post.subtitle }}</small
|
||||
>
|
||||
{{ post.title_en }}<small class="text-body-secondary">{{ post.subtitle }}</small>
|
||||
</h5>
|
||||
<p class="card-text">{{ post.desc_en }}</p>
|
||||
{% endif %}
|
||||
|
@ -43,14 +34,17 @@
|
|||
<li class="list-group-item">
|
||||
{% translate "category" %}: <b>{{ post.category.name }}</b>
|
||||
</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>
|
||||
{% elif LANGUAGE_CODE == "en" %}
|
||||
<li class="list-group-item">{{ keyword.text_en }}</li>
|
||||
{% else %}
|
||||
<li class="list-group-item">{{ keyword.text_en }}</li>
|
||||
{% endif %} {% endfor %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
</a>
|
||||
|
|
|
@ -23,6 +23,7 @@ def change_lang(context, lang="de", *args, **kwargs):
|
|||
|
||||
logger.debug(f"changing lang from '{lang}'")
|
||||
|
||||
try:
|
||||
path = context['request'].get_raw_uri()
|
||||
url = path
|
||||
try:
|
||||
|
@ -36,3 +37,5 @@ def change_lang(context, lang="de", *args, **kwargs):
|
|||
finally:
|
||||
activate(lang)
|
||||
return "%s" % url
|
||||
except Exception as e:
|
||||
logger.error(f"passing error chain: {e}")
|
||||
|
|
Loading…
Reference in New Issue