Mercurial > moin-2.0-moinboot
changeset 2134:b1eed94f932d
Factor render_{pagetrail,locationline} into utils.
| author | Andreas Kloeckner <inform@tiker.net> |
|---|---|
| date | Tue, 02 Apr 2013 00:59:48 -0400 |
| parents | 9791423fd4d8 |
| children | 9226fc133d70 ef151b24b567 |
| files | MoinMoin/templates/layout.html MoinMoin/templates/utils.html |
| diffstat | 2 files changed, 63 insertions(+), 46 deletions(-) [+] |
line wrap: on
line diff
--- a/MoinMoin/templates/layout.html Tue Apr 02 00:58:59 2013 -0400 +++ b/MoinMoin/templates/layout.html Tue Apr 02 00:59:48 2013 -0400 @@ -1,6 +1,9 @@ {% extends "base.html" %} {% import "snippets.html" as snippets with context %} +{% from "utils.html" import + render_locationline, render_pagetrail + with context %} {% set logo = snippets.logo() %} {% set before_header = snippets.before_header() %} {% set after_header = snippets.after_header() %} @@ -58,58 +61,14 @@ {%- endif %} </div> - <div id="moin-locationline"> - {% if cfg.show_interwiki -%} - <span id="moin-interwiki"> - <a href="{{ url_for('frontend.show_item', item_name=cfg.item_root) }}" rel="nofollow"> - {% if cfg.interwikiname %}{{ cfg.interwikiname }}{% else %}Self{% endif %} - </a> - <span class="sep">: </span> - </span> - {%- endif %} - <span id="moin-pagelocation"> - <span class="moin-pagepath"> - {% block pagepath %} - {% for segment_name, segment_path, exists in theme_supp.location_breadcrumbs(item_name) -%} - {% if not loop.last -%} - <a href="{{ url_for('frontend.show_item', item_name=segment_path) }}" {% if not exists %}class="moin-nonexistent"{% endif %}> - {{ segment_name|shorten_item_name }} - </a> - <span class="sep">/</span> - {% else %} - {% if title_name %} - {{ title_name }} - {% else %} - <a href="{{ url_for('frontend.show_item', item_name=segment_path) }}" {% if not exists %}class="moin-nonexistent"{% endif %}> - {{ segment_name|shorten_item_name }} - </a> - {%- endif %} - {%- endif %} - {%- endfor %} - {% endblock %} - </span> - </span> + {{ render_locationline() }} </div> {% set trail_items = theme_supp.path_breadcrumbs() %} {% if trail_items %} <div id="moin-pagetrail"> - {% for wiki_name, item_name, item_href, exists, err in trail_items %} - {%- if wiki_name -%} - <a href="{{ item_href }}"{{ " " }} - title="{{ wiki_name }}" - class="{% if err %}moin-badinterwiki{% else %}moin-interwiki{% endif %}"> - {{ item_name|shorten_item_name }} - </a> - {%- else -%} - <a href="{{ url_for('frontend.show_item', item_name=item_name) }}"{{ " " }} - {% if not exists -%}class="moin-nonexistent"{%- endif -%}> - {{ item_name|shorten_item_name }} - </a> - {%- endif %} - {% if not loop.last %}<span class="sep"> » </span>{% endif %} - {% endfor %} + {{ render_pagetrail(trail_items) }} </div> {% endif %}
--- a/MoinMoin/templates/utils.html Tue Apr 02 00:58:59 2013 -0400 +++ b/MoinMoin/templates/utils.html Tue Apr 02 00:59:48 2013 -0400 @@ -102,3 +102,61 @@ {{ forms.render_errors(form) }} {{ gen.form.close() }} {% endmacro %} + +{% macro render_locationline() %} + {% if cfg.show_interwiki -%} + <span id="moin-interwiki"> + <a href="{{ url_for('frontend.show_item', item_name=cfg.item_root) }}" rel="nofollow"> + {% if cfg.interwikiname %}{{ cfg.interwikiname }}{% else %}Self{% endif %} + </a> + <span class="sep">: </span> + </span> + {%- endif %} + <span id="moin-pagelocation"> + <span class="moin-pagepath"> + {% block pagepath %} + {% for segment_name, segment_path, exists in theme_supp.location_breadcrumbs(item_name) -%} + {% if not loop.last -%} + <a href="{{ url_for('frontend.show_item', item_name=segment_path) }}" {% if not exists %}class="moin-nonexistent"{% endif %}> + {{ segment_name|shorten_item_name }} + </a> + <span class="sep">/</span> + {% else %} + {% if title_name %} + {{ title_name }} + {% else %} + <a href="{{ url_for('frontend.show_item', item_name=segment_path) }}" {% if not exists %}class="moin-nonexistent"{% endif %}> + {{ segment_name|shorten_item_name }} + </a> + {%- endif %} + {%- endif %} + {%- endfor %} + {% endblock %} + </span> + </span> +{% endmacro %} + +{% macro render_pagetrail(trail_items, as_list_items=false) %} + {% for wiki_name, item_name, item_href, exists, err in trail_items %} + {%- if as_list_items -%} + <li> + {%- endif -%} + {%- if wiki_name -%} + <a href="{{ item_href }}"{{ " " }} + title="{{ wiki_name }}" + class="{% if err %}moin-badinterwiki{% else %}moin-interwiki{% endif %}"> + {{ item_name|shorten_item_name }} + </a> + {%- else -%} + <a href="{{ url_for('frontend.show_item', item_name=item_name) }}"{{ " " }} + {% if not exists -%}class="moin-nonexistent"{%- endif -%}> + {{ item_name|shorten_item_name }} + </a> + {%- endif %} + {%- if as_list_items -%} + </li> + {%- else -%} + {% if not loop.last %}<span class="sep"> » </span>{% endif %} + {%- endif -%} + {% endfor %} +{% endmacro %}
