diff options
author | vincent <vincent@deuxfleurs.fr> | 2022-09-28 16:42:41 +0200 |
---|---|---|
committer | vincent <vincent@deuxfleurs.fr> | 2022-09-28 16:42:41 +0200 |
commit | d6957256474c990960b8393f1d3b426e12da1a61 (patch) | |
tree | c03946e81c5231f55fd6a2438cb903ac42b5dd7b /templates | |
parent | 4499c6419e1157de9b7bcac7284ea5540d5b48a2 (diff) | |
parent | 125d5031a5d80fb2b1306c7f047bf02f868a737e (diff) | |
download | guide.deuxfleurs.fr-d6957256474c990960b8393f1d3b426e12da1a61.tar.gz guide.deuxfleurs.fr-d6957256474c990960b8393f1d3b426e12da1a61.zip |
Fusiodemande 'Classement entre sections et pages' (#14) depuis classement vers main
Discuté sur: https://git.deuxfleurs.fr/Deuxfleurs/guide.deuxfleurs.fr/pulls/14
Diffstat (limited to 'templates')
-rw-r--r-- | templates/_nav.html | 138 |
1 files changed, 108 insertions, 30 deletions
diff --git a/templates/_nav.html b/templates/_nav.html index e353681..3bfda07 100644 --- a/templates/_nav.html +++ b/templates/_nav.html @@ -3,47 +3,125 @@ {% set sec = get_section(path=sec) %} {% set maxlevel = hierarchy | length %} + + {# Ici on regarde si toutes les sous-sections et pages contenues ont #} + {# une variable weight_custom. Au passage on note ces poids. #} + {% set temoin = true %} + {% set liste = [] %} {% if sec.subsections %} {% for s in sec.subsections %} - {% set p = get_section(path=s) %} - <div class="toc-item"> - {% if p.subsections or p.pages %} - {% if p.path == current.path %} - <a class="subtext" href="{{ p.permalink | safe}}">‣ <b>{{ p.title }}</b></a> - {% elif hierarchy is containing(s) %} - <a class="subtext" href="{{ p.permalink | safe}}">‣ {{ p.title }}</a> - {% else %} - <a class="subtext" href="{{ p.permalink | safe}}">‣ {{ p.title }}</a> + {% set s_temp = get_section(path=s) %} + {% if not s_temp.extra.weight_custom %} + {% set_global temoin = false %} + {% else %} + {% set_global liste = liste | concat(with=s_temp.extra.weight_custom) %} + {% endif %} + {% endfor %} + {% endif %} + {% if sec.pages %} + {% for p in sec.pages %} + {% if not p.extra.weight_custom %} + {% set_global temoin = false %} + {% else %} + {% set_global liste = liste | concat(with=p.extra.weight_custom) %} + {% endif %} + {% endfor %} + {% endif %} + + + {# Si toutes les sous-sections et pages ont une variable weight_custom, #} + {# on classe selon elle. Sinon, on utilise la méthode classique. #} + {% if temoin %} + {% set_global liste = liste | sort %} + {% for x in liste %} + {% if sec.subsections %} + {% for y in sec.subsections %} + {% set p = get_section(path=y) %} + {% if p.extra.weight_custom == x %} + <div class="toc-item"> + {% if p.subsections or p.pages %} + {% if p.path == current.path %} + <a class="subtext" href="{{ p.permalink | safe}}">‣ <b>{{ p.title }}</b></a> + {% elif hierarchy is containing(y) %} + <a class="subtext" href="{{ p.permalink | safe}}">‣ {{ p.title }}</a> + {% else %} + <a class="subtext" href="{{ p.permalink | safe}}">‣ {{ p.title }}</a> + {% endif %} + {% if hierarchy is containing(y) or current.path == p.path %} + {% if level + 1 < maxlevel %} + <div class="nav-subsection"> + {{ nav::navsection(hierarchy=hierarchy,level=level + 1,current=current) }} + </div> + {% endif %} + {% endif %} + {% else %} + {% if p.path == current.path %} + <a class="subtext" href="{{p.permalink | safe}}"><b>{{ p.title }}</b></a> + {% else %} + <a class="subtext" href="{{p.permalink | safe}}">{{ p.title }}</a> + {% endif %} + {% endif %} + </div> + {% endif %} + {% endfor %} + {% endif %} + {% if sec.pages %} + {% for p in sec.pages %} + {% if p.extra.weight_custom == x %} + <div class="toc-item"> + {% if p.path == current.path %} + <a class="subtext" href="{{p.permalink | safe}}"><b>{{ p.title }}</b></a> + {% else %} + <a class="subtext" href="{{p.permalink | safe}}">{{ p.title }}</a> + {% endif %} + </div> {% endif %} - {% if hierarchy is containing(s) or current.path == p.path %} - {% if level + 1 < maxlevel %} - <div class="nav-subsection"> - {{ nav::navsection(hierarchy=hierarchy,level=level + 1,current=current) }} - </div> + {% endfor %} + {% endif %} + {% endfor %} + {% else %} + {% if sec.subsections %} + {% for s in sec.subsections %} + {% set p = get_section(path=s) %} + <div class="toc-item"> + {% if p.subsections or p.pages %} + {% if p.path == current.path %} + <a class="subtext" href="{{ p.permalink | safe}}">‣ <b>{{ p.title }}</b></a> + {% elif hierarchy is containing(s) %} + <a class="subtext" href="{{ p.permalink | safe}}">‣ {{ p.title }}</a> + {% else %} + <a class="subtext" href="{{ p.permalink | safe}}">‣ {{ p.title }}</a> + {% endif %} + {% if hierarchy is containing(s) or current.path == p.path %} + {% if level + 1 < maxlevel %} + <div class="nav-subsection"> + {{ nav::navsection(hierarchy=hierarchy,level=level + 1,current=current) }} + </div> + {% endif %} + {% endif %} + {% else %} + {% if p.path == current.path %} + <a class="subtext" href="{{p.permalink | safe}}"><b>{{ p.title }}</b></a> + {% else %} + <a class="subtext" href="{{p.permalink | safe}}">{{ p.title }}</a> {% endif %} {% endif %} - {% else %} + </div> + {% endfor %} + {% endif %} + + {% if sec.pages %} + {% for p in sec.pages %} + <div class="toc-item"> {% if p.path == current.path %} <a class="subtext" href="{{p.permalink | safe}}"><b>{{ p.title }}</b></a> {% else %} <a class="subtext" href="{{p.permalink | safe}}">{{ p.title }}</a> {% endif %} - {% endif %} - </div> + </div> {% endfor %} - {% endif %} - - {% if sec.pages %} - {% for p in sec.pages %} - <div class="toc-item"> - {% if p.path == current.path %} - <a class="subtext" href="{{p.permalink | safe}}"><b>{{ p.title }}</b></a> - {% else %} - <a class="subtext" href="{{p.permalink | safe}}">{{ p.title }}</a> - {% endif %} - </div> - {% endfor %} - {% endif %} + {% endif %} + {% endif %} {% endmacro navsection %} {% macro navmenu(current) %} |