make navbar template more readable

This commit is contained in:
maxbachmann 2019-05-05 23:04:39 +02:00 committed by L3D
parent a783fde208
commit e3196c7ad5
3 changed files with 59 additions and 65 deletions

24
databags/nav-bar.ini Normal file
View file

@ -0,0 +1,24 @@
[NavBar]
Blog = '/blog'
Rezept = '/rezept'
mitglied = '/mitmachen'
Kontakt = '/kontakt'
[Rezept]
show_projekt = '/rezept/'
xml = '/feed_projekte.xml'
[Kontakt]
Kontakt = '/kontakt'
Impressum = '/impressum'
Datenschutz = '/datenschutz'
[Blog]
Alle-Beitraege = '/blog/'
RSS-Feed = '/feed_blog.xml'
[list]
Rezept = '/rezept/'
Blog = '/blog/'

View file

@ -7,7 +7,7 @@ Rezept = Rezepte
Kontakt = Kontakt Kontakt = Kontakt
Impressum = Impressum Impressum = Impressum
Datenschutz = Datenschutz Datenschutz = Datenschutz
xml = als XML-Feed xml = Rezepte als XML-Feed
mitglied = Werde Teil der Waffel Crew mitglied = Werde Teil der Waffel Crew
Anfahrt = Anfahrt Anfahrt = Anfahrt
fragen = Häufige Fragen fragen = Häufige Fragen
@ -18,6 +18,8 @@ Englisch = English
falls = if available falls = if available
show_projekt = Alle Rezepte show_projekt = Alle Rezepte
default_path = 'en' default_path = 'en'
RSS-Feed = RSS Feed
Alle-Beitraege = Alle Beiträge
[en] [en]
home = Start home = Start
@ -26,7 +28,7 @@ Rezept = Recipes
Kontakt = Contact Kontakt = Contact
Impressum = Imprint Impressum = Imprint
Datenschutz = Data protection Datenschutz = Data protection
xml = as XML feed xml = Recipes as XML feed
mitglied = become part of our waffle crew mitglied = become part of our waffle crew
Anfahrt = Approach Anfahrt = Approach
fragen = Frequently Asked Questions fragen = Frequently Asked Questions
@ -37,4 +39,5 @@ English = English
falls = if available falls = if available
show_projekt = All recipes show_projekt = All recipes
default_path = '' default_path = ''
RSS-Feed = RSS Feed
Alle-Beitraege = all news

View file

@ -107,69 +107,36 @@
<ul> <ul>
<li{% if this._path == '/' %} class="active"{% endif <li{% if this._path == '/' %} class="active"{% endif
%}><a href="{{ '/'|url }}">{% %}><a href="{{ '/'|url }}">{%
if bag('navigation', this.alt, 'home') %}{{ bag('navigation', this.alt, 'home') }}{% if bag('navigation', this.alt, 'home') %}{{ bag('navigation', this.alt, 'home') }}{%
else %}{{ bag('navigation', 'de', 'home') }}{% endif %}</a></li>{% else %}{{ bag('navigation', 'de', 'home') }}{% endif %}</a></li>{%
for href, title, print in [ for title, href in bag('nav-bar', "NavBar").items() %}
['/blog', 'Blog', 1], <li{% if this.is_child_of(href) %} class="active"{% endif
['/rezept', 'Rezept', 1], %}><a href="{{ href|url }}">{% if bag('navigation', this.alt, title) %}{{ bag('navigation', this.alt, title) }}{% else %}{{ title }}{% endif %}</a>
['/mitmachen', 'mitglied', 1], <ul>
['/hunger', 'Wo gibt es Waffeln?', 0], {% if bag('nav-bar', 'list', title) %}
['/kontakt', 'Kontakt', 1] {% set root = site.get( bag('nav-bar', 'list', title), alt=this.alt) %}{%
] %}{% if print %} for child in root.children recursive %}{% if loop.index <= 7 %}
<li{% if this.is_child_of(href) %} class="active"{% endif <li{% if this._path == child._path %} class="active"{% endif %}>
%}><a href="{{ href|url }}">{% <a href="{{ child|url }}">
if bag('navigation', this.alt, title) {{ child.shorttitle if child.shorttitle else child.title }}
%}{{ bag('navigation', this.alt, title) }}{% </a></li>
else %}{{ title }}{% {% endif %}{% endfor %}
endif %}</a>{# {% endif %}
{% if bag('nav-bar', title) %}
Hier beginnt die vorhin erwähnt if-schleife, {% for nav_title, nav_url in bag('nav-bar', title).items() %}
in der die Untermenüs definiert werden. <li><a href={{ nav_url if 'http' in nav_url else nav_url|url }}
{% if bag('nav-bar', 'button', nav_title) %}
PLZ Fix me!!! class="button special"
{% endif %}>
-> Eine Idee zum Fix wäre, die obige Tabelle ausweiten... {{ bag('navigation', this.alt, nav_title)
if bag('navigation', this.alt, nav_title)
#}{% else bag('navigation', 'de', nav_title) }}
if title == 'Rezept' %} </a></li>
<ul>{% set root = site.get('/rezept/', alt=this.alt) %}{% {% endfor %}
for child in root.children recursive %}{% if loop.index <= 8 %} {% endif %}
<li{% </ul>
if this._path == child._path %} class="active"{% endif </li>
%}><a href="{% if this.alt == 'de' %}{% else %}/{{ this.alt }}/{% endif %}{{ child|url }}">{{ child.title }}</a></li>{% {% endfor %}
endif %}{% endfor %}
<li><a href="{{ '/rezept/'|url }}">{%
if bag('navigation', this.alt, 'show_projekt') %}{{ bag('navigation', this.alt, 'show_projekt') }}{%
else %}{{ bag('navigation', 'de', 'show_projekt') }}{% endif %}</a></li>
<li><a href="{{ '/feed_projekte.xml'|url }}">{%
if bag('navigation', this.alt, title) %}{{ bag('navigation', this.alt, title) }}{%
else %}{{ title }}{% endif %} {%
if bag('navigation', this.alt, 'xml') %}{{ bag('navigation', this.alt, 'xml') }}{%
else %}{{ bag('navigation', 'de', 'xml') }}{% endif %}</a></li>
</ul>{%
elif title == 'Kontakt' %}
<ul><li><a href="{{ '/kontakt'|url }}">{%
if bag('navigation', this.alt, 'Kontakt') %}{{ bag('navigation', this.alt, 'Kontakt') }}{%
else %}{{ bag('navigation', 'de', 'Kontakt') }}{% endif %}</a></li>
<li><a href="{{ '/impressum'|url }}">{%
if bag('navigation', this.alt, 'Impressum') %}{{ bag('navigation', this.alt, 'Impressum') }}{%
else %}Impressum{% endif %}</a></li>
<li><a href="{{ '/datenschutz/'|url }}">{%
if bag('navigation', this.alt, 'Datenschutz') %}{{ bag('navigation', this.alt, 'Datenschutz') }}{%
else %}Datenschutz{% endif %}</a></li>
</ul>{%
elif title == 'Blog' %}
<ul>{% set root = site.get('/blog/', alt=this.alt) %}{%
for child in root.children recursive %}{% if loop.index <= 8 %}
<li{%
if this._path == child._path %} class="active"{% endif
%}><a href="{{ child|url }}">{{ child.shorttitle }}</a></li>{%
endif %}{% endfor %}
<li><a href="{{ '/blog/'|url }}">Alle Beiträge</a></li>
<li><a href="{{ '/feed_blog.xml'|url }}">RSS Feed</a></li></ul>{%
endif %}</li>{%
endif %}{%
endfor %}
<li class="last"><a href="/{% if bag('navigation', this.alt, 'default_path') %}{{ bag('navigation', this.alt, 'default_path') }}{% else %}..{% endif %}{{ this._path }}">{% if bag('navigation', this.alt, 'sprache') %}{{ bag('navigation', this.alt, 'sprache') }}{% else %}Sprache{% endif %}</a> <li class="last"><a href="/{% if bag('navigation', this.alt, 'default_path') %}{{ bag('navigation', this.alt, 'default_path') }}{% else %}..{% endif %}{{ this._path }}">{% if bag('navigation', this.alt, 'sprache') %}{{ bag('navigation', this.alt, 'sprache') }}{% else %}Sprache{% endif %}</a>
<ul class="last"> <ul class="last">
<li><a href="{{ this._path }}">{% <li><a href="{{ this._path }}">{%