Skip to content
Snippets Groups Projects
Verified Commit 081d1ecb authored by Jake's avatar Jake
Browse files

use macros dir

parent dd56e0fb
No related branches found
No related tags found
No related merge requests found
...@@ -7,54 +7,9 @@ Hurra!!! lang ist definiert als {{ lang }}. ...@@ -7,54 +7,9 @@ Hurra!!! lang ist definiert als {{ lang }}.
{{ diese_variable_existiert_nicht_werfe_fehler }} {{ diese_variable_existiert_nicht_werfe_fehler }}
{%- endif -%} {%- endif -%}
{%- macro category_by_name(catname, ignore_native = False) -%} {%- import 'macros/getters.html' as get with context -%}
{%- if ignore_native -%} {%- import 'macros/cards.html' as cards with context -%}
{{- caller(null, sc.categories[catname], null) -}} {%- import 'macros/renderers.html' as render with context -%}
{%- else -%}
{%- for nativecat, catarticles in categories -%}
{%- if nativecat.name == catname -%}
{{- caller(nativecat, sc.categories[catname], catarticles) -}}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{%- endmacro -%}
{%- macro tag_by_name(tagname) -%}
{%- for nativetag, tagarticles in tags -%}
{%- if nativetag.name == tagname -%}
{{- caller(nativetag, tagarticles) -}}
{%- endif -%}
{%- endfor -%}
{%- endmacro -%}
{%- macro article_by_slug(slug, lang) -%}
{%- for a in all_articles -%}
{%- if a.slug == slug and a.lang == lang -%}
{{- caller(a) -}}
{%- endif -%}
{%- endfor -%}
{%- endmacro -%}
{%- macro page_by_slug(slug, lang) -%}
{%- for p in pages -%}
{%- if p.slug == slug and p.lang == lang -%}
{{- caller(p) -}}
{%- endif -%}
{%- endfor -%}
{%- endmacro -%}
{%- macro article_or_page_by_slug(slug, lang) -%}
{%- for a in all_articles -%}
{%- if a.slug == slug and a.lang == lang -%}
{{- caller(a) -}}
{%- endif -%}
{%- endfor -%}
{%- for p in pages -%}
{%- if p.slug == slug and p.lang == lang -%}
{{- caller(p) -}}
{%- endif -%}
{%- endfor -%}
{%- endmacro -%}
<html lang="{%- block html_lang -%}{{ DEFAULT_LANG }}{%- endblock html_lang -%}"> <html lang="{%- block html_lang -%}{{ DEFAULT_LANG }}{%- endblock html_lang -%}">
<head> <head>
...@@ -93,12 +48,12 @@ Hurra!!! lang ist definiert als {{ lang }}. ...@@ -93,12 +48,12 @@ Hurra!!! lang ist definiert als {{ lang }}.
<ul> <ul>
{% for item in sc.menuitems -%} {% for item in sc.menuitems -%}
{%- if item.category is defined -%} {%- if item.category is defined -%}
{%- call(nativecat, sccat, _) category_by_name(item.category) -%} {%- call(nativecat, sccat, _) get.category_by_name(item.category) -%}
<li style="--category-color: {{ sccat.color }}"><a href="{{ SITEURL }}/{{ nativecat.url }}">{{ sccat[lang]|e }}</a></li> <li style="--category-color: {{ sccat.color }}"><a href="{{ SITEURL }}/{{ nativecat.url }}">{{ sccat[lang]|e }}</a></li>
{%- endcall -%} {%- endcall -%}
{%- elif item.slug is defined -%} {%- elif item.slug is defined -%}
{%- call(aop) article_or_page_by_slug(item.slug, lang) -%} {%- call(aop, _) get.article_or_page_by_slug(item.slug, lang) -%}
{%- call(_, sccat, __) category_by_name(aop.category.name, True) -%} {%- call(__, sccat, ___) get.category_by_name(aop.category.name, True) -%}
<li style="--category-color: {{ sccat.color }}"><a href="{{ SITEURL }}/{{ aop.url }}">{{ aop.title }}</a></li> <li style="--category-color: {{ sccat.color }}"><a href="{{ SITEURL }}/{{ aop.url }}">{{ aop.title }}</a></li>
{%- endcall -%} {%- endcall -%}
{%- endcall -%} {%- endcall -%}
...@@ -113,8 +68,8 @@ Hurra!!! lang ist definiert als {{ lang }}. ...@@ -113,8 +68,8 @@ Hurra!!! lang ist definiert als {{ lang }}.
</nav> </nav>
</div> </div>
<main> <main>
{% block content %} {% block content %}
{% endblock content %} {% endblock content %}
</main> </main>
<footer> <footer>
{% block footer %} {% block footer %}
......
{% extends "index.html" %} {% extends "base.html" %}
{% block title %}{{ l[lang].title_prefix }}{{ l[lang].sitename }}{{ l[lang].title_suffix }} - {{ category }}{%endblock%} {% block title %}{{ l[lang].title_prefix }}{{ l[lang].sitename }}{{ l[lang].title_suffix }} - {{ category }}{%endblock%}
{% block content %} {% block content %}
<section> <section>
{{ render_section({"type": "category", "category": category.slug, "num": 5000 }) }} {{ render.section({"type": "category", "category": category.slug, "num": 5000 }) }}
</section> </section>
{% endblock content %} {% endblock content %}
{% extends "base.html" %} {% extends "base.html" %}
{% block content_title %}{% endblock %} {% block content_title %}{% endblock %}
{%- macro render_section_news(s) -%}
<ul class="catcards">
{%- for article in all_articles -%}
{%- if loop.index < s.num -%}
{%- call(nativecat, sccat, _) category_by_name(article.category.name) -%}
<li style="--category-color: {{ sccat.color }}"><a href="{{ SITEURL }}/{{ article.url }}">{{ article.title }}</a></li>
{%- endcall -%}
{%- endif -%}
{%- endfor -%}
</ul>
{%- endmacro -%}
{%- macro render_section_custom(s) -%}
<ul class="catcards">
{%- for c in s.content -%}
<li style="--category-color: {{ c.color }}"><a href="{{ c.url }}">{{ c[lang]|e }}</a></li>
{%- endfor -%}
</ul>
{%- endmacro -%}
{%- macro render_section_iframe(s) -%}
<iframe src="{{ s.url }}"></iframe>
{%- endmacro -%}
{%- macro render_section_category(s) -%}
{%- call(nativecat, sccat, catarticles) category_by_name(s.category) -%}
{%- if s.title is not defined -%}
<header>
<h2 {% if s.id is defined -%}id="{{ s.id }}"{%- endif %}>{{ sccat[lang]|e }}</h2>
</header>
{%- endif -%}
<ul class="catcards">
{%- for article in catarticles -%}
{%- if loop.index < s.num -%}
<li style="--category-color: {{ sccat.color }}"><a href="{{ SITEURL }}/{{ article.url }}">{{ article.title }}</a></li>
{%- endif -%}
{%- endfor -%}
</ul>
{%- endcall -%}
{%- endmacro -%}
{%- macro render_section_tag(s) -%}
{%- call(nativetag, tagarticles) tag_by_name(s.tag) -%}
{%- if s.title is not defined -%}
<header>
<h2 {% if s.id is defined -%}id="{{ s.id }}"{%- endif %}>{{ s.tag|e }}</h2>
</header>
{%- endif -%}
<ul class="catcards">
{%- for article in tagarticles -%}
{%- if loop.index < s.num -%}
{%- call(nativecat, sccat, _) category_by_name(article.category.name) -%}
<li style="--category-color: {{ sccat.color }}"><a href="{{ SITEURL }}/{{ article.url }}">{{ article.title }}</a></li>
{%- endcall -%}
{%- endif -%}
{%- endfor -%}
</ul>
{%- endcall -%}
{%- endmacro -%}
{%- macro render_section(s) -%}
{%- if s.title is defined -%}
<header>
<h2 {% if s.id is defined -%}id="{{ s.id }}"{%- endif %}>{{ s.title[lang]|e }}</h2>
</header>
{%- endif -%}
{%- if s.type == "news" -%}
{{ render_section_news(s) }}
{%- elif s.type == "iframe" -%}
{{ render_section_iframe(s) }}
{%- elif s.type == "custom" -%}
{{ render_section_custom(s) }}
{%- elif s.type == "category" -%}
{{ render_section_category(s) }}
{%- elif s.type == "tag" -%}
{{ render_section_tag(s) }}
{%- else -%}
<br />
<strong>ERROR: render_section: Unknown section type: {{ s.type|e }}</strong><br />
<br />
{%- endif -%}
{%- endmacro -%}
{% block content %} {% block content %}
{%- for s in sc.startpage -%} {%- for s in sc.startpage -%}
<section> <section>
{{ render_section(s) }} {{ render.section(s) }}
</section> </section>
{%- endfor -%} {%- endfor -%}
{% endblock content %} {% endblock content %}
{% extends "index.html" %} {% extends "base.html" %}
{% block title %}{{ l[lang].title_prefix }}{{ l[lang].sitename }}{{ l[lang].title_suffix }} - {{ tag }}{%endblock%} {% block title %}{{ l[lang].title_prefix }}{{ l[lang].sitename }}{{ l[lang].title_suffix }} - {{ tag }}{%endblock%}
{% block content %} {% block content %}
<section> <section>
{{ render_section({"type": "tag", "tag": tag.slug, "num": 5000 }) }} {{ render.section({"type": "tag", "tag": tag.slug, "num": 5000 }) }}
</section> </section>
{% endblock content %} {% endblock content %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment