<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Wiki</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.0/font/bootstrap-icons.css">
    <style type="text/css">
        body {
          padding-top: 4.5rem;
        }
    </style>
  </head>
  <body>
    <nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
      <div class="container">
        <a class="navbar-brand d-flex" href="/">Wiki</a>
        <form class="d-flex">
          <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
          <button class="btn btn-outline-light" type="submit">Search</button>
        </form>
        <ul class="navbar-nav">
        {% if current_user.is_authenticated %}
          <li class="nav-item dropdown">
            <a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button" data-bs-toggle="dropdown" aria-expanded="false">
              <i class="bi-person-fill"></i>
              {% if current_user.name -%}
              {{ current_user.name }}
              {% else -%}
              {{ current_user.email }}
              {%- endif %}
            </a>
            <ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
              {% if current_user.has_role('admin') %}
              <li><a class="dropdown-item" href="{{ url_for('admin.index') }}">Admin</a></li>
              {% endif %}
              <li><a class="dropdown-item" href="{{ url_for('security.logout') }}">Logout</a></li>
            </ul>
          </li>
        {% else %}
          <li class="nav-item">
            <a class="nav-link" aria-current="page" href="{{ url_for('security.login') }}">Log in</a>
          </li>
        {% endif %}
        </ul>
      </div>
    </nav>

    <main class="container">
{% block content %}{% endblock %}
    </main>
    <!-- JavaScript Bundle with Popper -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
  </body>
</html>
