{#-
    Define layout of wiki headers and footers: logo, site name, search, user login/logout, page trail...

    The difference between this file and /templates/layout.html is sequence of panels,
    addition of custom_panels from snippets.html, and addition of LI tags containing panel headings.
-#}

{%- extends "base.html" %}

{%- import "snippets.html" as snippets with context %}
{%- import "utils.html" as utils with context %}

{%- block layout -%}

    <div id="moin-main-wrapper">
        {{ snippets.before_header() }}
        <header id="moin-header" lang="{{ theme_supp.user_lang }}" dir="{{ theme_supp.user_dir }}">
            {%- block header %}
                {%- if snippets.logo() %}
                    <div id="moin-logo">
                        <a href="{{ url_for('frontend.show_item', item_name=cfg.root_mapping.get('', cfg.default_root)) }}">{{ snippets.logo() }}</a>
                    </div>
                {%- endif %}
                {%- if cfg.sitename %}
                    <a class="moin-sitename" href="{{ url_for('frontend.show_item', item_name=cfg.default_root) }}">
                        {{ cfg.sitename }}
                    </a>
                {%- endif %}
                {%- if search_form %}
                    {{ header_search(search_form) }}
                {%- endif %}
                {%- if form and form['content_form'] and not form['content_form'].is_draw %}
                    <div class="moin-edit-actions">
                        <button class="moin-button" onclick="document.getElementById('moin-save-text-button').click()">OK</button>
                        <button class="moin-button" onclick="document.getElementById('moin-preview-text-button').click()">Preview</button>
                        <button class="moin-button" onclick="document.getElementById('moin-cancel-text-button').click()">Cancel</button>
                    </div>
                {%- endif %}
                <ul id="moin-username">
                    {{ utils.user_login_logoff() }}
                </ul>
                {%- set navibar_items = theme_supp.navibar(fqname) %}
                {%- if navibar_items %}
                    <ul id="moin-navibar" class="panel">
                        <li class="moin-panel-heading">{{ _('Navigation') }}</li>
                        {% for cls, url, text, title, iconcls in navibar_items %}
                            <li class="{{ cls }}">
                                <a href="{{ url }}" {% if title %}title="{{ title }} : {{ url|safe }}"{% else %}title="{{ url|safe }}"{% endif %}>{{ text }}</a>
                            </li>
                        {%- endfor %}
                    </ul>
                {%- endif %}
                {{ utils.breadcrumbs(theme_supp.path_breadcrumbs, title_name) }}
                {%- block header_itemviews %}{% endblock %}
                {{ snippets.custom_panels() }}
            {%- endblock %}
        </header>
        {{ snippets.after_header() }}

        <div id="moin-page" role="main">
            {% block item -%}
                {# If you want itemviews in your template, extend from show.html, not from here. #}
                <div id="moin-content">
                    <div id="moin-flash">  {# client side javascript may add messages here #}
                        {% for category, msg in get_flashed_messages(with_categories=true) %}
                            <p class="moin-flash moin-flash-{{ category }}">{{ msg }}</p>
                        {% endfor %}
                    </div>
                    {% block content %}
                        {# show.html or other template will provide content #}
                    {% endblock %}
                </div>
            {%- endblock %}
        </div>

        {{ snippets.before_footer() }}
        <footer id="moin-footer">
            {%- block footer %}
                {% block footer_hr %}<hr/>{% endblock %}
                {%- block footer_itemviews %}{% endblock %}
                {%- block footer_meta %}{% endblock %}
                {{- snippets.credits() }}
                {{- snippets.license_info() }}
                {{- snippets.creditlogos() }}
            {%- endblock -%}
        </footer>
        {{- snippets.after_footer() }}
    </div>
{%- endblock %}
