2024-07-23 21:51:42 +01:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
{% set title = "Vérités Fabula Ultima" %}
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<title>{{ title }}</title>
|
|
|
|
<link href="/style.css" rel="stylesheet"/>
|
|
|
|
{% if user.logged_in == true and not user.is_admin %}
|
|
|
|
<script defer="defer" type="text/javascript" src="/vote_handler.js"></script>
|
|
|
|
{% endif %}
|
|
|
|
<script defer="defer" type="application/javascript" src="https://cdn.jsdelivr.net/npm/chart.js@4.4.3/dist/chart.umd.min.js"></script>
|
|
|
|
<script defer="defer" type="text/javascript" src="/vote_chart.js"></script>
|
|
|
|
</head>
|
|
|
|
|
|
|
|
{# Check if the user has a vote in advance, for readability #}
|
|
|
|
{% if user.logged_in == true and user.has_week_vote == true%}
|
|
|
|
{% set has_vote = true %}
|
|
|
|
{% else %}
|
|
|
|
{% set has_vote = false %}
|
|
|
|
{% endif -%}
|
|
|
|
|
|
|
|
<body>
|
|
|
|
<div class="top_bar">
|
|
|
|
<h1>{{ title }}</h1>
|
|
|
|
{% if user.logged_in == true %}
|
|
|
|
<p>Connecté en tant que <b>{{ user.name }}</b></p>
|
|
|
|
{% else %}
|
|
|
|
<form class="login" id="login" action="/login" method="POST">
|
|
|
|
<label>Pseudo <input form="login" type="text" name="name"/></label>
|
|
|
|
<label>Mot de passe <input form="login" type="password" name="password"/></label>
|
|
|
|
<button form="login">Se connecter</button>
|
|
|
|
</form>
|
|
|
|
{% endif %}
|
|
|
|
</div>
|
|
|
|
|
2024-07-23 21:51:51 +01:00
|
|
|
<h2>Semaine {{ week_data.number }}</h2>
|
2024-07-23 21:51:42 +01:00
|
|
|
<div class="page_body">
|
|
|
|
<div class="truth_list">
|
2024-07-23 21:51:51 +01:00
|
|
|
<div class="week_intro">
|
|
|
|
{{ week_data.rendered_text | safe }}
|
|
|
|
{%- if user.is_admin == true -%}
|
|
|
|
<hr/>
|
|
|
|
<form action="/{{ week_data.number }}/edit" method="post">
|
|
|
|
<textarea class="editor" name="raw_intro">
|
|
|
|
{{- week_data.raw_text -}}
|
|
|
|
</textarea>
|
|
|
|
<button>
|
|
|
|
Modifier l'introduction
|
|
|
|
</button>
|
|
|
|
</form>
|
|
|
|
{% endif %}
|
|
|
|
</div>
|
2024-07-23 21:51:42 +01:00
|
|
|
{% if user.logged_in == true and user.is_admin == false %}
|
2024-07-23 21:51:51 +01:00
|
|
|
<form id="truths" action="/{{ week_data.number }}/vote" method="POST">
|
2024-07-23 21:51:42 +01:00
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
{# Truths start at 1 but the array starts at 0 #}
|
|
|
|
{% set index_delta = 1 %}
|
|
|
|
{% for truth in truths %}
|
|
|
|
{#
|
|
|
|
The truths are in an ordered array, but one of them might be the user's.
|
|
|
|
In this case, we need to stop the array index from incrementing if the current
|
|
|
|
truth is the user's, as they cannot have voted for themselves, leading to one
|
|
|
|
less votes than there are truths.
|
|
|
|
#}
|
|
|
|
{%- if truth.author_id == user.id -%}
|
|
|
|
{%- set_global index_delta = 2 -%}
|
|
|
|
{% endif %}
|
|
|
|
{% set truth_index = truth.number - index_delta %}
|
|
|
|
|
|
|
|
{% if user.is_admin == true %}
|
|
|
|
{% include "editable_truth" %}
|
|
|
|
{% else %}
|
|
|
|
{% include "truth" %}
|
|
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
|
|
|
|
|
|
|
{% if user.logged_in == true and user.is_admin == false %}
|
|
|
|
<br/>
|
|
|
|
<button form="truths">
|
|
|
|
{%- if has_vote == true -%}
|
|
|
|
Changer de vote
|
|
|
|
{% else %}
|
|
|
|
À voter !
|
|
|
|
{% endif %}
|
|
|
|
</button>
|
|
|
|
</form>
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
{# If admin, show an additional box for creating a new Truth. #}
|
|
|
|
{% if user.is_admin == true %}
|
|
|
|
<div class="individual_truth">
|
|
|
|
<h3>Nouvelle vérité</h3>
|
2024-07-23 21:51:51 +01:00
|
|
|
<form action="/{{ week_data.number }}/new" method="POST">
|
2024-07-23 21:51:42 +01:00
|
|
|
{% include "truth_editor" %}
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
{% endif %}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="graph">
|
|
|
|
<div>
|
|
|
|
<canvas id="vote_chart"></canvas>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|