{% load static %}
{% load tags %}
{% load cache %}
{% load compress %}

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>SatNOGS Network{% block title %}{% endblock title %}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    {% compress css %}
      <link rel="stylesheet" href="{% static 'lib/bootstrap/dist/css/bootstrap.min.css' %}">
      <link rel="stylesheet" type="text/scss" href="{% static 'css/app.scss' %}">
      {% block css %}
      {% endblock %}
    {% endcompress %}

    <link rel="shortcut icon" href="{% static 'favicon.ico' %}">

  </head>

  <body {% block body-class %}{% endblock %}>
    {{ stage_notice }}
    {% block prenav-content %}{% endblock %}

    <div class="container">
      <nav class="navbar navbar-default navbar-main" role="navigation">
        <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
          <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
              <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="{% if request.user.is_authenticated %}
                                            {% url 'users:view_user' username=request.user.username %}
                                          {% else %}
                                            {% url 'base:home' %}
                                          {% endif %}">
              <img class="navbar-logo" src="{% static 'img/satnogs_net.png' %}" alt="SatNOGS net">
            </a>
          </div>

          <!-- Collect the nav links, forms, and other content for toggling -->
          <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav">
              <li class="{% active request 'base:home' %}"><a href="{% url 'base:home' %}">Home</a></li>
              <li class="{% active request 'base:about' %}"><a href="{% url 'base:about' %}">About</a></li>
              <li class="{% active request 'base:observations_list' %}"><a href="{% url 'base:observations_list' %}">Observations</a></li>
              <li class="{% active request 'base:stations_list' %}"><a href="{% url 'base:stations_list' %}">Ground Stations</a></li>
              <li><a href="https://community.libre.space/" target="_blank" class="hidden-sm">Community</a></li>
              <li><a href="https://wiki.satnogs.org/" target="_blank" class="hidden-sm">Wiki</a></li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
              <li><a href="https://www.timeanddate.com/worldclock" target="_blank" class="hidden-sm"><span id="current_utc">--:-- UTC</span></a></li>
              {% if request.user.is_authenticated %}
                {% with count=owner_unknown_count %}
                  {% if count %}
                    <li data-toggle="tooltip"
                        data-placement="bottom"
                        title="{{ count }} observations needs rating">
                      <a href="{% url 'base:observations_list' %}?observer={{ request.user.id }}&future=0&good=0&bad=0&failed=0&rated=rwu">
                        <span class="glyphicon glyphicon-check" aria-hidden="true"></span>
                        <span class="badge badge-unknown">{{ count }}</span>
                      </a>
                    </li>
                  {% endif %}
                {% endwith %}
              <li class="dropdown">
                <a href="#"
                   class="dropdown-toggle"
                   data-toggle="dropdown">
                  {% cache 3600 nav-avatar request.user.email %}
                    <img src="{{ request.user.email|gravatar_url:35 }}" class="img-avatar"/>
                  {% endcache %}
                  <span class="caret"></span>
                </a>
                <ul class="dropdown-menu" role="menu">
                    <li><a href="{% url 'users:view_user' username=request.user.username %}">Dashboard</a></li>
                    <li role="separator" class="divider"></li>
                    {% if request.user.is_superuser %}
                      <li><a href="{% url 'base:settings_site' %}">Site Settings</a></li>
                    {% endif %}
                    {{ logout_block }}
                </ul>
              </li>
              {% else %}
                {{ auth_block }}
              {% endif %}
            </ul>
          </div><!-- /.navbar-collapse -->
        </div><!-- /.container-fluid -->
      </nav>
    </div>

    <div class="container">

      <div id="alert-messages" class="row messages">
        {% if messages %}
          <div class="col-md-12">
            {% for notification in messages %}
              <div class="alert alert-{{ notification.tags }}" role="alert">
                <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                  <span class="glyphicon glyphicon-remove"></span>
                </button>
                {{ notification.message|safe }}
              </div>
            {% endfor %}
          </div>
        {% endif %}
      </div>

      {% block content %}{% endblock content %}

    </div> <!-- /container -->

    {% block modal %}{% endblock modal %}

    {% block footer %}
      <footer>
        <div class="container">
          <hr>
          <div class="row">
            <div class="col-md-6 footer-options">
              <span class="glyphicon glyphicon-copyright-mark" aria-hidden="true"></span> 2014<span id="copy"></span>
              <a href="https://libre.space/" target="_blank">Libre Space Foundation</a>.<br>
              <span class="glyphicon glyphicon-cloud" aria-hidden="true"></span>
              Observation data are freely distributed under the
              <a href="https://creativecommons.org/licenses/by-sa/4.0/" target="_blank">CC BY-SA</a> license.
            </div>
            <div class="col-md-6 text-right footer-options">
              <a href="https://satnogs.org/" target="_blank">SatNOGS</a> |
              <a href="#top">Back to top</a>
              <p>
                {{ version }}
              </p>
            </div>
          </div>
        </div>
      </footer>
    {% endblock %}

    {% compress js %}
      <script src="{% static 'lib/jquery/dist/jquery.min.js' %}"></script>
      <script src="{% static 'lib/bootstrap/dist/js/bootstrap.min.js' %}"></script>
      <script src="{% static 'js/app.js' %}"></script>
      <script src="{% static 'js/current_utc.js'%}"></script>
      {% block javascript %}
      {% endblock javascript %}
    {% endcompress %}
    {{ analytics_code }}
</body>
</html>
