<!DOCTYPE html>
<html lang="{{ lang[0:2] }}">
  <head>
    {% block head %}
      <title>
        {% block title %}
          {% if title %}{{ title }}{% endif %}
        {% endblock title %}
        - {{ header_name }}
      </title>
      <meta charset="utf-8" />
      <meta content="noindex" name="robots" />
      <meta content="IE=edge" http-equiv="X-UA-Compatible" />
      <meta content="width=device-width, initial-scale=1" name="viewport" />
      <link href="{{ url_for('favicon.ico', v=cache_invalid) }}"
            rel="shortcut icon"/>
      <!-- Jquery -->
      <script src="{{ url_for('/static/js/jquery.min.js') }}"></script>
      <!-- Bootstrap v4 -->
      <script src="{{ url_for('/static/js/bootstrap.bundle.min.js') }}"></script>
      <link href="{{ url_for('/static/css/bootstrap.min.css') }}"
            rel="stylesheet"
            type="text/css"/>
      <!-- Fontawesome -->
      <link href="{{ url_for('/static/css/font-awesome.min.css') }}"
            rel="stylesheet"
            type="text/css"/>
      <!-- JQuery Datatables -->
      <script src="{{ url_for('/static/js/jquery.dataTables.min.js') }}"></script>
      <script src="{{ url_for('/static/js/dataTables.buttons.min.js') }}"></script>
      <script src="{{ url_for('/static/js/dataTables.responsive.min.js') }}"></script>
      <link href="{{ url_for('/static/css/jquery.dataTables.min.css') }}"
            rel="stylesheet"
            type="text/css"/>
      <link href="{{ url_for('/static/css/responsive.dataTables.min.css') }}"
            rel="stylesheet"
            type="text/css"/>
      <!-- Custom -->
      <script src="{{ url_for('/static/js/main.js', v=cache_invalid) }}"></script>
      <link href="{{ url_for('/main.css', v=cache_invalid) }}"
            rel="stylesheet"
            type="text/css"/>
    {% endblock head %}
    {% block script %}
    {% endblock script %}
  </head>
  <body class="d-flex flex-column">
    <!-- .navbar -->
    {% if username %}
      <nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
        <div class="container-fluid">
          <a class="navbar-brand" href="{{ url_for('/') }}">
            <img alt="{{ header_name }}"
                 class="mr-1"
                 height="36"
                 src="{{ url_for('/header_logo',v=cache_invalid) }}"/>
          </a>
          <button aria-controls="navbarSupportedContent"
                  aria-expanded="false"
                  aria-label="{% trans %}Toggle navigation{% endtrans %}"
                  class="navbar-toggler"
                  data-target="#navbarSupportedContent"
                  data-toggle="collapse"
                  type="button">
            <span class="navbar-toggler-icon"></span>
          </button>
          <div class="collapse navbar-collapse" id="navbarSupportedContent">
            <ul class="navbar-nav mr-auto">
              <li class="nav-item{% if active_page=='repo' %} active{% endif %}">
                <a class="nav-link" href="{{ url_for('/') }}">{% trans %}Repositories{% endtrans %}</a>
              </li>
              <li class="nav-item{% if active_page=='status' %} active{% endif %}">
                <a class="nav-link" href="{{ url_for('status', username, '/') }}">{% trans %}Dashboard{% endtrans %}</a>
              </li>
              {% if is_admin %}
                <li class="nav-item{% if active_page=='admin' %} active{% endif %}">
                  <a class="nav-link" href="{{ url_for('admin','') }}">{% trans %}Admin area{% endtrans %}</a>
                </li>
              {% endif %}
            </ul>
            <ul class="navbar-nav">
              <li class="nav-item dropdown">
                <a aria-expanded="false"
                   class="nav-link dropdown-toggle"
                   data-toggle="dropdown"
                   href="#"
                   id="navbarDropdown"
                   role="button">
                  <i aria-hidden="true" class="fa fa-user"></i>
                  {{ username }}
                </a>
                <form action="{{ url_for('logout') }}" method="post">
                  <div aria-labelledby="navbarDropdown"
                       class="dropdown-menu dropdown-menu-right">
                    <h6 class="dropdown-header">{% trans %}Signed in as{% endtrans %} {{ username }}</h6>
                    <a class="dropdown-item" href="{{ url_for('prefs', 'general') }}">{% trans %}Edit profile{% endtrans %}</a>
                    <a class="dropdown-item" href="{{ url_for('prefs', 'notification') }}">{% trans %}Notifications{% endtrans %}</a>
                    <div class="dropdown-divider"></div>
                    {# Logout button #}
                    <button type="submit" class="dropdown-item">{% trans %}Logout{% endtrans %}</button>
                  </div>
                </form>
              </li>
            </ul>
          </div>
        </div>
      </nav>
    {% endif %}
    {% block body %}
    {% endblock body %}
    <footer class="small text-center mt-auto">
      {% trans %}Powered by{% endtrans %} <a href="{{ footerurl }}">{{ footername }}</a>
    </footer>
  </body>
</html>
