added /manage/ and /manage/accounts/ views, added TOC to template

This commit is contained in:
Yusur 2023-03-22 09:49:38 +01:00
parent 4536f7fbd9
commit 191e235137
9 changed files with 162 additions and 21 deletions

View file

@ -0,0 +1,23 @@
{% extends "base.jinja2" %}
{% block title %}Administrative tools — {{ app_name }}{% endblock %}
{% block content %}
<h1>Administrative tools</h1>
{% if current_user and current_user.is_admin %}
<ul>
<li>
<a href="/manage/export">Export pages</a>
</li>
<li>
<a href="/manage/import">Import pages</a>
</li>
<li>
<a href="/manage/accounts">Manage accounts</a>
</li>
</ul>
{% else %}
<p>Administrative tools can be accessed by administrator users only.</p>
{% endif %}
{% endblock %}

View file

@ -52,6 +52,7 @@
<div class="flash">{{ msg }}</div>
{% endfor %}
{% block content %}{% endblock %}
{% block toc %}{% endblock %}
</div>
<footer class="footer">
<div class="footer-copyright">&copy; 20202023 Sakuragasaki46.</div>

View file

@ -7,10 +7,17 @@
{% endblock %}
{% block content %}
<h1>Contributions of {{ u.username }}</div>
<h1>Contributions of {{ u.username }}</h1>
<p class="nl-pagination">Showing results <strong>{{ page_n * 20 - 19 }}</strong> to <strong>{{ min(page_n * 20, total_count) }}</strong> of <strong>{{ total_count }}</strong> total.</p>
<ul>
{% for rev in contributions %}
{% if page_n > 1 %}
<li class="nl-prev"><a href="?page={{ page_n - 1}}">&laquo; Previous page</a></li>
{% endif %}
{% for rev in contributions %}
<li>
<a href="/history/revision/{{ rev.id }}/">
#{{ rev.id }}
@ -25,6 +32,10 @@
{{ rev.page.title }}
</a>
</li>
{% endfor %}
{% endfor %}
{% if page_n < total_count // 20 %}
<li class="nl-next"><a href="?page={{ page_n + 1 }}">Next page &raquo;</a></li>
{% endif %}
</ul>
{% endblock %}

View file

@ -0,0 +1,52 @@
{% extends "base.jinja2" %}
{% block title %}Manage accounts - {{ app_name }}{% endblock %}
{% block content %}
<h1>Manage accounts</h1>
{% if current_user.is_admin %}
<p>
Here is the list of users registered on {{ app_name }}, in reverse chronological order.
<strong>Beware: you are managing sensitive informations.</strong>
</p>
<p class="nl-pagination">Showing results <strong>{{ page_n * 20 - 19 }}</strong> to <strong>{{ min(page_n * 20, total_count) }}</strong> of <strong>{{ total_count }}</strong> total.</p>
<form enctype="multipart/form-data" method="POST">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<ul>
{% if page_n > 1 %}
<li class="nl-prev"><a href="?page={{ page_n - 1}}">&laquo; Previous page</a></li>
{% endif %}
{% for u in users %}
<li>
<input type="checkbox" name="u{{ u.id }}">
<a href="/@{{ u.username }}">{{ u.username }}</a>
{% if u == current_user %}<strong>(you)</strong>{% endif %}
-
Groups:
<ul class="inline">
{% for ug in u.groups() %}
<li>{{ ug.name }}</li>
{% endfor %}
</ul>
-
Registered on:
{{ u.join_date }}
</li>
{% endfor %}
{% if page_n < total_count // 20 %}
<li class="nl-next"><a href="?page={{ page_n + 1 }}">Next page &raquo;</a></li>
{% endif %}
</ul>
</form>
{% else %}
<p>Managing accounts can be done by users with Admin permissions only.</p>
{% endif %}
{% endblock %}

View file

@ -1,9 +1,9 @@
{% extends "base.jinja2" %}
{% block title %}Not found - {{ app_name }}{% endblock %}
{% block title %}{{ T('not-found') }} - {{ app_name }}{% endblock %}
{% block content %}
<h1>{{ T('not-found') }}</h1>
<p>{{ T('not-found-text-1')}} <strong>{{ request.path }}</strong> {{ T('not-found-text-2' )}}.</p>
<p>{{ T('not-found-text-1') }} <strong>{{ request.path }}</strong> {{ T('not-found-text-2') }}.</p>
{% endblock %}

View file

@ -4,12 +4,14 @@
{% block json_info %}<script>window.page_info={{ p.js_info()|tojson|safe }};</script>{% endblock %}
{% set html_and_toc = rev.html_and_toc(math = request.args.get('math') not in ['0', 'false', 'no', 'off']) %}
{% block content %}
<article>
<h1 id="firstHeading">{{ p.title }}</h1>
{% if p.calendar %}
<p class="calendar-subtitle"><span class="material-icons">calendar_today</span>{{ p.calendar.strftime('%B %-d, %Y') }}</div>
<p class="calendar-subtitle"><span class="material-icons">calendar_today</span>{{ p.calendar.strftime('%B %-d, %Y') }}</p>
{% endif %}
<div class="jump-to-actions">
@ -28,7 +30,7 @@
{% endif %}
<div class="inner-content">
{{ rev.html(math = request.args.get('math') not in ['0', 'false', 'no', 'off'])|safe }}
{{ html_and_toc[0]|safe }}
</div>
{% if p.tags %}
@ -54,6 +56,12 @@
{{ T('owner') }}: {{ p.owner.username }}
{% endblock %}
{% block toc %}
<nav class="toc">
{{ html_and_toc[1] }}
</nav>
{% endblock %}
{% block scripts %}
<script src="/static/content.js"></script>
{% endblock %}