{% extends "base.html" %}
{% load mptt_tags documents_markup documents_utils %}

{% block head_title %}{{ page_instance.title }}{% endblock %}

{% block head_more_links %}
    <link rel="Stylesheet" title="Normal" media="screen" type="text/css" href="{{ STATIC_URL }}documents/css/pygments.css"/>
    <link rel="stylesheet" href="{{ STATIC_URL }}documents/css/restructuredtext.css" type="text/css" />
{% endblock %}

{% block breadcrumbs %}{{ block.super }}
{% for item in page_instance.get_ancestors %}
    <a href="{% url documents-page-details item.slug %}">{{ item.title }}</a> &gt; 
{% endfor %}
    <a href="{% url documents-page-details page_instance.slug %}">{{ page_instance.title }}</a>
{% endblock %}

{% block action_menu %}
<div class="document_action_menu">
    <ul class="flat_bulletlist">
        {% if user.is_staff %}<li><a href="{% url documents-page-edit page_instance.slug %}">Editer</a></li>
        <li><a href="{% url documents-page-delete page_instance.slug %}">Supprimer</a></li>{% endif %}
        <li><a href="{% url documents-page-source page_instance.slug %}">Source</a></li>
    </ul>
    <div class="cale"></div>
</div>{% endblock %}

{% block content %}
{% document_context page_instance %}

<h2{% if page_instance.level == 0 %} class="root_page"{% endif %}>{{ page_instance.title }}</h2>

<div class="restructuredtext_container">
    {{ document_render }}
</div>
{% endblock %}

{% block context_menu_content %}
    {% if document_toc %}
        <h2>Sommaire</h2>
        {{ document_toc }}
    {% endif %}
    
    {% with document_navigation as tree_descendants %}
    {% if tree_descendants %}
        <h2>Navigation</h2>
        <ul class="tree_bulletlist">
            {% recursetree tree_descendants %}
                <li{% if active_page_instance and active_page_instance.slug == node.slug %} class="active"{% endif %}>
                    <a href="{% url documents-page-details node.slug %}">{{ node.title }}</a>
                    {% if not node.is_leaf_node %}
                        <ul class="children">
                            {{ children }}
                        </ul>
                    {% endif %}
                </li>
            {% endrecursetree %}
        </ul>
    {% endif %}
    {% endwith %}
{% endblock %}