Docfile commited on
Commit
2081e73
·
verified ·
1 Parent(s): dfc761c

Upload index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +177 -95
templates/index.html CHANGED
@@ -2,95 +2,163 @@
2
  <html lang="fr">
3
  <head>
4
  <meta charset="UTF-8">
5
- <title>Mariam AI - Section Commentaire Composé</title>
6
- <!-- Intégration de Tailwind CSS via CDN avec le plugin Typography activé -->
7
- <script src="https://cdn.tailwindcss.com?plugins=typography"></script>
8
- <!-- Intégration de Marked.js pour la conversion Markdown -->
9
- <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
10
  <style>
11
- /* Spinner personnalisé pour l'indicateur de chargement */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  .spinner {
13
  border: 4px solid rgba(0, 0, 0, 0.1);
14
  width: 3rem;
15
  height: 3rem;
16
  border-radius: 50%;
17
- border-left-color: #4f46e5;
18
  animation: spin 1s linear infinite;
19
  }
 
20
  @keyframes spin {
21
  to { transform: rotate(360deg); }
22
  }
23
- /* Optionnel : style personnalisé pour les tableaux générés en Markdown */
24
- .prose table {
25
- width: 100%;
26
- border-collapse: collapse;
27
- }
28
- .prose th,
29
- .prose td {
30
- border: 1px solid #e5e7eb; /* gris clair */
31
- padding: 0.75rem;
32
- text-align: left;
33
  }
34
- .prose th {
35
- background-color: #f3f4f6;
36
- font-weight: 600;
 
 
37
  }
38
  </style>
39
  </head>
40
- <body class="bg-gray-100">
41
- <div class="max-w-3xl mx-auto p-4">
42
- <!-- En-tête de l'application -->
43
- <header class="mb-8 text-center">
44
- <h1 class="text-4xl font-extrabold text-gray-800">Mariam AI</h1>
45
- <p class="text-xl text-gray-600">Section Commentaire Composé</p>
46
  </header>
47
 
48
- <div class="bg-white rounded-lg shadow-lg p-6">
49
- <!-- Formulaire d'upload et prévisualisation -->
50
- <form id="uploadForm" enctype="multipart/form-data" class="mb-6">
51
- <label for="imageInput" class="block text-lg font-medium text-gray-700 mb-2">
52
- Sélectionnez une image :
53
- </label>
54
- <input type="file" name="image" id="imageInput" accept="image/*" required
55
- class="block w-full border border-gray-300 rounded-md p-2 mb-4 focus:ring focus:ring-blue-300">
56
- <!-- Prévisualisation de l'image -->
57
- <div id="previewContainer" class="mb-4 hidden">
58
- <p class="text-gray-700 font-medium mb-2">Prévisualisation :</p>
59
- <img id="previewImage" src="#" alt="Prévisualisation" class="w-full max-h-64 object-contain rounded-lg shadow-md">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  </div>
61
- <button type="submit" class="w-full bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded transition-colors">
62
- Analyser
 
63
  </button>
64
  </form>
65
 
66
  <!-- Indicateur de chargement -->
67
- <div id="loading" class="flex flex-col items-center space-y-2 mb-6 hidden">
68
- <div class="spinner"></div>
69
- <span class="text-gray-700 font-medium">Analyse en cours...</span>
 
 
 
 
70
  </div>
71
 
72
- <!-- Bouton pour afficher/masquer le tableau d'analyse -->
73
- <button id="toggleButton" class="hidden bg-green-600 hover:bg-green-700 text-white font-bold py-2 px-4 rounded w-full mb-4 transition-colors">
74
- Afficher le Tableau
75
- </button>
76
-
77
- <!-- Zone de résultats -->
78
- <div id="result" class="hidden">
79
- <!-- Section Dissertation -->
80
- <section class="mb-8">
81
- <h2 class="text-2xl font-semibold text-gray-800 mb-4">Dissertation</h2>
82
- <div id="dissertationContent" class="prose prose-sm sm:prose lg:prose-xl bg-gray-50 border border-gray-200 rounded p-6 text-gray-800"></div>
83
- </section>
84
- <!-- Section Tableau d'analyse -->
85
- <section id="tableauSection" class="hidden">
86
- <h2 class="text-2xl font-semibold text-gray-800 mb-4">Tableau d'analyse</h2>
87
- <div id="tableauContent" class="prose prose-sm sm:prose lg:prose-xl bg-gray-50 border border-gray-200 rounded p-6 text-gray-800"></div>
88
- </section>
 
 
89
  </div>
90
  </div>
91
  </div>
92
 
93
- <!-- Script JavaScript pour la gestion des interactions -->
94
  <script>
95
  const uploadForm = document.getElementById('uploadForm');
96
  const imageInput = document.getElementById('imageInput');
@@ -98,12 +166,20 @@
98
  const previewImage = document.getElementById('previewImage');
99
  const loadingIndicator = document.getElementById('loading');
100
  const resultDiv = document.getElementById('result');
101
- const toggleButton = document.getElementById('toggleButton');
102
- const tableauSection = document.getElementById('tableauSection');
103
- const tableauContent = document.getElementById('tableauContent');
104
  const dissertationContent = document.getElementById('dissertationContent');
 
 
 
 
 
 
 
 
 
105
 
106
- // Prévisualisation de l'image sélectionnée
107
  imageInput.addEventListener('change', function() {
108
  const file = this.files[0];
109
  if (file) {
@@ -118,16 +194,27 @@
118
  }
119
  });
120
 
121
- // Gestion de la soumission du formulaire
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  uploadForm.addEventListener('submit', function(e) {
123
  e.preventDefault();
124
-
125
- // Afficher l'indicateur de chargement et masquer les zones de résultats
126
  loadingIndicator.classList.remove('hidden');
127
  resultDiv.classList.add('hidden');
128
- toggleButton.classList.add('hidden');
129
- tableauSection.classList.add('hidden');
130
-
131
  const formData = new FormData(uploadForm);
132
 
133
  fetch('/analyze', {
@@ -138,37 +225,32 @@
138
  .then(data => {
139
  loadingIndicator.classList.add('hidden');
140
  if (data.error) {
141
- alert("Erreur : " + data.error);
142
- } else {
143
- // Convertir les réponses Markdown en HTML via Marked.js
144
- dissertationContent.innerHTML = marked.parse(data.dissertation);
145
- tableauContent.innerHTML = marked.parse(data.tableau);
146
-
147
- // Afficher la zone de résultats et le bouton Toggle
148
- resultDiv.classList.remove('hidden');
149
- toggleButton.classList.remove('hidden');
150
- // Masquer le tableau par défaut
151
- tableauSection.classList.add('hidden');
152
- toggleButton.textContent = 'Afficher le Tableau';
153
  }
 
 
 
 
 
 
 
 
 
 
154
  })
155
  .catch(error => {
156
  loadingIndicator.classList.add('hidden');
157
- console.error(error);
158
- alert("Une erreur est survenue lors de l'analyse.");
159
  });
160
  });
161
 
162
- // Gestion du bouton d'affichage/masquage du tableau
163
- toggleButton.addEventListener('click', function() {
164
- if (tableauSection.classList.contains('hidden')) {
165
- tableauSection.classList.remove('hidden');
166
- toggleButton.textContent = 'Masquer le Tableau';
167
- } else {
168
- tableauSection.classList.add('hidden');
169
- toggleButton.textContent = 'Afficher le Tableau';
170
- }
171
  });
172
  </script>
173
  </body>
174
- </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>Mariam AI - Analyse Littéraire</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/marked/9.1.6/marked.min.js"></script>
 
9
  <style>
10
+ @import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;700&family=Inter:wght@300;400;500;600;700&display=swap');
11
+
12
+ .custom-prose h1, .custom-prose h2, .custom-prose h3 {
13
+ font-family: 'Playfair Display', serif;
14
+ margin-top: 2em;
15
+ margin-bottom: 1em;
16
+ line-height: 1.3;
17
+ }
18
+
19
+ .custom-prose p {
20
+ margin-bottom: 1.5em;
21
+ line-height: 1.8;
22
+ }
23
+
24
+ .custom-prose ul, .custom-prose ol {
25
+ margin-top: 1em;
26
+ margin-bottom: 1em;
27
+ padding-left: 1.5em;
28
+ }
29
+
30
+ .custom-prose li {
31
+ margin-bottom: 0.5em;
32
+ }
33
+
34
+ .markdown-table table {
35
+ width: 100%;
36
+ border-collapse: separate;
37
+ border-spacing: 0;
38
+ margin: 2em 0;
39
+ background: white;
40
+ box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
41
+ }
42
+
43
+ .markdown-table th {
44
+ background: #1a365d;
45
+ color: white;
46
+ font-weight: 600;
47
+ padding: 1rem;
48
+ text-align: left;
49
+ }
50
+
51
+ .markdown-table td {
52
+ padding: 1rem;
53
+ border-bottom: 1px solid #e2e8f0;
54
+ }
55
+
56
+ .markdown-table tr:hover {
57
+ background: #f8fafc;
58
+ }
59
+
60
  .spinner {
61
  border: 4px solid rgba(0, 0, 0, 0.1);
62
  width: 3rem;
63
  height: 3rem;
64
  border-radius: 50%;
65
+ border-left-color: #1a365d;
66
  animation: spin 1s linear infinite;
67
  }
68
+
69
  @keyframes spin {
70
  to { transform: rotate(360deg); }
71
  }
72
+
73
+ .fade-enter {
74
+ opacity: 0;
75
+ transform: translateY(20px);
 
 
 
 
 
 
76
  }
77
+
78
+ .fade-enter-active {
79
+ opacity: 1;
80
+ transform: translateY(0);
81
+ transition: opacity 300ms, transform 300ms;
82
  }
83
  </style>
84
  </head>
85
+ <body class="bg-gradient-to-br from-gray-50 to-gray-100 min-h-screen font-['Inter']">
86
+ <div class="max-w-4xl mx-auto p-6">
87
+ <!-- En-tête -->
88
+ <header class="text-center mb-12">
89
+ <h1 class="font-['Playfair_Display'] text-5xl font-bold text-gray-900 mb-4">Mariam AI</h1>
90
+ <p class="text-xl text-gray-600">Assistant d'Analyse Littéraire</p>
91
  </header>
92
 
93
+ <div class="bg-white rounded-xl shadow-lg p-8">
94
+ <!-- Zone de téléchargement -->
95
+ <form id="uploadForm" class="space-y-6">
96
+ <div class="relative">
97
+ <label for="imageInput" class="block text-lg font-medium text-gray-700 mb-3">
98
+ Sélectionnez votre document
99
+ </label>
100
+ <div class="mt-2 flex justify-center px-6 pt-5 pb-6 border-2 border-gray-300 border-dashed rounded-lg hover:border-blue-500 transition-colors cursor-pointer">
101
+ <div class="space-y-2 text-center">
102
+ <svg class="mx-auto h-12 w-12 text-gray-400" stroke="currentColor" fill="none" viewBox="0 0 48 48" aria-hidden="true">
103
+ <path d="M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4v-4m32-4l-3.172-3.172a4 4 0 00-5.656 0L28 28M8 32l9.172-9.172a4 4 0 015.656 0L28 28m0 0l4 4m4-24h8m-4-4v8m-12 4h.02" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
104
+ </svg>
105
+ <div class="text-sm text-gray-600">
106
+ <label for="imageInput" class="relative cursor-pointer bg-white rounded-md font-medium text-blue-600 hover:text-blue-500 focus-within:outline-none">
107
+ <span>Télécharger un fichier</span>
108
+ <input id="imageInput" name="image" type="file" class="sr-only" accept="image/*" required>
109
+ </label>
110
+ </div>
111
+ <p class="text-xs text-gray-500">PNG, JPG jusqu'à 10MB</p>
112
+ </div>
113
+ </div>
114
+ </div>
115
+
116
+ <!-- Prévisualisation -->
117
+ <div id="previewContainer" class="hidden">
118
+ <p class="text-gray-700 font-medium mb-3">Aperçu du document :</p>
119
+ <div class="relative rounded-lg overflow-hidden bg-gray-100">
120
+ <img id="previewImage" src="#" alt="Aperçu" class="w-full max-h-80 object-contain">
121
+ </div>
122
  </div>
123
+
124
+ <button type="submit" class="w-full bg-blue-600 text-white rounded-lg px-4 py-3 font-semibold hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors">
125
+ Lancer l'analyse
126
  </button>
127
  </form>
128
 
129
  <!-- Indicateur de chargement -->
130
+ <div id="loading" class="hidden">
131
+ <div class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
132
+ <div class="bg-white p-6 rounded-lg shadow-xl text-center">
133
+ <div class="spinner mx-auto mb-4"></div>
134
+ <p class="text-gray-700 font-medium">Analyse en cours...</p>
135
+ </div>
136
+ </div>
137
  </div>
138
 
139
+ <!-- Résultats -->
140
+ <div id="result" class="hidden mt-8 space-y-8">
141
+ <!-- Navigation -->
142
+ <div class="flex space-x-4 border-b border-gray-200">
143
+ <button id="dissertationTab" class="px-4 py-2 text-sm font-medium text-blue-600 border-b-2 border-blue-600">
144
+ Dissertation
145
+ </button>
146
+ <button id="tableauTab" class="px-4 py-2 text-sm font-medium text-gray-500 hover:text-gray-700">
147
+ Tableau d'analyse
148
+ </button>
149
+ </div>
150
+
151
+ <!-- Contenu Dissertation -->
152
+ <div id="dissertationContent" class="custom-prose prose prose-lg max-w-none">
153
+ </div>
154
+
155
+ <!-- Contenu Tableau -->
156
+ <div id="tableauContent" class="hidden markdown-table prose prose-lg max-w-none">
157
+ </div>
158
  </div>
159
  </div>
160
  </div>
161
 
 
162
  <script>
163
  const uploadForm = document.getElementById('uploadForm');
164
  const imageInput = document.getElementById('imageInput');
 
166
  const previewImage = document.getElementById('previewImage');
167
  const loadingIndicator = document.getElementById('loading');
168
  const resultDiv = document.getElementById('result');
169
+ const dissertationTab = document.getElementById('dissertationTab');
170
+ const tableauTab = document.getElementById('tableauTab');
 
171
  const dissertationContent = document.getElementById('dissertationContent');
172
+ const tableauContent = document.getElementById('tableauContent');
173
+
174
+ // Configuration de marked pour le rendu Markdown
175
+ marked.setOptions({
176
+ breaks: true,
177
+ gfm: true,
178
+ headerIds: true,
179
+ langPrefix: 'language-',
180
+ });
181
 
182
+ // Prévisualisation
183
  imageInput.addEventListener('change', function() {
184
  const file = this.files[0];
185
  if (file) {
 
194
  }
195
  });
196
 
197
+ // Gestion des onglets
198
+ dissertationTab.addEventListener('click', function() {
199
+ dissertationTab.classList.add('text-blue-600', 'border-b-2', 'border-blue-600');
200
+ tableauTab.classList.remove('text-blue-600', 'border-b-2', 'border-blue-600');
201
+ dissertationContent.classList.remove('hidden');
202
+ tableauContent.classList.add('hidden');
203
+ });
204
+
205
+ tableauTab.addEventListener('click', function() {
206
+ tableauTab.classList.add('text-blue-600', 'border-b-2', 'border-blue-600');
207
+ dissertationTab.classList.remove('text-blue-600', 'border-b-2', 'border-blue-600');
208
+ tableauContent.classList.remove('hidden');
209
+ dissertationContent.classList.add('hidden');
210
+ });
211
+
212
+ // Soumission du formulaire
213
  uploadForm.addEventListener('submit', function(e) {
214
  e.preventDefault();
 
 
215
  loadingIndicator.classList.remove('hidden');
216
  resultDiv.classList.add('hidden');
217
+
 
 
218
  const formData = new FormData(uploadForm);
219
 
220
  fetch('/analyze', {
 
225
  .then(data => {
226
  loadingIndicator.classList.add('hidden');
227
  if (data.error) {
228
+ throw new Error(data.error);
 
 
 
 
 
 
 
 
 
 
 
229
  }
230
+
231
+ dissertationContent.innerHTML = marked.parse(data.dissertation);
232
+ tableauContent.innerHTML = marked.parse(data.tableau);
233
+
234
+ resultDiv.classList.remove('hidden');
235
+ // Afficher l'onglet dissertation par défaut
236
+ dissertationTab.click();
237
+
238
+ // Scroll vers les résultats
239
+ resultDiv.scrollIntoView({ behavior: 'smooth' });
240
  })
241
  .catch(error => {
242
  loadingIndicator.classList.add('hidden');
243
+ alert("Une erreur est survenue : " + error.message);
 
244
  });
245
  });
246
 
247
+ // Animation douce pour les transitions
248
+ document.querySelectorAll('.fade-enter').forEach(element => {
249
+ element.classList.add('fade-enter-active');
250
+ setTimeout(() => {
251
+ element.classList.remove('fade-enter', 'fade-enter-active');
252
+ }, 300);
 
 
 
253
  });
254
  </script>
255
  </body>
256
+ </html>