{% block doc -%}
<!doctype html>
<html lang="de"{% block html_attribs %}{% endblock html_attribs %}>
  {%- block html %}
  <head>
    {%- block head %}
    <title>{%- block title -%}{{ title|default('eventcally') }}{% endblock title %}</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    {% if canonical_url %}
    <link rel="canonical" href="{{ canonical_url }}" />
    {% endif %}
    {%- block metas %}
      <meta property="og:type" content="website">
      <meta property="og:title" content="{{ self.title() }}">

      {% if canonical_url %}
        <meta property="og:url" content="{{ canonical_url }}" />
      {% endif %}

      {% if meta %}
        <meta name="description" content="{{ meta['description'] }}">
        <meta property="og:description" content="{{ meta['description'] }}">

        <meta name="twitter:title" content="{{ self.title() }}">
        {% if 'image' in meta %}
          <meta property="og:image" content="{{ meta['image'] }}">
          <meta name="twitter:image" content="{{ meta['image'] }}">
          <meta name="twitter:card" content="summary_large_image">
        {% else %}
          <meta name="twitter:card" content="summary">
        {% endif %}

      {% else %}
        <meta name="description" content="Mit der offenen Veranstaltungsdatenbank Events einfach bekannt machen!">
        <meta property="og:description" content="Mit der offenen Veranstaltungsdatenbank Events einfach bekannt machen!">
      {% endif %}
    {%- endblock metas %}

    <link rel="apple-touch-icon" sizes="180x180" href="{{ url_for('static', filename='apple-touch-icon.png')}}">
    <link rel="icon" type="image/png" sizes="32x32" href="{{ url_for('static', filename='favicon-32x32.png')}}">
    <link rel="icon" type="image/png" sizes="16x16" href="{{ url_for('static', filename='apple-touch-icon.png')}}">
    <link rel="manifest" href="{{ url_for('static', filename='site.webmanifest')}}">

    <link rel="stylesheet" href="{{ url_for('static', filename='ext/bootstrap.4.4.1.min.css')}}">
    <link rel="stylesheet" href="{{ url_for('static', filename='ext/font-awesome.5.13.1/css/all.min.css')}}">
    <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='site.css')}}" />

    {%- block styles %}
    {%- endblock styles %}

    <script src="{{ url_for('static', filename='ext/jquery-1.12.4.min.js')}}"></script>
    <script src="{{ url_for('static', filename='ext/moment.2.24.0.with-locales.min.js')}}"></script>

    {% block header_before_site_js %}
    {%- endblock -%}
    <script src="{{ url_for('static', filename='site.js')}}"></script>

    <script>
      function render_event_status_pill(event) {
        if (event.eventStatus != null) {
            if (event.eventStatus == "EventCancelled") {
                return '<span class="badge badge-pill badge-warning">{{ _('EventStatus.cancelled') }}</span>';
            }
            if (event.eventStatus == "EventMovedOnline") {
                return '<span class="badge badge-pill badge-warning">{{ _('EventStatus.movedOnline') }}</span>';
            }
            if (event.eventStatus == "EventPostponed") {
                return '<span class="badge badge-pill badge-warning">{{ _('EventStatus.postponed') }}</span>';
            }
            if (event.eventStatus == "EventRescheduled") {
                return '<span class="badge badge-pill badge-warning">{{ _('EventStatus.rescheduled') }}</span>';
            }
        }

        if (event.status != null) {
            if (event.status == "cancelled") {
                return '<span class="badge badge-pill badge-warning">{{ _('EventStatus.cancelled') }}</span>';
            }
            if (event.status == "movedOnline") {
                return '<span class="badge badge-pill badge-warning">{{ _('EventStatus.movedOnline') }}</span>';
            }
            if (event.eventStatus == "postponed") {
                return '<span class="badge badge-pill badge-warning">{{ _('EventStatus.postponed') }}</span>';
            }
            if (event.eventStatus == "rescheduled") {
                return '<span class="badge badge-pill badge-warning">{{ _('EventStatus.rescheduled') }}</span>';
            }
        }

        return '';
    }

    function render_attendance_mode_pill(event) {
        if (event.attendance_mode != null) {
            if (event.attendance_mode == "online") {
                return '<span class="badge badge-pill badge-info">{{ _('EventAttendanceMode.online') }}</span>';
            }
            if (event.attendance_mode == "mixed") {
                return '<span class="badge badge-pill badge-info">{{ _('EventAttendanceMode.mixed') }}</span>';
            }
        }

        return '';
    }

    function render_booked_up_pill(event) {
      if (event.booked_up) {
        return '<span class="badge badge-pill badge-warning">{{ _('Booked up') }}</span>';
      }

      return '';
    }

    function render_event_warning_pills(event) {
      return render_event_status_pill(event) + ' ' + render_booked_up_pill(event) + ' ' + render_attendance_mode_pill(event);
    }

    </script>

    {% if structured_data %}
    <script type="application/ld+json">
      {{ structured_data | safe }}
    </script>
    {% endif %}

    {% if structured_datas %}
      {% for structured_data in structured_datas %}
      <script type="application/ld+json">
        {{ structured_data | safe }}
      </script>
      {% endfor %}
    {% endif %}

    {% block header %}
    {% endblock %}
    {%- endblock head %}
  </head>
  <body{% block body_attribs %}{% endblock body_attribs %}>
    {% block body -%}
      {% block navbar %}
      <nav class="navbar navbar-expand-md navbar-dark bg-dark">
          <a class="navbar-brand" href="{{ url_for('home') }}">
            <img src="{{ url_for('static', filename='calendar_icon_90.png')}}" width="30" height="30" class="d-inline-block align-top rounded" alt="Logo">
          </a>
          <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
              <span class="navbar-toggler-icon"></span>
          </button>
          <div class="collapse navbar-collapse" id="navbarNavAltMarkup">
              <div class="navbar-nav mr-auto">
                <a class="nav-item nav-link" href="{{ url_for('event_dates') }}">{{ _('Events') }}</a>
                <a class="nav-item nav-link" href="{{ url_for('organizations') }}">{{ _('Organizations') }}</a>
                <a class="nav-item nav-link" href="{{ url_for('planing') }}">{{ _('Planing') }}</a>
              </div>
              <div class="navbar-nav navbar-right">
                {% if config["DOCS_URL"] %}
                  <a class="nav-item nav-link" href="{{ config["DOCS_URL"] }}" target="_blank" rel="noopener noreferrer">{{ _('Docs') }}</a>
                {% endif %}
                {% if current_user.is_authenticated %}
                  <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" id="navbarUserDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                      {{ current_user.email }}
                    </a>
                    <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarUserDropdown">
                      <a class="dropdown-item" href="{{ url_for('manage_admin_units') }}">{{ _('Organizations') }}</a>
                      <a class="dropdown-item" href="{{ url_for('profile') }}">{{ _('Profile') }}</a>
                      <a class="dropdown-item" href="{{ url_for('user_favorite_events') }}">{{ _('Favorite events') }}</a>

                      {% if current_user.has_role('admin') %}
                      <a class="dropdown-item" href="{{ url_for('admin') }}">{{ _('Admin') }}</a>
                      {% endif %}

                      <div class="dropdown-divider"></div>
                      <a class="dropdown-item" href="{{ url_for('security.logout') }}">{{ _('Logout') }}</a>
                    </div>
                  </li>

                {% else %}
                  <a class="nav-item nav-link" href="{{ url_for('security.login') }}">{{ _fsdomain('Login') }}</a>
                  <a class="nav-item nav-link" href="{{ url_for('security.register') }}">{{ _fsdomain('Register') }}</a>
                {% endif %}

              </div>
          </div>
      </nav>
      {%- endblock navbar %}
      {% block managebar -%}
      {% if current_admin_unit %}
      {% set menu_options = get_manage_menu_options(current_admin_unit) %}
      <nav class="navbar navbar-expand-md navbar-light bg-light">
          <span></span>
          <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAdminUnitMarkup" aria-controls="navbarNavAdminUnitMarkup" aria-expanded="false" aria-label="Toggle navigation">
              <span class="navbar-toggler-icon"></span>
          </button>
          <div class="collapse navbar-collapse" id="navbarNavAdminUnitMarkup">
              <div class="navbar-nav mr-auto">
                <li class="nav-item dropdown">
                  <a class="nav-link dropdown-toggle text-truncate" href="#" id="navbarAdminUnitEventsDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    {{ _('Events') }}
                    {% if menu_options['reviews_badge'] > 0 %}
                      <span class="badge badge-secondary badge-pill">{{ menu_options['reviews_badge'] }}</span>
                    {% endif %}
                  </a>
                  <div class="dropdown-menu" aria-labelledby="navbarAdminUnitEventsDropdown">
                    <a class="dropdown-item" href="{{ url_for('manage_admin_unit_events', id=current_admin_unit.id) }}">{{ _('Show events') }}</a>
                    <a class="dropdown-item" href="{{ url_for('event_create_for_admin_unit_id', id=current_admin_unit.id) }}">{{ _('Create event') }}</a>
                    <a class="dropdown-item" href="{{ url_for('manage_admin_unit_events_import', id=current_admin_unit.id) }}">{{ _('Import event') }}</a>
                    <div class="dropdown-divider"></div>
                    <a class="dropdown-item" href="{{ url_for('manage_admin_unit_event_lists', id=current_admin_unit.id) }}">{{ _('Event lists') }}</a>
                    {% if current_admin_unit.suggestions_enabled %}
                      <div class="dropdown-divider"></div>
                      <a class="dropdown-item" href="{{ url_for('manage_admin_unit_event_reviews', id=current_admin_unit.id) }}">{{ _('Review suggestions') }}
                        {% if menu_options['reviews_badge'] > 0 %}
                          <span class="badge badge-secondary badge-pill">{{ menu_options['reviews_badge'] }}</span>
                        {% endif %}
                      </a>
                    {% endif %}
                  </div>
                </li>
                <li class="nav-item dropdown">
                  <a class="nav-link dropdown-toggle text-truncate" href="#" id="navbarAdminUnitReferencesDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    {{ _('References') }}
                    {% if menu_options['reference_requests_incoming_badge'] > 0 %}
                      <span class="badge badge-secondary badge-pill">{{ menu_options['reference_requests_incoming_badge'] }}</span>
                    {% endif %}
                  </a>
                  <div class="dropdown-menu" aria-labelledby="navbarAdminUnitReferencesDropdown">
                    <a class="dropdown-item" href="{{ url_for('manage_admin_unit_references_incoming', id=current_admin_unit.id) }}">{{ _('Incoming references') }}</a>
                    <a class="dropdown-item" href="{{ url_for('manage_admin_unit_references_outgoing', id=current_admin_unit.id) }}">{{ _('Outgoing references') }}</a>
                    <div class="dropdown-divider"></div>
                    <a class="dropdown-item" href="{{ url_for('manage_admin_unit_reference_requests_incoming', id=current_admin_unit.id) }}">{{ _('Incoming reference requests') }}
                      {% if menu_options['reference_requests_incoming_badge'] > 0 %}
                        <span class="badge badge-secondary badge-pill">{{ menu_options['reference_requests_incoming_badge'] }}</span>
                      {% endif %}
                    </a>
                    <a class="dropdown-item" href="{{ url_for('manage_admin_unit_reference_requests_outgoing', id=current_admin_unit.id) }}">{{ _('Outgoing reference requests') }}</a>
                  </div>
                </li>
                <li class="nav-item dropdown">
                  <a class="nav-link dropdown-toggle text-truncate" href="#" id="navbarAdminUnitOrganizationDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    {{ _('Organization') }}
                  </a>
                  <div class="dropdown-menu" aria-labelledby="navbarAdminUnitOrganizationDropdown">
                    <a class="dropdown-item" href="{{ url_for('manage_admin_unit_organizers', id=current_admin_unit.id) }}">{{ _('Organizers') }}</a>
                    <a class="dropdown-item" href="{{ url_for('manage_admin_unit_event_places', id=current_admin_unit.id) }}">{{ _('Places') }}</a>
                    <div class="dropdown-divider"></div>
                    <a class="dropdown-item" href="{{ url_for('manage_admin_unit_members', id=current_admin_unit.id) }}">{{ _('Members') }}</a>
                    <a class="dropdown-item" href="{{ url_for('manage_admin_unit_relations', id=current_admin_unit.id) }}">{{ _('Relations') }}</a>
                    {% if current_admin_unit.can_invite_other %}
                    <a class="dropdown-item" href="{{ url_for('manage_admin_unit_organization_invitations', id=current_admin_unit.id) }}">{{ _('Organization invitations') }}</a>
                    {% endif %}
                    <a class="dropdown-item" href="{{ url_for('admin_unit_update', id=current_admin_unit.id) }}">{{ _('Settings') }}</a>
                    <a class="dropdown-item" href="{{ url_for('manage_admin_unit_custom_widgets', id=current_admin_unit.id) }}">{{ _('Custom widgets') }}</a>
                    <a class="dropdown-item" href="{{ url_for('manage_admin_unit_widgets', id=current_admin_unit.id) }}">{{ _('Widgets') }}</a>
                    <a class="dropdown-item" href="{{ url_for('organizations', path=current_admin_unit.id) }}">{{ _('Profile') }}</a>
                  </div>
                </li>
              </div>
              <div class="navbar-nav navbar-right">
                <li class="nav-item dropdown">
                  <a class="nav-link dropdown-toggle" href="#" id="navbarAdminUnitSwitchDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    {{ current_admin_unit.name }}
                  </a>
                  <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarAdminUnitSwitchDropdown">
                    <a class="dropdown-item" href="{{ url_for('manage_admin_units') }}">{{ _('Switch organization') }}</a>
                  </div>
                </li>
              </div>
          </div>
      </nav>
      {% endif %}
      {%- endblock managebar %}

      <div class="body-content"{% block body_content__attribs %}{% endblock body_content__attribs %}>

          {% block content_container -%}
          <main {% block content_container_attribs %}class="p-3"{% endblock content_container_attribs %}>
            {% include "_messages.html" %}

            {% block content -%}
            {%- endblock content %}
          </main>
          {%- endblock content_container %}

          <!-- Footer -->
          {% block footer -%}
          <footer class="footer mt-5">
            <div class="container">
              <div class="row">
                <div class="col h-100 text-center my-auto">
                  <ul class="list-inline mb-2">
                    <li class="list-inline-item">
                      <a href="{{ url_for('tos') }}" class="text-muted">{{ _('Terms of service') }}</a>
                    </li>
                    <li class="list-inline-item">&sdot;</li>
                    <li class="list-inline-item">
                      <a href="{{ url_for('legal_notice') }}" class="text-muted">{{ _('Legal notice') }}</a>
                    </li>
                    <li class="list-inline-item">&sdot;</li>
                    <li class="list-inline-item">
                      <a href="{{ url_for('contact') }}" class="text-muted">{{ _('Contact') }}</a>
                    </li>
                    <li class="list-inline-item">&sdot;</li>
                    <li class="list-inline-item">
                      <a href="{{ url_for('privacy') }}" class="text-muted">{{ _('Privacy') }}</a>
                    </li>
                    <li class="list-inline-item">&sdot;</li>
                    <li class="list-inline-item">
                      <a href="{{ url_for('developer') }}" class="text-muted">{{ _('Developer') }}</a>
                    </li>
                  </ul>
                </div>
              </div>
            </div>
          </footer>
          {%- endblock footer %}

      </div>

      <script src="{{ url_for('static', filename='ext/popper.1.16.0.min.js')}}"></script>
      <script src="{{ url_for('static', filename='ext/bootstrap.4.4.1.min.js')}}"></script>
      {% block scripts %}
      {%- endblock scripts %}
    {%- endblock body %}
  </body>
  {%- endblock html %}
</html>
{% endblock doc -%}