{% extends "base_bootstrap.html" %}
{% block navbar %}
{% load app_tags %}
<nav class="navbar navbar-expand-xl navbar-dark bg-dark mb-4">
  <div class="container-fluid">
    <a class="navbar-brand" href="/"><img src="/static/logo.png" alt="" width="175" class="d-inline-block align-text-top"></a>
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarCollapse">
      <ul class="navbar-nav mx-auto mb-2 mb-md-0">
        <li class="nav-item">
          <a class="nav-link" href="{% url 'api:api-root' %}">API Root</a>
        </li>
        <li class="nav-item dropdown">
          <a class="nav-link dropdown-toggle" href="#" id="navbarDarkDropdownMenuLink" role="button" data-bs-toggle="dropdown" aria-expanded="false">API List</a>
          <ul class="dropdown-menu dropdown-menu-dark" aria-labelledby="navbarDropdownMenuLink">
            <li><a class="dropdown-item" href="{% url 'api:ad-list' %}">Ads API</a></li>
            <li><hr class="dropdown-divider"></li>
            <li><a class="dropdown-item" href="{% url 'api:snippet-list' %}">Snippet API</a></li>
            <li><hr class="dropdown-divider"></li>
            <li><a class="dropdown-item" href="{% url 'api:user-list' %}">User API</a></li>
          </ul>
        </li>
        <li class="nav-item">
        {% url 'ads:index' as ads %}
          <a {% if ads in request.get_full_path %}class="nav-link active"{% else %}class="nav-link"{% endif %} aria-current="page" href="{% url 'ads:index' %}">Ads</a>
        </li>
        <li class="nav-item">
        {% url 'autos:index' as autos %}
          <a {% if autos in request.get_full_path %}class="nav-link active"{% else %}class="nav-link"{% endif %} aria-current="page" href="{% url 'autos:index' %}">Autos</a>
        </li>
        <li class="nav-item">
        {% url 'cats:index' as cats %}
          <a {% if cats in request.get_full_path %}class="nav-link active"{% else %}class="nav-link"{% endif %} aria-current="page" href="{% url 'cats:index' %}">Cats</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="{% url 'polls:index' %}">Polls</a>
        </li>
      </ul>
      <ul class="navbar-nav ml-auto mb-2 mb-md-0">
        {% if user.is_authenticated %}
        {% if ads in request.get_full_path %}
        <li class="nav-item">
          <a class="nav-link" href="{% url 'ads:ad create' %}">Create Ad</a>
        </li>
        {% endif %}
        <li class="nav-item dropdown">
          <a class="nav-link dropdown-toggle" href="#" id="navbarDarkDropdownMenuLink" role="button" data-bs-toggle="dropdown" aria-expanded="false">
            <img style="width: 28px;" src="{{ user|gravatar:60 }}"/>
          </a>
          <ul class="dropdown-menu dropdown-menu-dark dropdown-menu-end" aria-labelledby="navbarDropdownMenuLink">
            <li><a class="dropdown-item" href="{% url 'admin:index' %}">Admin Panel</a></li>
            <li><hr class="dropdown-divider"></li>
            <li><a class="dropdown-item" href="{% url 'logout' %}?next={% url 'site root' %}">Logout</a></li>
          </ul>
        </li>
        {% else %}
        <li class="nav-item">
          <a class="nav-link" href="{% url 'login' %}?next={% url 'site root' %}">Login</a>
        </li>
        {% endif %}
      </ul>
    </div>
  </div>
</nav>

{% endblock %}