Spaces:
Sleeping
Sleeping
File size: 11,801 Bytes
a3f3ee1 c34b565 725f8a8 14fc873 b9cd811 5064228 a3f3ee1 87e553e 14fc873 87e553e 14fc873 a3f3ee1 87e553e 14fc873 5064228 a3f3ee1 64ff4b2 a3f3ee1 564705b a3f3ee1 564705b a3f3ee1 564705b c34b565 5064228 564705b a3f3ee1 5064228 564705b 5064228 a3f3ee1 64ff4b2 564705b 3ce173a a3f3ee1 5064228 564705b 5064228 a3f3ee1 564705b a3f3ee1 564705b a3f3ee1 3ce173a 564705b 3ce173a 564705b 3ce173a 564705b a3f3ee1 5064228 564705b 5064228 a3f3ee1 5064228 a3f3ee1 564705b a3f3ee1 564705b a3f3ee1 564705b 5064228 564705b a3f3ee1 5064228 a3f3ee1 5064228 564705b a3f3ee1 64ff4b2 564705b 5064228 64ff4b2 564705b a3f3ee1 5064228 564705b a3f3ee1 5064228 564705b a3f3ee1 564705b 5064228 64ff4b2 a3f3ee1 64ff4b2 a3f3ee1 64ff4b2 564705b a3f3ee1 564705b a3f3ee1 564705b a3f3ee1 5064228 a3f3ee1 64ff4b2 564705b c34b565 564705b be583ae 3f851f5 14fc873 a3f3ee1 564705b a3f3ee1 564705b d979f73 564705b a3f3ee1 564705b fc4bc7e 564705b a3f3ee1 564705b a3f3ee1 564705b 64ff4b2 a3f3ee1 564705b 14fc873 a3f3ee1 5064228 a3f3ee1 5064228 14fc873 fc4bc7e 14fc873 5064228 14fc873 fc4bc7e a3f3ee1 14fc873 5064228 564705b 87e553e 14fc873 3ce173a fc4bc7e a3f3ee1 fc4bc7e 14fc873 64ff4b2 a3f3ee1 64ff4b2 5064228 14fc873 5064228 14fc873 5064228 14fc873 3ce173a fc4bc7e a3f3ee1 3ce173a 87e553e 5064228 564705b 5064228 a3f3ee1 5064228 d865223 14fc873 64ff4b2 d865223 64ff4b2 14fc873 64ff4b2 14fc873 64ff4b2 564705b 64ff4b2 14fc873 64ff4b2 5064228 64ff4b2 a3f3ee1 64ff4b2 87e553e 64ff4b2 d083d33 a3f3ee1 5064228 a3f3ee1 5064228 14fc873 3f851f5 |
1 2 3 4 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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 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 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 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 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 |
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Assistant de Philosophie (Vue.js)</title>
<script src="https://unpkg.com/vue@3/dist/vue.global.prod.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Kalam&family=Lato:wght@400;700&display=swap" rel="stylesheet">
<style>
:root {
--primary-color: #4f46e5; /* Indigo */
--primary-hover: #4338ca;
--text-color: #374151; /* Gris foncé */
--background-color: #f8f9fa;
--border-color: #e5e7eb;
}
body {
font-family: 'Lato', sans-serif;
background-color: var(--background-color);
margin: 0;
padding: 2rem;
color: var(--text-color);
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.container {
max-width: 960px;
margin: 0 auto;
/* Suppression du style "frame": background, padding, border-radius, box-shadow */
}
h1 {
text-align: center;
color: #111827;
margin-bottom: 0.5em;
}
.type-indicator {
text-align: center;
color: #6b7280;
font-size: 1.1em;
margin-bottom: 2em;
font-weight: bold;
}
.form-group {
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 8px;
font-weight: 700;
color: #4b5563;
}
textarea, .form-select {
width: 100%;
padding: 15px;
border-radius: 8px;
border: 1px solid var(--border-color);
min-height: 58px;
font-size: 16px;
line-height: 1.6;
transition: border-color 0.3s, box-shadow 0.3s;
background-color: #fff;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
box-sizing: border-box;
}
.form-select {
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
background-position: right 0.75rem center;
background-repeat: no-repeat;
background-size: 1.5em 1.5em;
padding-right: 2.5rem;
}
textarea {
min-height: 100px;
}
textarea:focus, .form-select:focus {
outline: none;
border-color: var(--primary-color);
box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}
button {
display: block;
box-sizing: border-box;
width: 100%;
padding: 16px;
background-color: var(--primary-color);
color: white;
border: none;
border-radius: 8px;
font-size: 18px;
font-weight: 700;
cursor: pointer;
transition: background-color 0.3s, transform 0.2s;
}
button:hover:not(:disabled) {
background-color: var(--primary-hover);
transform: translateY(-2px);
}
button:disabled {
background-color: #9ca3af;
cursor: not-allowed;
}
.download-container {
margin-top: 15px;
}
.secondary-button {
background-color: #f3f4f6;
color: #374151;
border: 1px solid #d1d5db;
}
.secondary-button:hover:not(:disabled) {
background-color: #e5e7eb;
border-color: #9ca3af;
}
.loader {
display: block;
border: 8px solid #f3f3f3;
border-top: 8px solid var(--primary-color);
border-radius: 50%;
width: 50px;
height: 50px;
animation: spin 1s linear infinite;
margin: 30px auto;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.error {
color: #ef4444;
background-color: #fee2e2;
text-align: center;
margin-top: 20px;
padding: 15px;
border-radius: 8px;
font-weight: bold;
}
/* Styles de la feuille de dissertation */
.dissertation-paper {
font-family: 'Kalam', cursive;
font-size: 20px;
color: #1a2a4c;
background-color: #fdfaf4;
line-height: 2;
background-image: linear-gradient(transparent 97%, #d8e2ee 98%);
background-size: 100% 40px;
border-left: 3px solid #ffaaab;
padding-left: 4em;
margin: 40px 0 0; /* Ajustement pour le design plat */
padding-top: 30px;
padding-bottom: 40px;
padding-right: 30px;
-webkit-print-color-adjust: exact;
print-color-adjust: exact;
}
.dissertation-paper h2 { font-size: 1.5em; text-align: center; margin-bottom: 1.5em; }
.dissertation-paper h3 { font-size: 1.2em; margin-top: 3em; margin-bottom: 1.5em; text-transform: uppercase; text-decoration: underline; }
.dissertation-paper .development-block { margin-top: 3em; }
.dissertation-paper p { text-align: justify; margin: 0; padding: 0; }
.dissertation-paper .prof { text-align: center; font-style: italic; margin-bottom: 2em; }
.dissertation-paper .indented { text-indent: 3em; }
.dissertation-paper .transition { margin-top: 2em; margin-bottom: 2em; font-style: italic; color: #4a6a9c; }
.dissertation-paper, .dissertation-paper * { box-sizing: border-box; }
.avoid-page-break { page-break-inside: avoid; break-inside: avoid; }
</style>
</head>
<body>
<div id="app" class="container">
<h1>Assistant de Dissertation Philosophique</h1>
<p class="type-indicator">Méthodologie : [[ dissertationTypeLabel ]]</p>
<form @submit.prevent="generateDissertation">
<div class="form-group">
<label for="dissertation-type">Choisir la méthodologie</label>
<select id="dissertation-type" v-model="dissertationType" class="form-select">
<option value="type1">Type 1 </option>
<option value="type2">Type 2 (citation)</option>
</select>
</div>
<div class="form-group">
<label for="course-context">Choisir un cours comme contexte (optionnel)</label>
<select id="course-context" v-model="selectedCourse" class="form-select">
<option value="">-- Aucun cours en contexte --</option>
<option v-for="course in courses" :key="course.id" :value="course.id">
[[ course.title ]]
</option>
</select>
</div>
<div class="form-group">
<label for="question">Entrez votre sujet de dissertation</label>
<textarea id="question" v-model="question" placeholder="Entrez votre sujet ou la citation à analyser ici..."></textarea>
</div>
<button type="submit" :disabled="isLoading">
[[ isLoading ? 'Génération en cours...' : 'Générer la dissertation' ]]
</button>
</form>
<div v-if="dissertation" class="download-container" data-html2canvas-ignore="true">
<button class="secondary-button" @click="generatePDF">Télécharger la dissertation en PDF</button>
</div>
<div v-if="isLoading" class="loader"></div>
<p v-if="errorMessage" class="error">[[ errorMessage ]]</p>
<div v-if="dissertation" id="dissertation-content" class="dissertation-paper">
<h2>Sujet : [[ dissertation.sujet ]]</h2>
<p class="prof">Prof : [[ dissertation.prof ]]</p>
<h3>Introduction</h3>
<p class="indented">[[ dissertation.introduction ]]</p>
<div v-for="partie in dissertation.parties" :key="partie.chapeau" class="avoid-page-break">
<div class="development-block">
<p class="indented">[[ partie.chapeau ]]</p>
<p v-for="(arg, idx) in partie.arguments" :key="idx" class="indented">
[[ arg.paragraphe_argumentatif ]]
</p>
</div>
<p v-if="partie.transition" class="indented transition">[[ partie.transition ]]</p>
</div>
<h3>Conclusion</h3>
<p class="indented">[[ dissertation.conclusion ]]</p>
</div>
</div>
<script>
const { createApp } = Vue;
const app = createApp({
data() {
return {
question: '',
dissertationType: 'type1',
courses: [], // Pour stocker la liste des cours
selectedCourse: '', // Pour stocker l'ID du cours sélectionné
isLoading: false,
errorMessage: null,
dissertation: null
}
},
computed: {
dissertationTypeLabel() {
return this.dissertationType === 'type1' ? 'Type 1' : 'Type 2';
}
},
mounted() {
// Au chargement du composant, on récupère la liste des cours
this.fetchCourses();
},
methods: {
async fetchCourses() {
try {
const response = await fetch('/api/philosophy/courses');
if (!response.ok) throw new Error('Impossible de charger les cours. Vérifiez la connexion à la base de données.');
const data = await response.json();
if (data.error) throw new Error(data.error);
this.courses = data;
} catch (error) {
this.errorMessage = error.message;
console.error("Erreur de chargement des cours:", error);
}
},
async generateDissertation() {
if (!this.question.trim()) {
this.errorMessage = "Veuillez entrer un sujet de dissertation.";
return;
}
this.isLoading = true;
this.errorMessage = null;
this.dissertation = null;
try {
const response = await fetch('/api/generate_dissertation', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
question: this.question,
type: this.dissertationType,
courseId: this.selectedCourse // On envoie l'ID du cours sélectionné
})
});
const data = await response.json();
if (!response.ok) {
throw new Error(data.error || "Une erreur inconnue est survenue.");
}
this.dissertation = data;
} catch (error) {
this.errorMessage = error.message;
} finally {
this.isLoading = false;
}
},
async generatePDF() {
const element = document.getElementById('dissertation-content');
if (!element) {
this.errorMessage = "Contenu introuvable pour le PDF.";
return;
}
try {
if (document.fonts && document.fonts.ready) {
await document.fonts.ready;
}
window.scrollTo(0, 0);
const options = {
margin: [15, 15, 15, 15],
filename: 'dissertation-philosophie.pdf',
image: { type: 'jpeg', quality: 0.98 },
html2canvas: {
scale: 2,
useCORS: true,
logging: true,
backgroundColor: null,
},
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' }
};
await html2pdf().set(options).from(element).save();
} catch (err) {
console.error('Erreur html2pdf:', err);
this.errorMessage = "Erreur lors de la génération du PDF. Voir la console pour les détails.";
}
}
}
});
// ⚠️ Changer les délimiteurs pour éviter le conflit avec Jinja2
app.config.compilerOptions.delimiters = ['[[', ']]'];
app.mount('#app');
</script>
</body>
</html> |