Spaces:
Sleeping
Sleeping
Update templates/generale.html
Browse files- templates/generale.html +228 -208
templates/generale.html
CHANGED
@@ -1,221 +1,241 @@
|
|
1 |
-
<!DOCTYPE html>
|
2 |
<html lang="fr">
|
3 |
-
|
4 |
<head>
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
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 |
-
background-image: linear-gradient(to right, #4facfe, #00f2fe);
|
37 |
-
background-size: 200% auto;
|
38 |
-
box-shadow: 0 4px 15px 0 rgba(65, 132, 234, 0.75);
|
39 |
-
transition: background-position 0.3s ease-in-out, transform 0.2s ease-in-out, box-shadow 0.3s ease-in-out;
|
40 |
-
}
|
41 |
-
|
42 |
-
.animated-button:hover {
|
43 |
-
background-position: right center;
|
44 |
-
transform: translateY(-2px);
|
45 |
-
box-shadow: 0 6px 20px 0 rgba(65, 132, 234, 0.9);
|
46 |
}
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
</head>
|
66 |
-
|
67 |
<body class="bg-gradient-to-r from-gray-100 to-gray-200 min-h-screen flex items-center justify-center font-sans">
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
<div class="mb-6">
|
77 |
-
<label for="questionInput" class="block mb-2 text-lg font-medium text-gray-700">Votre question :</label>
|
78 |
-
<textarea id="questionInput" class="w-full p-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-400 input-underline" rows="4" placeholder="Entrez votre question ici..."></textarea>
|
79 |
-
</div>
|
80 |
-
|
81 |
-
<div class="mb-6">
|
82 |
-
<label for="urlInput" class="block mb-2 text-lg font-medium text-gray-700">URLs (optionnel) :</label>
|
83 |
-
<div class="flex">
|
84 |
-
<input type="text" id="urlInput" class="flex-grow p-3 border border-gray-300 rounded-l-lg focus:ring-2 focus:ring-blue-400 input-underline" placeholder="Entrez une URL">
|
85 |
-
<button onclick="addUrl()" class="animated-button text-white px-4 py-2 rounded-r-lg">Ajouter</button>
|
86 |
-
</div>
|
87 |
-
<div id="urlList" class="mt-2 space-y-2"></div>
|
88 |
-
</div>
|
89 |
-
|
90 |
-
<div class="mb-6">
|
91 |
-
<label for="fileUpload" class="block mb-2 text-lg font-medium text-gray-700">Fichiers (optionnel) :</label>
|
92 |
-
<input type="file" id="fileUpload" class="w-full p-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-400 input-underline" multiple>
|
93 |
-
</div>
|
94 |
-
|
95 |
-
<button onclick="submitQuestion()" class="animated-button w-full text-white px-4 py-3 rounded-lg text-lg font-medium">Soumettre</button>
|
96 |
-
|
97 |
-
<div id="loader" class="hidden mt-4">
|
98 |
-
<div class="flex justify-center items-center">
|
99 |
-
<div class="animate-spin rounded-full h-12 w-12 border-t-4 border-b-4 border-blue-500"></div>
|
100 |
-
<p class="ml-2 text-gray-600">Chargement en cours...</p>
|
101 |
-
</div>
|
102 |
-
</div>
|
103 |
-
|
104 |
-
<div id="response" class="mt-6 p-4 bg-gray-100 rounded-lg shadow-lg"></div>
|
105 |
-
|
106 |
-
<div id="copyResponseContainer" class="hidden mt-4">
|
107 |
-
<button onclick="copyResponse()" class="animated-button w-full text-white px-4 py-2 rounded-lg flex items-center justify-center">
|
108 |
-
<i class="fas fa-copy mr-2"></i>Copier la réponse
|
109 |
-
</button>
|
110 |
-
</div>
|
111 |
</div>
|
112 |
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
<p class="mb-2">Ce formulaire vous permet de poser des questions générales.</p>
|
119 |
-
<p class="mb-2">Vous pouvez également ajouter des URLs et des fichiers pour fournir plus de contexte à votre question.</p>
|
120 |
-
<p>La réponse sera formatée en Markdown et peut inclure des équations LaTeX.</p>
|
121 |
-
<p class="mb-2">Et si vous avez le courage de résoudre vos exos de math ici, veuillez signaler à Mariam de répondre en utilisant du LaTeX.</p>
|
122 |
-
`,
|
123 |
-
icon: 'info',
|
124 |
-
confirmButtonText: 'Compris'
|
125 |
-
});
|
126 |
-
}
|
127 |
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
<i class="fas fa-times"></i>
|
140 |
-
</button>
|
141 |
-
`;
|
142 |
-
urlList.appendChild(urlItem);
|
143 |
-
urlInput.value = '';
|
144 |
-
}
|
145 |
-
}
|
146 |
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
|
|
151 |
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
document.querySelectorAll('#urlList .url-item').forEach(item => {
|
169 |
-
formData.append('urls', item.querySelector('span').textContent);
|
170 |
-
});
|
171 |
-
|
172 |
-
Array.from(document.getElementById('fileUpload').files).forEach(file => {
|
173 |
-
formData.append('files', file);
|
174 |
-
});
|
175 |
-
|
176 |
-
try {
|
177 |
-
const response = await fetch('/submit', {
|
178 |
-
method: 'POST',
|
179 |
-
body: formData
|
180 |
-
});
|
181 |
-
const data = await response.json();
|
182 |
-
|
183 |
-
loader.classList.add('hidden');
|
184 |
-
responseDiv.classList.remove('opacity-0');
|
185 |
-
|
186 |
-
if (data.error) {
|
187 |
-
responseDiv.innerHTML = `<p class="text-red-600">Erreur : ${data.error}</p>`;
|
188 |
-
} else {
|
189 |
-
const htmlContent = marked.parse(data.response);
|
190 |
-
responseDiv.innerHTML = htmlContent;
|
191 |
-
copyResponseContainer.classList.remove('hidden');
|
192 |
-
|
193 |
-
await MathJax.typesetPromise([responseDiv]);
|
194 |
-
console.log('LaTeX rendu avec succès');
|
195 |
-
}
|
196 |
-
} catch (error) {
|
197 |
-
loader.classList.add('hidden');
|
198 |
-
responseDiv.innerHTML = `<p class="text-red-600">Erreur : ${error.message}</p>`;
|
199 |
-
responseDiv.classList.remove('opacity-0');
|
200 |
-
}
|
201 |
-
}
|
202 |
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
217 |
}
|
218 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
219 |
</body>
|
220 |
-
|
221 |
-
</html>
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
<html lang="fr">
|
|
|
3 |
<head>
|
4 |
+
<meta charset="UTF-8" />
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
6 |
+
<title>Question Générale</title>
|
7 |
+
<!-- Tailwind CSS -->
|
8 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
9 |
+
<!-- Marked (Markdown) -->
|
10 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/4.0.2/marked.min.js" defer></script>
|
11 |
+
<!-- Font Awesome -->
|
12 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" />
|
13 |
+
<!-- SweetAlert2 -->
|
14 |
+
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11" defer></script>
|
15 |
+
<!-- Polyfill -->
|
16 |
+
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6" defer></script>
|
17 |
+
<!-- Anime.js -->
|
18 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" defer></script>
|
19 |
+
<!-- MathJax -->
|
20 |
+
<script>
|
21 |
+
MathJax = {
|
22 |
+
tex: {
|
23 |
+
inlineMath: [['$', '$'], ['\\(', '\\)']],
|
24 |
+
displayMath: [['$$', '$$'], ['\\[', '\\]']],
|
25 |
+
processEscapes: true
|
26 |
+
},
|
27 |
+
options: {
|
28 |
+
skipHtmlTags: ['script', 'noscript', 'style', 'textarea', 'pre']
|
29 |
+
},
|
30 |
+
startup: {
|
31 |
+
pageReady: () => {
|
32 |
+
return MathJax.startup.defaultPageReady().then(() => {
|
33 |
+
console.log('MathJax initial typesetting complete');
|
34 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
}
|
36 |
+
}
|
37 |
+
};
|
38 |
+
</script>
|
39 |
+
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js" defer></script>
|
40 |
+
<style>
|
41 |
+
/* Bouton animé avec un dégradé pastel */
|
42 |
+
.animated-button {
|
43 |
+
background-image: linear-gradient(to right, #a1c4fd, #c2e9fb);
|
44 |
+
background-size: 200% auto;
|
45 |
+
box-shadow: 0 4px 15px rgba(161, 196, 253, 0.5);
|
46 |
+
transition: background-position 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
|
47 |
+
}
|
48 |
+
.animated-button:hover {
|
49 |
+
background-position: right center;
|
50 |
+
transform: translateY(-2px);
|
51 |
+
box-shadow: 0 6px 20px rgba(161, 196, 253, 0.7);
|
52 |
+
}
|
53 |
+
/* Effet de soulignement sur les champs de saisie */
|
54 |
+
.input-underline {
|
55 |
+
background-image: linear-gradient(to right, #a1c4fd, #c2e9fb);
|
56 |
+
background-size: 0% 2px;
|
57 |
+
background-repeat: no-repeat;
|
58 |
+
background-position: left bottom;
|
59 |
+
transition: background-size 0.3s ease;
|
60 |
+
}
|
61 |
+
.input-underline:focus {
|
62 |
+
background-size: 100% 2px;
|
63 |
+
outline: none;
|
64 |
+
}
|
65 |
+
/* Conteneur de réponse */
|
66 |
+
#response {
|
67 |
+
overflow-x: auto;
|
68 |
+
white-space: pre-wrap;
|
69 |
+
}
|
70 |
+
</style>
|
71 |
</head>
|
|
|
72 |
<body class="bg-gradient-to-r from-gray-100 to-gray-200 min-h-screen flex items-center justify-center font-sans">
|
73 |
+
<div class="container mx-auto p-8 bg-white rounded-3xl shadow-2xl max-w-3xl">
|
74 |
+
<!-- En-tête -->
|
75 |
+
<div class="flex flex-col md:flex-row md:justify-between items-start md:items-center mb-6 space-y-4 md:space-y-0">
|
76 |
+
<h1 class="text-3xl font-bold text-gray-800">Poser une question générale</h1>
|
77 |
+
<button onclick="showInfo()" class="animated-button text-white px-4 py-2 rounded-lg flex items-center">
|
78 |
+
<i class="fas fa-info-circle mr-2"></i> Info
|
79 |
+
</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
</div>
|
81 |
|
82 |
+
<!-- Zone de question -->
|
83 |
+
<div class="mb-6">
|
84 |
+
<label for="questionInput" class="block mb-2 text-lg font-medium text-gray-700">Votre question :</label>
|
85 |
+
<textarea id="questionInput" class="w-full p-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-400 input-underline" rows="4" placeholder="Entrez votre question ici..."></textarea>
|
86 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
|
88 |
+
<!-- Zone d'ajout d'URLs -->
|
89 |
+
<div class="mb-6">
|
90 |
+
<label for="urlInput" class="block mb-2 text-lg font-medium text-gray-700">URLs (optionnel) :</label>
|
91 |
+
<div class="flex">
|
92 |
+
<input type="text" id="urlInput" class="flex-grow p-3 border border-gray-300 rounded-l-lg focus:ring-2 focus:ring-blue-400 input-underline" placeholder="Entrez une URL" />
|
93 |
+
<button onclick="addUrl()" class="animated-button text-white px-4 py-2 rounded-r-lg">
|
94 |
+
Ajouter
|
95 |
+
</button>
|
96 |
+
</div>
|
97 |
+
<div id="urlList" class="mt-2 space-y-2"></div>
|
98 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
|
100 |
+
<!-- Zone d'ajout de fichiers -->
|
101 |
+
<div class="mb-6">
|
102 |
+
<label for="fileUpload" class="block mb-2 text-lg font-medium text-gray-700">Fichiers (optionnel) :</label>
|
103 |
+
<input type="file" id="fileUpload" class="w-full p-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-400 input-underline" multiple />
|
104 |
+
</div>
|
105 |
|
106 |
+
<!-- Bouton de soumission -->
|
107 |
+
<button onclick="submitQuestion()" class="animated-button w-full text-white px-4 py-3 rounded-lg text-lg font-medium">
|
108 |
+
Soumettre
|
109 |
+
</button>
|
110 |
+
|
111 |
+
<!-- Loader -->
|
112 |
+
<div id="loader" class="hidden mt-4">
|
113 |
+
<div class="flex justify-center items-center">
|
114 |
+
<div class="animate-spin rounded-full h-12 w-12 border-t-4 border-b-4 border-blue-500"></div>
|
115 |
+
<p class="ml-2 text-gray-600">Chargement en cours...</p>
|
116 |
+
</div>
|
117 |
+
</div>
|
118 |
+
|
119 |
+
<!-- Affichage de la réponse -->
|
120 |
+
<div id="response" class="mt-6 p-4 bg-gray-100 rounded-lg shadow-lg"></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
|
122 |
+
<!-- Bouton pour copier la réponse -->
|
123 |
+
<div id="copyResponseContainer" class="hidden mt-4">
|
124 |
+
<button onclick="copyResponse()" class="animated-button w-full text-white px-4 py-2 rounded-lg flex items-center justify-center">
|
125 |
+
<i class="fas fa-copy mr-2"></i> Copier la réponse
|
126 |
+
</button>
|
127 |
+
</div>
|
128 |
+
</div>
|
129 |
+
|
130 |
+
<script>
|
131 |
+
function showInfo() {
|
132 |
+
Swal.fire({
|
133 |
+
title: 'Information',
|
134 |
+
html: `
|
135 |
+
<p class="mb-2">Ce formulaire vous permet de poser des questions générales.</p>
|
136 |
+
<p class="mb-2">Vous pouvez également ajouter des URLs et des fichiers pour fournir plus de contexte à votre question.</p>
|
137 |
+
<p class="mb-2">La réponse sera formatée en Markdown et peut inclure des équations LaTeX.</p>
|
138 |
+
<p>Si vous souhaitez résoudre vos exercices de mathématiques ici, signalez-le à Mariam pour une réponse en LaTeX.</p>
|
139 |
+
`,
|
140 |
+
icon: 'info',
|
141 |
+
confirmButtonText: 'Compris'
|
142 |
+
});
|
143 |
+
}
|
144 |
+
|
145 |
+
function addUrl() {
|
146 |
+
const urlInput = document.getElementById('urlInput');
|
147 |
+
const urlList = document.getElementById('urlList');
|
148 |
+
const url = urlInput.value.trim();
|
149 |
+
|
150 |
+
if (url) {
|
151 |
+
// Création d'un élément URL avec la classe "url-item"
|
152 |
+
const urlItem = document.createElement('div');
|
153 |
+
urlItem.className = 'url-item flex items-center bg-gray-200 p-2 rounded-lg shadow-sm';
|
154 |
+
urlItem.innerHTML = `
|
155 |
+
<span class="flex-grow truncate">${url}</span>
|
156 |
+
<button onclick="removeUrl(this)" class="ml-2 text-red-500 hover:text-red-700">
|
157 |
+
<i class="fas fa-times"></i>
|
158 |
+
</button>
|
159 |
+
`;
|
160 |
+
urlList.appendChild(urlItem);
|
161 |
+
urlInput.value = '';
|
162 |
+
}
|
163 |
+
}
|
164 |
+
|
165 |
+
function removeUrl(button) {
|
166 |
+
const urlItem = button.closest('.url-item');
|
167 |
+
if(urlItem) urlItem.remove();
|
168 |
+
}
|
169 |
+
|
170 |
+
async function submitQuestion() {
|
171 |
+
const question = document.getElementById('questionInput').value.trim();
|
172 |
+
if (!question) return;
|
173 |
+
|
174 |
+
const loader = document.getElementById('loader');
|
175 |
+
const responseDiv = document.getElementById('response');
|
176 |
+
const copyResponseContainer = document.getElementById('copyResponseContainer');
|
177 |
+
|
178 |
+
loader.classList.remove('hidden');
|
179 |
+
responseDiv.innerHTML = '';
|
180 |
+
responseDiv.classList.add('opacity-0');
|
181 |
+
copyResponseContainer.classList.add('hidden');
|
182 |
+
|
183 |
+
const formData = new FormData();
|
184 |
+
formData.append('question', question);
|
185 |
+
|
186 |
+
// Récupération des URLs
|
187 |
+
document.querySelectorAll('#urlList .url-item').forEach(item => {
|
188 |
+
formData.append('urls', item.querySelector('span').textContent);
|
189 |
+
});
|
190 |
+
|
191 |
+
// Récupération des fichiers
|
192 |
+
Array.from(document.getElementById('fileUpload').files).forEach(file => {
|
193 |
+
formData.append('files', file);
|
194 |
+
});
|
195 |
+
|
196 |
+
try {
|
197 |
+
const response = await fetch('/submit', {
|
198 |
+
method: 'POST',
|
199 |
+
body: formData
|
200 |
+
});
|
201 |
+
const data = await response.json();
|
202 |
+
|
203 |
+
loader.classList.add('hidden');
|
204 |
+
responseDiv.classList.remove('opacity-0');
|
205 |
+
|
206 |
+
if (data.error) {
|
207 |
+
responseDiv.innerHTML = `<p class="text-red-600">Erreur : ${data.error}</p>`;
|
208 |
+
} else {
|
209 |
+
const htmlContent = marked.parse(data.response);
|
210 |
+
responseDiv.innerHTML = htmlContent;
|
211 |
+
copyResponseContainer.classList.remove('hidden');
|
212 |
+
|
213 |
+
// Rendu de LaTeX avec MathJax
|
214 |
+
await MathJax.typesetPromise([responseDiv]);
|
215 |
+
console.log('LaTeX rendu avec succès');
|
216 |
}
|
217 |
+
} catch (error) {
|
218 |
+
loader.classList.add('hidden');
|
219 |
+
responseDiv.innerHTML = `<p class="text-red-600">Erreur : ${error.message}</p>`;
|
220 |
+
responseDiv.classList.remove('opacity-0');
|
221 |
+
}
|
222 |
+
}
|
223 |
+
|
224 |
+
function copyResponse() {
|
225 |
+
const responseDiv = document.getElementById('response');
|
226 |
+
const text = responseDiv.innerText;
|
227 |
+
navigator.clipboard.writeText(text).then(() => {
|
228 |
+
Swal.fire({
|
229 |
+
icon: 'success',
|
230 |
+
title: 'Copié !',
|
231 |
+
text: 'La réponse a été copiée dans le presse-papiers.',
|
232 |
+
showConfirmButton: false,
|
233 |
+
timer: 1500
|
234 |
+
});
|
235 |
+
}).catch(err => {
|
236 |
+
console.error('Erreur lors de la copie:', err);
|
237 |
+
});
|
238 |
+
}
|
239 |
+
</script>
|
240 |
</body>
|
241 |
+
</html>
|
|