Update templates/thread.html
Browse files- templates/thread.html +72 -41
templates/thread.html
CHANGED
@@ -1,45 +1,75 @@
|
|
1 |
{% extends "base.html" %}
|
2 |
{% block title %}{{ thread.title }}{% endblock %}
|
3 |
{% block content %}
|
4 |
-
<h2>{{ thread.title }}</h2>
|
5 |
-
<p>Créé le {{ thread.timestamp.strftime('%d/%m/%Y %H:%M:%S') }}</p>
|
6 |
-
|
7 |
-
<
|
8 |
-
{% for msg in messages %}
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
{
|
33 |
-
<
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
<script>
|
42 |
-
// Prévisualisation via l'API /preview
|
43 |
function previewMessage() {
|
44 |
const content = document.getElementById('reply-content').value;
|
45 |
fetch('{{ url_for('preview') }}', {
|
@@ -53,11 +83,12 @@ function previewMessage() {
|
|
53 |
document.getElementById('preview-area').innerHTML = data.preview;
|
54 |
});
|
55 |
}
|
56 |
-
|
57 |
function quoteMessage(messageId, content) {
|
58 |
const replyArea = document.getElementById('reply-content');
|
59 |
-
|
|
|
60 |
replyArea.focus();
|
61 |
}
|
62 |
</script>
|
63 |
-
{% endblock %}
|
|
|
1 |
{% extends "base.html" %}
|
2 |
{% block title %}{{ thread.title }}{% endblock %}
|
3 |
{% block content %}
|
4 |
+
<h2 class="text-2xl font-semibold mb-2">{{ thread.title }}</h2> <!-- Titre du fil -->
|
5 |
+
<p class="text-gray-500 mb-4">Créé le {{ thread.timestamp.strftime('%d/%m/%Y %H:%M:%S') }}</p> <!-- Date de création -->
|
6 |
+
|
7 |
+
<div class="messages space-y-6"> <!-- Conteneur pour les messages, espacement vertical -->
|
8 |
+
{% for msg in messages %}
|
9 |
+
<div class="message {% if msg.removed %}bg-gray-200 text-gray-500{% else %}bg-white{% endif %} p-4 rounded-md shadow-sm"> <!-- Style du message, condition pour les messages supprimés -->
|
10 |
+
{% if not msg.removed %}
|
11 |
+
<p class="text-gray-800">{{ msg.content | safe }}</p> <!-- Contenu du message -->
|
12 |
+
<div class="text-sm text-gray-500 mt-1 mb-2"> <!-- Informations sur le message -->
|
13 |
+
Posté le {{ msg.timestamp.strftime('%d/%m/%Y %H:%M:%S') }} - Votes: {{ msg.vote_count }}
|
14 |
+
</div>
|
15 |
+
<div class="message-actions flex items-center space-x-4"> <!-- Actions sur le message -->
|
16 |
+
<form action="{{ url_for('vote', message_id=msg.id, action='up') }}" method="POST">
|
17 |
+
<button type="submit" aria-label="Upvote"
|
18 |
+
class="text-green-500 hover:text-green-700 transition-colors duration-200">
|
19 |
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
|
20 |
+
<path stroke-linecap="round" stroke-linejoin="round" d="M12 19.5v-15m0 0l-6.75 6.75M12 4.5l6.75 6.75" />
|
21 |
+
</svg>
|
22 |
+
</button>
|
23 |
+
</form>
|
24 |
+
<form action="{{ url_for('vote', message_id=msg.id, action='down') }}" method="POST">
|
25 |
+
<button type="submit" aria-label="Downvote"
|
26 |
+
class="text-red-500 hover:text-red-700 transition-colors duration-200">
|
27 |
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
|
28 |
+
<path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m0 0l6.75-6.75M12 19.5l-6.75-6.75" />
|
29 |
+
</svg>
|
30 |
+
</button>
|
31 |
+
</form>
|
32 |
+
<form action="{{ url_for('report', message_id=msg.id) }}" method="POST">
|
33 |
+
<button type="submit" aria-label="Report"
|
34 |
+
class="text-yellow-600 hover:text-yellow-800 transition-colors duration-200">
|
35 |
+
Signaler
|
36 |
+
|
37 |
+
</button>
|
38 |
+
</form>
|
39 |
+
<button onclick="quoteMessage('{{ msg.id }}', '{{ msg.content|escapejs }}')"
|
40 |
+
class="text-blue-500 hover:text-blue-700 transition-colors duration-200">
|
41 |
+
Citer
|
42 |
+
</button>
|
43 |
+
</div>
|
44 |
+
{% else %}
|
45 |
+
<p class="italic">Message supprimé par modération.</p> <!-- Message supprimé -->
|
46 |
+
{% endif %}
|
47 |
+
</div>
|
48 |
+
{% else %}
|
49 |
+
<p class="text-gray-600">Aucun message pour ce fil.</p> <!-- Aucun message -->
|
50 |
+
{% endfor %}
|
51 |
+
</div>
|
52 |
+
|
53 |
+
<div class="mt-6"> <!-- Marge en haut -->
|
54 |
+
<h3 class="text-xl font-semibold mb-3">Répondre</h3> <!-- Titre du formulaire -->
|
55 |
+
<form method="POST" action="{{ url_for('thread', thread_id=thread.id) }}" class="space-y-4"> <!-- Formulaire de réponse -->
|
56 |
+
<textarea name="content" id="reply-content" rows="5" placeholder="Votre réponse ici..." required
|
57 |
+
class="block w-full p-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"></textarea>
|
58 |
+
<div class="flex items-center space-x-4"> <!-- Boutons -->
|
59 |
+
<button type="button" onclick="previewMessage()"
|
60 |
+
class="bg-gray-200 hover:bg-gray-300 text-gray-800 font-bold py-2 px-4 rounded transition-colors duration-200">
|
61 |
+
Prévisualiser
|
62 |
+
</button>
|
63 |
+
<button type="submit"
|
64 |
+
class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded transition-colors duration-200">
|
65 |
+
Poster
|
66 |
+
</button>
|
67 |
+
</div>
|
68 |
+
</form>
|
69 |
+
<div id="preview-area" class="mt-4"></div> <!-- Zone de prévisualisation -->
|
70 |
+
</div>
|
71 |
+
|
72 |
<script>
|
|
|
73 |
function previewMessage() {
|
74 |
const content = document.getElementById('reply-content').value;
|
75 |
fetch('{{ url_for('preview') }}', {
|
|
|
83 |
document.getElementById('preview-area').innerHTML = data.preview;
|
84 |
});
|
85 |
}
|
86 |
+
|
87 |
function quoteMessage(messageId, content) {
|
88 |
const replyArea = document.getElementById('reply-content');
|
89 |
+
const quotedContent = `<div class="quoted-text"><p class="quoted-message-id">ID du message: ${messageId}</p>${content}</div>`;
|
90 |
+
replyArea.value = quotedContent + "\n\n" + replyArea.value;
|
91 |
replyArea.focus();
|
92 |
}
|
93 |
</script>
|
94 |
+
{% endblock %}
|