{#
# This file is part of Invenio.
# Copyright (C) 2012, 2013, 2014, 2015 CERN.
#
# Invenio is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# Invenio is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Invenio; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#}

{#
# This file contains header part of main page template.
#
# Usage:
# {% include 'header.html' %}
#}

  <nav class="navbar navbar-inverse navbar-static-top">
    <div class="container">
      <div class="navbar-header">
        <button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".navbar-collapse">
          <span class="sr-only">{{ _('Toggle navigation') }}</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand" href="{{ url_for('collections.index') }}">
          <img src="{{ url_for('static', filename='img/logo_white.svg') }}" alt="{{ config.CFG_SITE_NAME_INTL[g.ln] }}" />
      </a>
      </div>

      <div class="navbar-collapse collapse">
        <ul class="nav navbar-nav">
        {%- for item in current_menu.submenu('main').children if item.visible recursive %}
            {%- if item.children -%}
                <li class="dropdown">.
                  <a href="{{ item.url }}" style="display: inline-block; padding-right: 5px;"> {{ item.text|safe }} </a>
                  <a href="#" class="dropdown-toggle" data-toggle="dropdown" style="display: inline-block; padding-left: 5px;">
                    <b class="caret"></b>
                  </a>
                  <ul class="dropdown-menu pull-right">
                    {{ loop(item.children) }}
                  </ul>
                </li>
            {%- else -%}
            <li{% if item.active %} class="active"{% endif %}><a href="{{ item.url }}">{{ item.text|safe }}</a></li>
            {%- endif -%}
        {%- endfor -%}
        </ul>
        <ul class="nav navbar-nav navbar-right">
        {% if current_user.is_guest %}
          <a class="btn navbar-btn btn-default btn-sm" href="{{url_for('webaccount.login')}}" title="{{ _('Login') }}">
            <i class="fa fa-sign-in"></i> {{ _('Login') }}
          </a>
          {% if config.CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS in [0, 1] %}
            <a class="btn navbar-btn btn-warning btn-sm" href="{{url_for('webaccount.register')}}" title="{{ _('Register') }}">
              <i class="fa fa-edit"></i> {{ _('Register') }}
            </a>
          {% endif %}
        {% else %}
          <li class="dropdown">
            <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                <i class="glyphicon glyphicon-user"></i> {{ current_user.nickname|default(current_user.email) }}
                <b class="caret"></b>
            </a>
            <ul class="dropdown-menu">
              <li>
                <div class="navbar-content">
                  <div class="row">
                    <div class="col-md-3">
                      <i class="fa fa-user fa-3x"></i>
                    </div>
                    <div class="col-md-9">
                      <strong>
                        {{ current_user.nickname|default(current_user.email) }}
                      </strong>
                      <p class="text-muted small"> {{ current_user.email }} </p>
                    </div>
                  </div>
                </div>
              </li>
              {%- for item in current_menu.submenu('settings').children if item.visible %}
              {% if loop.first %}<li class="divider"></li>{% endif -%}
              <li><a href="{{ item.url }}">{{ item.text|safe }}</a></li>
              {%- endfor %}
              <li class="divider"></li>
              <li>
                <a href="{{ url_for('webaccount.logout') }}">
                  <i class="glyphicon glyphicon-log-out"></i> {{ _('Logout') }}
                </a>
              </li>
            </ul>
          </li>
        {% endif %}
      </ul>
    </div>
  </div>
</nav>
