<!DOCTYPE html>

{% load wiki_extras %}

<html lang="en">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width" />
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
    <title>{% block title %}Wiki Home{% endblock %}</title>
    <style>
    /* temp styles which may move somewhere better */
    a { color: blue; }
    a:visited { color: purple }
    a.newpage { color: red }
    span.wikilink:has(> a.newpage):after { content: '+' }

    .navbar a { color: white; }

    div.wiki_content_archive {
        border: 1px dashed #999999;
        background-color: #f0f0f0;
    }
    </style>
</head>

<body>

<!--

Various debugging bits
======================

Space: {{ sess_space_key }}

-->

<nav class="navbar navbar-expand-lg bg-body-tertiary bg-dark" data-bs-theme="dark">
  <div class="container-fluid">
    <a href="{%  url 'djwiki:home' %}" class="navbar-brand">DjWIKI<sup>alpha</sup></a>

    {% block main_nav %}

    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav me-auto mb-2 mb-lg-0">
        <li class="nav-item">
          <a class="nav-link" href="{% url 'djwiki:home' %}">Home</a>
        </li>

        {% if sess_space_key %}
        <!-- li class="nav-item">
            <a class="nav-link" href="{% url 'djwiki:space' sess_space_key %}">{{ sess_space_key|make_title }} </a>
        </li -->
        {% endif %}
        <li class="nav-item dropdown">
          <a class="btn dropdown-toggle btn btn-secondary ms-2" href="#" role="button" data-bs-toggle="dropdown">
            {% if sess_space_key %}
            {{ sess_space_key }}
            {% else %}
            Select Space
            {% endif %}
          </a>
          <ul class="dropdown-menu">
            {% for space in all_spaces %}
            <li><a class="dropdown-item" href="{% url 'djwiki:space' space.name %}">{{ space.name|make_title }} </a></li>
            {% endfor %}
          </ul>
        </li>

        {% if user.is_authenticated %}
        <li class="nav-item dropdown">
          <a class="btn dropdown-toggle btn btn-secondary ms-2" href="#" role="button" data-bs-toggle="dropdown">
            Hi {{ user.first_name }}!
          </a>
          <ul class="dropdown-menu">
            <li><a class="dropdown-item" href="{% url 'djwiki:user' user.username %}" class="navbar-brand">My Profile<!-- sup>alpha</sup --></a></li>
            <li><hr class="dropdown-divider"></li>
            <li>
              <form action="{% url 'logout' %}" method="post">
                {% csrf_token %}
                <button class="dropdown-item btn btn-secondary" type="submit">Log Out</button>
              </form>
            </li>
          </ul>
        </li>
        {% else %}
        <li class="nav-item">
          <a class="btn btn btn-secondary ms-2" href="{% url 'login' %}?next={% url 'djwiki:home' %}">
            Log In
          </a>
        </li>
        {% endif %}

      </ul>

      <!-- Search box -->
      <form class="d-flex" role="search" action="{% url 'djwiki:search' %}" method="get">
        <input class="form-control me-2" type="search" placeholder="Search" name="q">
        <button class="btn btn-secondary" type="submit">Search</button>
      </form>
    </div>

    {% endblock %}

  </div>
</nav>

<div class="container-lg my-5">

    <h1>{% block mainheading %}Override me - #mainheading{% endblock %}</h1>

    {% block feedback %}{% endblock %}

    <div id="content">
        {% block content %}Override me - #content{% endblock %}
        {% block subcontent %}{% endblock %}
    </div>

    <hr>

    <footer>
    {% block footer %}{% endblock %}
    </footer>


</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
</body>
</html>
