{% extends "sveedocuments/page_details/subbase.html" %}
{% load i18n mptt_tags documents_markup documents_utils %}

{% block body_attr %} class="columned cols-by-two"{% 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 %}

{% comment %}TODO: There is a problem with the context tags which update context only in their 
blocks, so actually the tag must be rendered twice, one for content and one for TOC 
menu{% endcomment %}

{% block context_menu %}{% document_context page_instance %}
<div id="context-menu">
    {% if document_toc %}<div class="brick">
        <h2>{% trans "Table of content" %}</h2>
        {{ document_toc }}
    </div>{% endif %}
    
    {% with document_navigation as tree_descendants %}
    {% if tree_descendants %}<div class="brick">
        <h2>{% trans "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>
    </div>{% endif %}
    {% endwith %}
</div>{% endblock %}