{% extends "core/base.jinja" %}

{% block title %}
  {% if page %}
    {{ page.get_display_name() }}
  {% elif page_list %}
    {% trans %}Page list{% endtrans %}
  {% elif new_page %}
    {% trans %}Create page{% endtrans %}
  {% else %}
    {% trans %}Not found{% endtrans %}
  {% endif %}
{% endblock %}

{% macro print_page_name(page) %}
  {% if page %}
    {{ print_page_name(page.parent) }} >
    <a href="{{ url('core:page', page_name=page.get_full_name()) }}">{{ page.get_display_name() }}</a>
  {% endif %}
{% endmacro %}

{% block content %}
  {{ print_page_name(page) }}

  <div class="tool_bar">
    <div class="tools">
      {% if page %}
        {% if page.club %}
          <a href="{{ url('club:club_view', club_id=page.club.id) }}">{% trans %}Return to club management{% endtrans %}</a>
        {% else %}
          <a href="{{ url('core:page', page.get_full_name()) }}">{% trans %}View{% endtrans %}</a>
        {% endif %}
        <a href="{{ url('core:page_hist', page_name=page.get_full_name()) }}">{% trans %}History{% endtrans %}</a>
        {% if can_edit(page, user) %}
          <a href="{{ url('core:page_edit', page_name=page.get_full_name()) }}">{% trans %}Edit{% endtrans %}</a>
        {% endif %}
        {% if can_edit_prop(page, user) and not page.is_club_page %}
          <a href="{{ url('core:page_prop', page_name=page.get_full_name()) }}">{% trans %}Prop{% endtrans %}</a>
        {% endif %}
      {% endif %}
    </div>
  </div>
  <hr>

  {% if page %}
    {% block page %}
    {% endblock %}
  {% else %}
    <h2>{% trans %}Page does not exist{% endtrans %}</h2>
    <p><a href="{{ url('core:page_new') }}?page={{ request.resolver_match.kwargs['page_name'] }}">
      {% trans %}Create it?{% endtrans %}</a></p>
  {% endif %}
{% endblock %}
