Spaces:
Sleeping
Sleeping
Update templates/philosophie.html
Browse files- templates/philosophie.html +123 -98
templates/philosophie.html
CHANGED
@@ -1,19 +1,16 @@
|
|
1 |
-
|
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>Assistant de Philosophie</title>
|
7 |
|
8 |
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/
|
9 |
-
<link rel="preconnect" href="https://fonts.googleapis.com">
|
10 |
-
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
11 |
-
<link href="https://fonts.googleapis.com/css2?family=Kalam&family=Lato:wght@400;700&display=swap" rel="stylesheet">
|
12 |
|
13 |
<style>
|
14 |
/* --- Styles Généraux et Interface --- */
|
15 |
body {
|
16 |
-
font-family:
|
17 |
background-color: #f4f4f9;
|
18 |
margin: 0;
|
19 |
padding: 20px;
|
@@ -68,11 +65,12 @@
|
|
68 |
}
|
69 |
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
|
70 |
.error { color: #c0392b; text-align: center; margin-top: 20px; }
|
|
|
71 |
|
72 |
-
/* --- Styles du Rendu "Cahier"
|
73 |
.dissertation-paper {
|
74 |
-
font-family: '
|
75 |
-
font-size:
|
76 |
color: #1a2a4c;
|
77 |
background-color: #fdfaf4;
|
78 |
line-height: 1.6;
|
@@ -82,20 +80,12 @@
|
|
82 |
min-height: 500px;
|
83 |
}
|
84 |
|
85 |
-
/* Lignes simulées avec des bordures au lieu de background-image */
|
86 |
-
.dissertation-paper p,
|
87 |
-
.dissertation-paper h2,
|
88 |
-
.dissertation-paper h3 {
|
89 |
-
border-bottom: 1px solid rgba(216, 226, 238, 0.3);
|
90 |
-
padding-bottom: 8px;
|
91 |
-
margin-bottom: 16px;
|
92 |
-
}
|
93 |
-
|
94 |
.dissertation-paper h2 {
|
95 |
font-size: 1.4em;
|
96 |
text-align: center;
|
97 |
margin-bottom: 24px;
|
98 |
font-weight: bold;
|
|
|
99 |
}
|
100 |
|
101 |
.dissertation-paper h3 {
|
@@ -115,6 +105,7 @@
|
|
115 |
.dissertation-paper p {
|
116 |
text-align: justify;
|
117 |
margin-bottom: 16px;
|
|
|
118 |
}
|
119 |
|
120 |
.dissertation-paper .prof {
|
@@ -136,37 +127,22 @@
|
|
136 |
font-weight: 500;
|
137 |
}
|
138 |
|
139 |
-
.
|
140 |
text-align: center;
|
141 |
margin-top: 40px;
|
142 |
-
border: none;
|
143 |
-
padding: 0;
|
144 |
}
|
145 |
|
146 |
-
.
|
147 |
-
font-family:
|
148 |
font-size: 16px;
|
149 |
padding: 12px 24px;
|
150 |
width: auto;
|
151 |
display: inline-block;
|
|
|
152 |
}
|
153 |
|
154 |
-
|
155 |
-
|
156 |
-
.pdf-button-container {
|
157 |
-
display: none !important;
|
158 |
-
}
|
159 |
-
|
160 |
-
.dissertation-paper {
|
161 |
-
margin: 0;
|
162 |
-
padding: 20px;
|
163 |
-
box-shadow: none;
|
164 |
-
border: none;
|
165 |
-
}
|
166 |
-
|
167 |
-
body {
|
168 |
-
background: white;
|
169 |
-
}
|
170 |
}
|
171 |
</style>
|
172 |
</head>
|
@@ -199,7 +175,6 @@
|
|
199 |
return;
|
200 |
}
|
201 |
|
202 |
-
// Simuler la génération d'une dissertation (à remplacer par votre API)
|
203 |
simulateGeneration(question);
|
204 |
});
|
205 |
|
@@ -209,7 +184,6 @@
|
|
209 |
loader.style.display = 'block';
|
210 |
resultContainer.innerHTML = '';
|
211 |
|
212 |
-
// Simulation d'une réponse (remplacez ceci par votre appel API réel)
|
213 |
setTimeout(() => {
|
214 |
const mockData = {
|
215 |
sujet: question,
|
@@ -257,94 +231,145 @@
|
|
257 |
<h2>Sujet : ${data.sujet}</h2>
|
258 |
<p class="prof">Prof : ${data.prof}</p>
|
259 |
<h3>Introduction</h3>
|
260 |
-
<p class="indented">${data.introduction
|
261 |
`;
|
262 |
|
263 |
data.parties.forEach((partie, index) => {
|
264 |
html += `<div class="development-block">`;
|
265 |
-
html += `<p class="indented">${partie.chapeau
|
266 |
partie.arguments.forEach(arg => {
|
267 |
-
html += `<p class="indented">${arg.paragraphe_argumentatif
|
268 |
});
|
269 |
html += `</div>`;
|
270 |
|
271 |
if (partie.transition) {
|
272 |
-
html += `<p class="indented transition">${partie.transition
|
273 |
}
|
274 |
});
|
275 |
|
276 |
html += `
|
277 |
<h3>Conclusion</h3>
|
278 |
-
<p class="indented">${data.conclusion
|
279 |
-
|
280 |
-
|
281 |
-
</
|
282 |
</div>
|
283 |
`;
|
284 |
|
285 |
resultContainer.innerHTML = html;
|
286 |
|
287 |
-
//
|
|
|
288 |
document.getElementById('download-pdf').addEventListener('click', generatePDF);
|
289 |
}
|
290 |
|
291 |
function generatePDF() {
|
292 |
-
const
|
293 |
-
const
|
294 |
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
const
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
323 |
}
|
324 |
-
};
|
325 |
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
})
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
343 |
}
|
344 |
|
345 |
function showError(message) {
|
346 |
resultContainer.innerHTML = `<p class="error">${message}</p>`;
|
347 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
348 |
});
|
349 |
</script>
|
350 |
|
|
|
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>Assistant de Philosophie</title>
|
7 |
|
8 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
|
|
|
|
|
|
|
9 |
|
10 |
<style>
|
11 |
/* --- Styles Généraux et Interface --- */
|
12 |
body {
|
13 |
+
font-family: Arial, sans-serif;
|
14 |
background-color: #f4f4f9;
|
15 |
margin: 0;
|
16 |
padding: 20px;
|
|
|
65 |
}
|
66 |
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
|
67 |
.error { color: #c0392b; text-align: center; margin-top: 20px; }
|
68 |
+
.success { color: #27ae60; text-align: center; margin-top: 20px; }
|
69 |
|
70 |
+
/* --- Styles du Rendu "Cahier" --- */
|
71 |
.dissertation-paper {
|
72 |
+
font-family: 'Times New Roman', serif;
|
73 |
+
font-size: 16px;
|
74 |
color: #1a2a4c;
|
75 |
background-color: #fdfaf4;
|
76 |
line-height: 1.6;
|
|
|
80 |
min-height: 500px;
|
81 |
}
|
82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
.dissertation-paper h2 {
|
84 |
font-size: 1.4em;
|
85 |
text-align: center;
|
86 |
margin-bottom: 24px;
|
87 |
font-weight: bold;
|
88 |
+
text-decoration: underline;
|
89 |
}
|
90 |
|
91 |
.dissertation-paper h3 {
|
|
|
105 |
.dissertation-paper p {
|
106 |
text-align: justify;
|
107 |
margin-bottom: 16px;
|
108 |
+
padding-bottom: 8px;
|
109 |
}
|
110 |
|
111 |
.dissertation-paper .prof {
|
|
|
127 |
font-weight: 500;
|
128 |
}
|
129 |
|
130 |
+
.pdf-button-container {
|
131 |
text-align: center;
|
132 |
margin-top: 40px;
|
|
|
|
|
133 |
}
|
134 |
|
135 |
+
.pdf-button {
|
136 |
+
font-family: Arial, sans-serif;
|
137 |
font-size: 16px;
|
138 |
padding: 12px 24px;
|
139 |
width: auto;
|
140 |
display: inline-block;
|
141 |
+
background-color: #27ae60;
|
142 |
}
|
143 |
|
144 |
+
.pdf-button:hover {
|
145 |
+
background-color: #2ecc71;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
}
|
147 |
</style>
|
148 |
</head>
|
|
|
175 |
return;
|
176 |
}
|
177 |
|
|
|
178 |
simulateGeneration(question);
|
179 |
});
|
180 |
|
|
|
184 |
loader.style.display = 'block';
|
185 |
resultContainer.innerHTML = '';
|
186 |
|
|
|
187 |
setTimeout(() => {
|
188 |
const mockData = {
|
189 |
sujet: question,
|
|
|
231 |
<h2>Sujet : ${data.sujet}</h2>
|
232 |
<p class="prof">Prof : ${data.prof}</p>
|
233 |
<h3>Introduction</h3>
|
234 |
+
<p class="indented">${data.introduction}</p>
|
235 |
`;
|
236 |
|
237 |
data.parties.forEach((partie, index) => {
|
238 |
html += `<div class="development-block">`;
|
239 |
+
html += `<p class="indented">${partie.chapeau}</p>`;
|
240 |
partie.arguments.forEach(arg => {
|
241 |
+
html += `<p class="indented">${arg.paragraphe_argumentatif}</p>`;
|
242 |
});
|
243 |
html += `</div>`;
|
244 |
|
245 |
if (partie.transition) {
|
246 |
+
html += `<p class="indented transition">${partie.transition}</p>`;
|
247 |
}
|
248 |
});
|
249 |
|
250 |
html += `
|
251 |
<h3>Conclusion</h3>
|
252 |
+
<p class="indented">${data.conclusion}</p>
|
253 |
+
</div>
|
254 |
+
<div class="pdf-button-container">
|
255 |
+
<button class="pdf-button" id="download-pdf">Télécharger en PDF</button>
|
256 |
</div>
|
257 |
`;
|
258 |
|
259 |
resultContainer.innerHTML = html;
|
260 |
|
261 |
+
// Stocker les données pour le PDF
|
262 |
+
window.currentDissertation = data;
|
263 |
document.getElementById('download-pdf').addEventListener('click', generatePDF);
|
264 |
}
|
265 |
|
266 |
function generatePDF() {
|
267 |
+
const { jsPDF } = window.jspdf;
|
268 |
+
const doc = new jsPDF();
|
269 |
|
270 |
+
const data = window.currentDissertation;
|
271 |
+
let yPosition = 20;
|
272 |
+
const lineHeight = 7;
|
273 |
+
const maxWidth = 180;
|
274 |
+
const margin = 15;
|
275 |
+
|
276 |
+
// Configuration des polices et styles
|
277 |
+
doc.setFont("times", "normal");
|
278 |
+
doc.setFontSize(12);
|
279 |
+
|
280 |
+
// Fonction pour ajouter du texte avec retour à la ligne automatique
|
281 |
+
function addText(text, x, y, fontSize = 12, style = "normal") {
|
282 |
+
doc.setFontSize(fontSize);
|
283 |
+
doc.setFont("times", style);
|
284 |
+
|
285 |
+
const splitText = doc.splitTextToSize(text, maxWidth);
|
286 |
+
doc.text(splitText, x, y);
|
287 |
+
return y + (splitText.length * lineHeight);
|
288 |
+
}
|
289 |
+
|
290 |
+
// Fonction pour centrer du texte
|
291 |
+
function addCenteredText(text, y, fontSize = 12, style = "normal") {
|
292 |
+
doc.setFontSize(fontSize);
|
293 |
+
doc.setFont("times", style);
|
294 |
+
const textWidth = doc.getTextWidth(text);
|
295 |
+
const x = (doc.internal.pageSize.width - textWidth) / 2;
|
296 |
+
doc.text(text, x, y);
|
297 |
+
return y + lineHeight;
|
298 |
+
}
|
299 |
+
|
300 |
+
// Titre
|
301 |
+
yPosition = addCenteredText(`Sujet : ${data.sujet}`, yPosition, 16, "bold");
|
302 |
+
yPosition += 5;
|
303 |
+
yPosition = addCenteredText(`Prof : ${data.prof}`, yPosition, 10, "italic");
|
304 |
+
yPosition += 10;
|
305 |
+
|
306 |
+
// Introduction
|
307 |
+
yPosition = addText("INTRODUCTION", margin, yPosition, 14, "bold");
|
308 |
+
yPosition += 5;
|
309 |
+
yPosition = addText(` ${data.introduction}`, margin, yPosition);
|
310 |
+
yPosition += 10;
|
311 |
+
|
312 |
+
// Parties
|
313 |
+
data.parties.forEach((partie, index) => {
|
314 |
+
// Vérifier si on a besoin d'une nouvelle page
|
315 |
+
if (yPosition > 250) {
|
316 |
+
doc.addPage();
|
317 |
+
yPosition = 20;
|
318 |
}
|
|
|
319 |
|
320 |
+
// Chapeau de partie
|
321 |
+
yPosition = addText(` ${partie.chapeau}`, margin, yPosition);
|
322 |
+
yPosition += 5;
|
323 |
+
|
324 |
+
// Arguments
|
325 |
+
partie.arguments.forEach(arg => {
|
326 |
+
if (yPosition > 250) {
|
327 |
+
doc.addPage();
|
328 |
+
yPosition = 20;
|
329 |
+
}
|
330 |
+
yPosition = addText(` ${arg.paragraphe_argumentatif}`, margin, yPosition);
|
331 |
+
yPosition += 5;
|
332 |
+
});
|
333 |
+
|
334 |
+
// Transition
|
335 |
+
if (partie.transition) {
|
336 |
+
if (yPosition > 250) {
|
337 |
+
doc.addPage();
|
338 |
+
yPosition = 20;
|
339 |
+
}
|
340 |
+
yPosition = addText(` ${partie.transition}`, margin, yPosition, 12, "italic");
|
341 |
+
yPosition += 10;
|
342 |
+
}
|
343 |
+
});
|
344 |
+
|
345 |
+
// Conclusion
|
346 |
+
if (yPosition > 230) {
|
347 |
+
doc.addPage();
|
348 |
+
yPosition = 20;
|
349 |
+
}
|
350 |
+
yPosition = addText("CONCLUSION", margin, yPosition, 14, "bold");
|
351 |
+
yPosition += 5;
|
352 |
+
yPosition = addText(` ${data.conclusion}`, margin, yPosition);
|
353 |
+
|
354 |
+
// Sauvegarder le PDF
|
355 |
+
doc.save('dissertation-philosophie.pdf');
|
356 |
+
showSuccess("PDF généré avec succès !");
|
357 |
}
|
358 |
|
359 |
function showError(message) {
|
360 |
resultContainer.innerHTML = `<p class="error">${message}</p>`;
|
361 |
}
|
362 |
+
|
363 |
+
function showSuccess(message) {
|
364 |
+
const successDiv = document.createElement('div');
|
365 |
+
successDiv.className = 'success';
|
366 |
+
successDiv.textContent = message;
|
367 |
+
resultContainer.appendChild(successDiv);
|
368 |
+
|
369 |
+
setTimeout(() => {
|
370 |
+
successDiv.remove();
|
371 |
+
}, 3000);
|
372 |
+
}
|
373 |
});
|
374 |
</script>
|
375 |
|