{% extends "base/base.html" %}

{# This macro will allow us to perform recursive HTML generation #}
{% macro forumtree(f, level) %}
	<tr>
		<td><code>{{ f.url }}</code></td>
		<td style='padding-left: {{ 6+24*level }}px'>
			<a href='/forum{{ f.url }}'>{{ f.name }}</a>
		</td>
		<td>{{ f.topics | length }}</td>
		<td>{{ f.post_count() }}</td>
	</tr>

	{% for subf in f.sub_forums %}
		{{ forumtree(subf, level+1) }}
	{% endfor %}
{% endmacro %}

{% block title %}
<a href="{{ url_for('adm') }}">Panneau d'administration</a> » <h1>Forums</h1>
{% endblock %}

{% block content %}
<section>
	<p>Cette page permet de gérer l'arbre des forums.</p>

	<h2>Arbre des forums</h2>

	{% if main_forum == None %}
		<p>Il n'y a aucun forum.</p>
	{% else %}
		<table style='width: 90%; margin: auto'>
			<tr><th>URL</th><th>Nom</th><th>Sujets</th><th>Messages</th></tr>
			{{ forumtree(main_forum, 0) }}
		</table>
	{% endif %}
</section>
{% endblock %}
