{% extends "base_bootstrap.html" %}
{% block navbar %}
{% load app_tags %}
<nav class="navbar navbar-default navbar-inverse">
  <div class="container-fluid">
    <div class="navbar-header">
        <a class="navbar-brand" href="/">{{ settings.APP_NAME }}</a>
    </div>
    <!-- https://stackoverflow.com/questions/22047251/django-dynamically-get-view-url-and-check-if-its-the-current-page -->
    <ul class="nav navbar-nav">
      {% url 'ads:index' as ads %}
      <li {% if ads in request.get_full_path %}class="active"{% endif %}>
          <a href="{% url 'ads:index' %}">Ads</a></li>
    </ul>
    <ul class="nav navbar-nav">
      <li><a href="{% url 'snippets:api-root' %}">Snippet-API</a></li>
    </ul>
    <ul class="nav navbar-nav">
      {% url 'autos:index' as autos %}
      <li {% if autos in request.get_full_path %}class="active"{% endif %}>
          <a href="{% url 'autos:index' %}">Autos</a></li>
    </ul>
    <ul class="nav navbar-nav">
      {% url 'cats:index' as cats %}
      <li {% if cats in request.get_full_path %}class="active"{% endif %}>
          <a href="{% url 'cats:index' %}">Cats</a></li>
    </ul>
    <ul class="nav navbar-nav">
      <li><a href="{% url 'polls:index' %}">Polls</a></li>
    </ul>
    <ul class="nav navbar-nav navbar-right">
        {% if user.is_authenticated %}
        {% if ads in request.get_full_path %}
        <li>
        <a href="{% url 'ads:ad create' %}">Create Ad</a>
        </li>
        {% endif %}
        <li class="dropdown">
            <a href="#" data-toggle="dropdown" class="dropdown-toggle">
                <img style="width: 25px;" src="{{ user|gravatar:60 }}"/><b class="caret"></b>
            </a>
            <ul class="dropdown-menu">
                <li><a href="{% url 'admin:index' %}">Admin Panel</a></li>
                <li><a href="{% url 'logout' %}?next={% url 'ads:index' %}">Logout</a></li>
            </ul>
        </li>
        {% else %}
        <li>
        <a href="{% url 'login' %}?next={% url 'ads:index' %}">Login</a>
        </li>
        {% endif %}
    </ul>
  </div>
</nav>
{% endblock %}