Update templates/index.html
Browse files- templates/index.html +454 -201
templates/index.html
CHANGED
|
@@ -3,234 +3,487 @@
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>
|
| 7 |
-
<!-- Tailwind CSS via CDN -->
|
| 8 |
-
<script src="https://cdn.tailwindcss.com"></script>
|
| 9 |
<style>
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
}
|
| 13 |
</style>
|
| 14 |
</head>
|
| 15 |
-
<body
|
| 16 |
-
<div class="container
|
| 17 |
-
<
|
| 18 |
-
<h1
|
| 19 |
-
<p
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
<
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
<ul class="text-sm mt-1 space-y-1">
|
| 39 |
-
<li>• Quelles sont les principales caractéristiques de la langue Fang?</li>
|
| 40 |
-
<li>• Expliquez la structure verbale en Fang</li>
|
| 41 |
-
<li>• Que dit le document sur la phonologie du Fang?</li>
|
| 42 |
-
</ul>
|
| 43 |
-
</div>
|
| 44 |
</div>
|
| 45 |
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
<div
|
| 49 |
-
<
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
rows="2"
|
| 54 |
-
></textarea>
|
| 55 |
-
<button
|
| 56 |
-
id="send-button"
|
| 57 |
-
class="bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 px-4 rounded-lg"
|
| 58 |
-
>
|
| 59 |
-
Envoyer
|
| 60 |
-
</button>
|
| 61 |
</div>
|
| 62 |
-
<button
|
| 63 |
-
id="reset-button"
|
| 64 |
-
class="bg-gray-300 hover:bg-gray-400 text-gray-800 font-bold py-2 px-4 rounded-lg self-end"
|
| 65 |
-
>
|
| 66 |
-
Nouvelle Conversation
|
| 67 |
-
</button>
|
| 68 |
</div>
|
| 69 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
</div>
|
| 71 |
|
| 72 |
<script>
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
|
|
|
| 81 |
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
messageDiv.className = `my-2 p-3 rounded-lg ${role === 'user' ? 'bg-blue-100 ml-12' : 'bg-gray-100 mr-12'}`;
|
| 86 |
-
|
| 87 |
-
const header = document.createElement('div');
|
| 88 |
-
header.className = 'font-bold text-sm';
|
| 89 |
-
header.textContent = role === 'user' ? 'Vous' : 'Gemini';
|
| 90 |
-
|
| 91 |
-
const timeSpan = document.createElement('span');
|
| 92 |
-
timeSpan.className = 'text-xs text-gray-500 ml-2';
|
| 93 |
-
timeSpan.textContent = timestamp;
|
| 94 |
-
header.appendChild(timeSpan);
|
| 95 |
-
|
| 96 |
-
const contentDiv = document.createElement('div');
|
| 97 |
-
contentDiv.className = 'whitespace-pre-wrap';
|
| 98 |
-
contentDiv.textContent = content;
|
| 99 |
-
|
| 100 |
-
messageDiv.appendChild(header);
|
| 101 |
-
messageDiv.appendChild(contentDiv);
|
| 102 |
-
chatHistory.appendChild(messageDiv);
|
| 103 |
-
|
| 104 |
-
// Scroll to bottom
|
| 105 |
-
chatHistory.scrollTop = chatHistory.scrollHeight;
|
| 106 |
}
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
|
|
|
|
|
|
| 112 |
}
|
| 113 |
-
|
| 114 |
-
//
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
const loadingDiv = document.createElement('div');
|
| 120 |
-
loadingDiv.id = 'loading-indicator';
|
| 121 |
-
loadingDiv.className = 'my-2 p-3 bg-gray-100 rounded-lg mr-12 flex items-center';
|
| 122 |
-
loadingDiv.innerHTML = `
|
| 123 |
-
<div class="font-bold text-sm">Gemini</div>
|
| 124 |
-
<div class="ml-2">
|
| 125 |
-
<span class="inline-block w-2 h-2 bg-gray-500 rounded-full animate-bounce"></span>
|
| 126 |
-
<span class="inline-block w-2 h-2 bg-gray-500 rounded-full animate-bounce" style="animation-delay: 0.2s"></span>
|
| 127 |
-
<span class="inline-block w-2 h-2 bg-gray-500 rounded-full animate-bounce" style="animation-delay: 0.4s"></span>
|
| 128 |
-
</div>
|
| 129 |
-
`;
|
| 130 |
-
chatHistory.appendChild(loadingDiv);
|
| 131 |
-
chatHistory.scrollTop = chatHistory.scrollHeight;
|
| 132 |
}
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
}
|
| 141 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
}
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
// Remplacer le contenu initial si c'est le premier message
|
| 150 |
-
if (chatHistory.querySelector('.text-gray-400')) {
|
| 151 |
-
chatHistory.innerHTML = '';
|
| 152 |
-
}
|
| 153 |
-
|
| 154 |
-
// Vider l'input et ajouter le message de l'utilisateur
|
| 155 |
-
userInput.value = '';
|
| 156 |
-
addMessage('user', message);
|
| 157 |
-
|
| 158 |
-
// Afficher l'indicateur de chargement
|
| 159 |
-
showLoading();
|
| 160 |
-
|
| 161 |
-
try {
|
| 162 |
-
// Envoyer la requête au serveur
|
| 163 |
-
const response = await fetch('/chat', {
|
| 164 |
-
method: 'POST',
|
| 165 |
-
headers: {
|
| 166 |
-
'Content-Type': 'application/json',
|
| 167 |
-
},
|
| 168 |
-
body: JSON.stringify({ message }),
|
| 169 |
-
});
|
| 170 |
-
|
| 171 |
-
if (!response.ok) {
|
| 172 |
-
throw new Error('Erreur de communication avec le serveur');
|
| 173 |
-
}
|
| 174 |
-
|
| 175 |
-
const data = await response.json();
|
| 176 |
-
|
| 177 |
-
// Masquer l'indicateur de chargement
|
| 178 |
-
hideLoading();
|
| 179 |
-
|
| 180 |
-
// Afficher la réponse
|
| 181 |
-
addMessage('model', data.response);
|
| 182 |
-
|
| 183 |
-
} catch (error) {
|
| 184 |
-
// Masquer l'indicateur de chargement
|
| 185 |
-
hideLoading();
|
| 186 |
-
|
| 187 |
-
// Afficher l'erreur
|
| 188 |
-
addMessage('system', `Erreur: ${error.message}`);
|
| 189 |
-
console.error('Erreur:', error);
|
| 190 |
-
}
|
| 191 |
}
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
|
|
|
| 195 |
try {
|
| 196 |
-
const response = await fetch(
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 202 |
}
|
| 203 |
-
|
| 204 |
-
// Vider l'historique
|
| 205 |
-
chatHistory.innerHTML = `
|
| 206 |
-
<div class="text-center text-gray-400 my-4">
|
| 207 |
-
<p>Posez des questions sur le document PDF de la langue Fang.</p>
|
| 208 |
-
<p class="mt-2 text-sm">Exemples de questions:</p>
|
| 209 |
-
<ul class="text-sm mt-1 space-y-1">
|
| 210 |
-
<li>• Quelles sont les principales caractéristiques de la langue Fang?</li>
|
| 211 |
-
<li>• Expliquez la structure verbale en Fang</li>
|
| 212 |
-
<li>• Que dit le document sur la phonologie du Fang?</li>
|
| 213 |
-
</ul>
|
| 214 |
-
</div>
|
| 215 |
-
`;
|
| 216 |
-
|
| 217 |
} catch (error) {
|
| 218 |
-
console.error('Erreur
|
| 219 |
-
alert('Impossible de réinitialiser la conversation. Veuillez réessayer.');
|
| 220 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 221 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 222 |
|
| 223 |
-
|
| 224 |
-
sendButton.addEventListener('click', sendMessage);
|
| 225 |
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
|
|
|
| 230 |
}
|
| 231 |
-
});
|
| 232 |
-
|
| 233 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 234 |
});
|
| 235 |
</script>
|
| 236 |
</body>
|
|
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Générateur de Manga BD</title>
|
|
|
|
|
|
|
| 7 |
<style>
|
| 8 |
+
* {
|
| 9 |
+
margin: 0;
|
| 10 |
+
padding: 0;
|
| 11 |
+
box-sizing: border-box;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
body {
|
| 15 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 16 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 17 |
+
min-height: 100vh;
|
| 18 |
+
color: #333;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
.container {
|
| 22 |
+
max-width: 1200px;
|
| 23 |
+
margin: 0 auto;
|
| 24 |
+
padding: 20px;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
.header {
|
| 28 |
+
text-align: center;
|
| 29 |
+
margin-bottom: 40px;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
.header h1 {
|
| 33 |
+
color: white;
|
| 34 |
+
font-size: 3em;
|
| 35 |
+
margin-bottom: 10px;
|
| 36 |
+
text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
.header p {
|
| 40 |
+
color: rgba(255,255,255,0.9);
|
| 41 |
+
font-size: 1.2em;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
.main-content {
|
| 45 |
+
display: grid;
|
| 46 |
+
grid-template-columns: 1fr 1fr;
|
| 47 |
+
gap: 30px;
|
| 48 |
+
margin-bottom: 30px;
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
.input-section, .status-section {
|
| 52 |
+
background: rgba(255, 255, 255, 0.95);
|
| 53 |
+
padding: 30px;
|
| 54 |
+
border-radius: 15px;
|
| 55 |
+
box-shadow: 0 10px 30px rgba(0,0,0,0.2);
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
.input-section h2, .status-section h2 {
|
| 59 |
+
color: #4a5568;
|
| 60 |
+
margin-bottom: 20px;
|
| 61 |
+
border-bottom: 3px solid #667eea;
|
| 62 |
+
padding-bottom: 10px;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
.json-input {
|
| 66 |
+
width: 100%;
|
| 67 |
+
height: 400px;
|
| 68 |
+
padding: 15px;
|
| 69 |
+
border: 2px solid #e2e8f0;
|
| 70 |
+
border-radius: 10px;
|
| 71 |
+
font-family: 'Courier New', monospace;
|
| 72 |
+
font-size: 14px;
|
| 73 |
+
line-height: 1.5;
|
| 74 |
+
resize: vertical;
|
| 75 |
+
background: #f8fafc;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
.json-input:focus {
|
| 79 |
+
outline: none;
|
| 80 |
+
border-color: #667eea;
|
| 81 |
+
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
.btn {
|
| 85 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 86 |
+
color: white;
|
| 87 |
+
border: none;
|
| 88 |
+
padding: 15px 30px;
|
| 89 |
+
border-radius: 10px;
|
| 90 |
+
cursor: pointer;
|
| 91 |
+
font-size: 16px;
|
| 92 |
+
font-weight: bold;
|
| 93 |
+
transition: all 0.3s ease;
|
| 94 |
+
width: 100%;
|
| 95 |
+
margin-top: 20px;
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
.btn:hover {
|
| 99 |
+
transform: translateY(-2px);
|
| 100 |
+
box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
.btn:disabled {
|
| 104 |
+
background: #a0aec0;
|
| 105 |
+
cursor: not-allowed;
|
| 106 |
+
transform: none;
|
| 107 |
+
box-shadow: none;
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
.status-card {
|
| 111 |
+
background: #f7fafc;
|
| 112 |
+
border: 2px solid #e2e8f0;
|
| 113 |
+
border-radius: 10px;
|
| 114 |
+
padding: 20px;
|
| 115 |
+
margin: 15px 0;
|
| 116 |
+
transition: all 0.3s ease;
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
.status-card.generating {
|
| 120 |
+
border-color: #f6ad55;
|
| 121 |
+
background: #fffaf0;
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
.status-card.completed {
|
| 125 |
+
border-color: #68d391;
|
| 126 |
+
background: #f0fff4;
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
.status-card.error {
|
| 130 |
+
border-color: #fc8181;
|
| 131 |
+
background: #fffafa;
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
.progress-bar {
|
| 135 |
+
background: #e2e8f0;
|
| 136 |
+
border-radius: 10px;
|
| 137 |
+
height: 20px;
|
| 138 |
+
margin: 15px 0;
|
| 139 |
+
overflow: hidden;
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
.progress-fill {
|
| 143 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 144 |
+
height: 100%;
|
| 145 |
+
transition: width 0.5s ease;
|
| 146 |
+
border-radius: 10px;
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
.download-btn {
|
| 150 |
+
background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
|
| 151 |
+
color: white;
|
| 152 |
+
border: none;
|
| 153 |
+
padding: 10px 20px;
|
| 154 |
+
border-radius: 8px;
|
| 155 |
+
cursor: pointer;
|
| 156 |
+
font-weight: bold;
|
| 157 |
+
text-decoration: none;
|
| 158 |
+
display: inline-block;
|
| 159 |
+
transition: all 0.3s ease;
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
.download-btn:hover {
|
| 163 |
+
transform: translateY(-2px);
|
| 164 |
+
box-shadow: 0 5px 15px rgba(72, 187, 120, 0.3);
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
.example-section {
|
| 168 |
+
background: rgba(255, 255, 255, 0.95);
|
| 169 |
+
padding: 30px;
|
| 170 |
+
border-radius: 15px;
|
| 171 |
+
box-shadow: 0 10px 30px rgba(0,0,0,0.2);
|
| 172 |
+
margin-top: 30px;
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
.example-json {
|
| 176 |
+
background: #2d3748;
|
| 177 |
+
color: #e2e8f0;
|
| 178 |
+
padding: 20px;
|
| 179 |
+
border-radius: 10px;
|
| 180 |
+
font-family: 'Courier New', monospace;
|
| 181 |
+
font-size: 14px;
|
| 182 |
+
line-height: 1.5;
|
| 183 |
+
overflow-x: auto;
|
| 184 |
+
white-space: pre-wrap;
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
.spinner {
|
| 188 |
+
display: inline-block;
|
| 189 |
+
width: 20px;
|
| 190 |
+
height: 20px;
|
| 191 |
+
border: 3px solid rgba(255,255,255,.3);
|
| 192 |
+
border-radius: 50%;
|
| 193 |
+
border-top-color: #fff;
|
| 194 |
+
animation: spin 1s ease-in-out infinite;
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
@keyframes spin {
|
| 198 |
+
to { transform: rotate(360deg); }
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
.alert {
|
| 202 |
+
padding: 15px;
|
| 203 |
+
border-radius: 10px;
|
| 204 |
+
margin: 15px 0;
|
| 205 |
+
font-weight: bold;
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
.alert-error {
|
| 209 |
+
background: #fed7d7;
|
| 210 |
+
color: #c53030;
|
| 211 |
+
border: 2px solid #fc8181;
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
.alert-success {
|
| 215 |
+
background: #c6f6d5;
|
| 216 |
+
color: #2f855a;
|
| 217 |
+
border: 2px solid #68d391;
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
@media (max-width: 768px) {
|
| 221 |
+
.main-content {
|
| 222 |
+
grid-template-columns: 1fr;
|
| 223 |
+
gap: 20px;
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
.header h1 {
|
| 227 |
+
font-size: 2em;
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
.json-input {
|
| 231 |
+
height: 300px;
|
| 232 |
+
}
|
| 233 |
}
|
| 234 |
</style>
|
| 235 |
</head>
|
| 236 |
+
<body>
|
| 237 |
+
<div class="container">
|
| 238 |
+
<div class="header">
|
| 239 |
+
<h1>🎨 Générateur de Manga BD</h1>
|
| 240 |
+
<p>Créez votre manga personnalisé avec l'IA Gemini</p>
|
| 241 |
+
</div>
|
| 242 |
+
|
| 243 |
+
<div class="main-content">
|
| 244 |
+
<div class="input-section">
|
| 245 |
+
<h2>📝 Configuration du Manga</h2>
|
| 246 |
+
<textarea
|
| 247 |
+
id="jsonInput"
|
| 248 |
+
class="json-input"
|
| 249 |
+
placeholder="Collez votre JSON de configuration ici...">
|
| 250 |
+
{
|
| 251 |
+
"partie-1": "Crée une page de manga style shonen avec un héros adolescent aux cheveux hérissés qui découvre ses pouvoirs magiques dans une forêt mystérieuse. Style artistique détaillé avec beaucoup d'effets visuels.",
|
| 252 |
+
"partie-2": "Suite de l'histoire: le héros rencontre un mentor sage qui lui explique l'origine de ses pouvoirs. Scène dans une clairière avec des éléments magiques flottants.",
|
| 253 |
+
"partie-3": "Combat épique contre un monstre des ombres. Le héros utilise ses nouveaux pouvoirs pour la première fois. Beaucoup d'action et d'effets spéciaux.",
|
| 254 |
+
"partie-4": "Victoire du héros et résolution. Il regarde vers l'horizon, prêt pour de nouvelles aventures. Scène inspirante avec un coucher de soleil."
|
| 255 |
+
}</textarea>
|
| 256 |
+
<button id="generateBtn" class="btn">
|
| 257 |
+
🚀 Générer le Manga
|
| 258 |
+
</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 259 |
</div>
|
| 260 |
|
| 261 |
+
<div class="status-section">
|
| 262 |
+
<h2>���� Statut de Génération</h2>
|
| 263 |
+
<div id="statusContainer">
|
| 264 |
+
<p style="color: #718096; text-align: center; padding: 40px;">
|
| 265 |
+
Aucune génération en cours.<br>
|
| 266 |
+
Collez votre configuration JSON et cliquez sur "Générer le Manga" pour commencer.
|
| 267 |
+
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 268 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 269 |
</div>
|
| 270 |
</div>
|
| 271 |
+
|
| 272 |
+
<div class="example-section">
|
| 273 |
+
<h2>📋 Format JSON Attendu</h2>
|
| 274 |
+
<p style="margin-bottom: 20px;">
|
| 275 |
+
Votre JSON doit contenir des clés nommées "partie-X" (où X est un numéro) avec des prompts détaillés pour chaque page :
|
| 276 |
+
</p>
|
| 277 |
+
<div class="example-json">{
|
| 278 |
+
"partie-1": "Prompt détaillé pour la première page de votre manga...",
|
| 279 |
+
"partie-2": "Prompt détaillé pour la deuxième page...",
|
| 280 |
+
"partie-3": "Prompt détaillé pour la troisième page...",
|
| 281 |
+
"partie-N": "Continuez avec autant de parties que nécessaire..."
|
| 282 |
+
}</div>
|
| 283 |
+
<p style="margin-top: 15px; color: #4a5568;">
|
| 284 |
+
<strong>Conseils :</strong> Soyez très descriptif dans vos prompts. Mentionnez le style artistique,
|
| 285 |
+
les personnages, l'action, l'ambiance, etc. Plus votre description est détaillée,
|
| 286 |
+
meilleur sera le résultat !
|
| 287 |
+
</p>
|
| 288 |
+
</div>
|
| 289 |
</div>
|
| 290 |
|
| 291 |
<script>
|
| 292 |
+
let currentTaskId = null;
|
| 293 |
+
let statusInterval = null;
|
| 294 |
+
|
| 295 |
+
const generateBtn = document.getElementById('generateBtn');
|
| 296 |
+
const jsonInput = document.getElementById('jsonInput');
|
| 297 |
+
const statusContainer = document.getElementById('statusContainer');
|
| 298 |
+
|
| 299 |
+
generateBtn.addEventListener('click', async () => {
|
| 300 |
+
const jsonText = jsonInput.value.trim();
|
| 301 |
|
| 302 |
+
if (!jsonText) {
|
| 303 |
+
showAlert('Veuillez saisir une configuration JSON', 'error');
|
| 304 |
+
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 305 |
}
|
| 306 |
+
|
| 307 |
+
let jsonData;
|
| 308 |
+
try {
|
| 309 |
+
jsonData = JSON.parse(jsonText);
|
| 310 |
+
} catch (error) {
|
| 311 |
+
showAlert('Format JSON invalide: ' + error.message, 'error');
|
| 312 |
+
return;
|
| 313 |
}
|
| 314 |
+
|
| 315 |
+
// Vérifier que le JSON contient des parties
|
| 316 |
+
const parts = Object.keys(jsonData).filter(key => key.startsWith('partie-'));
|
| 317 |
+
if (parts.length === 0) {
|
| 318 |
+
showAlert('Aucune partie trouvée dans le JSON. Utilisez des clés comme "partie-1", "partie-2", etc.', 'error');
|
| 319 |
+
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 320 |
}
|
| 321 |
+
|
| 322 |
+
try {
|
| 323 |
+
generateBtn.disabled = true;
|
| 324 |
+
generateBtn.innerHTML = '<span class="spinner"></span> Démarrage...';
|
| 325 |
+
|
| 326 |
+
const response = await fetch('/generate', {
|
| 327 |
+
method: 'POST',
|
| 328 |
+
headers: {
|
| 329 |
+
'Content-Type': 'application/json',
|
| 330 |
+
},
|
| 331 |
+
body: JSON.stringify(jsonData)
|
| 332 |
+
});
|
| 333 |
+
|
| 334 |
+
const result = await response.json();
|
| 335 |
+
|
| 336 |
+
if (response.ok) {
|
| 337 |
+
currentTaskId = result.task_id;
|
| 338 |
+
startStatusPolling();
|
| 339 |
+
showAlert(`Génération démarrée ! ID de tâche: ${currentTaskId}`, 'success');
|
| 340 |
+
} else {
|
| 341 |
+
throw new Error(result.error || 'Erreur inconnue');
|
| 342 |
}
|
| 343 |
+
|
| 344 |
+
} catch (error) {
|
| 345 |
+
showAlert('Erreur lors du démarrage: ' + error.message, 'error');
|
| 346 |
+
generateBtn.disabled = false;
|
| 347 |
+
generateBtn.innerHTML = '🚀 Générer le Manga';
|
| 348 |
}
|
| 349 |
+
});
|
| 350 |
+
|
| 351 |
+
function startStatusPolling() {
|
| 352 |
+
if (statusInterval) {
|
| 353 |
+
clearInterval(statusInterval);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 354 |
}
|
| 355 |
+
|
| 356 |
+
statusInterval = setInterval(async () => {
|
| 357 |
+
if (!currentTaskId) return;
|
| 358 |
+
|
| 359 |
try {
|
| 360 |
+
const response = await fetch(`/status/${currentTaskId}`);
|
| 361 |
+
const status = await response.json();
|
| 362 |
+
|
| 363 |
+
if (response.ok) {
|
| 364 |
+
updateStatusDisplay(status);
|
| 365 |
+
|
| 366 |
+
if (status.status === 'completed' || status.status === 'error') {
|
| 367 |
+
clearInterval(statusInterval);
|
| 368 |
+
statusInterval = null;
|
| 369 |
+
generateBtn.disabled = false;
|
| 370 |
+
generateBtn.innerHTML = '🚀 Générer le Manga';
|
| 371 |
+
}
|
| 372 |
+
} else {
|
| 373 |
+
console.error('Erreur lors de la récupération du statut:', status.error);
|
| 374 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 375 |
} catch (error) {
|
| 376 |
+
console.error('Erreur réseau:', error);
|
|
|
|
| 377 |
}
|
| 378 |
+
}, 2000); // Vérifier toutes les 2 secondes
|
| 379 |
+
}
|
| 380 |
+
|
| 381 |
+
function updateStatusDisplay(status) {
|
| 382 |
+
const container = statusContainer;
|
| 383 |
+
|
| 384 |
+
let statusClass = '';
|
| 385 |
+
let statusIcon = '';
|
| 386 |
+
let statusText = '';
|
| 387 |
+
|
| 388 |
+
switch (status.status) {
|
| 389 |
+
case 'queued':
|
| 390 |
+
statusClass = 'generating';
|
| 391 |
+
statusIcon = '⏳';
|
| 392 |
+
statusText = 'En file d\'attente';
|
| 393 |
+
break;
|
| 394 |
+
case 'generating':
|
| 395 |
+
statusClass = 'generating';
|
| 396 |
+
statusIcon = '🎨';
|
| 397 |
+
statusText = 'Génération en cours';
|
| 398 |
+
break;
|
| 399 |
+
case 'creating_pdf':
|
| 400 |
+
statusClass = 'generating';
|
| 401 |
+
statusIcon = '📄';
|
| 402 |
+
statusText = 'Création du PDF';
|
| 403 |
+
break;
|
| 404 |
+
case 'completed':
|
| 405 |
+
statusClass = 'completed';
|
| 406 |
+
statusIcon = '✅';
|
| 407 |
+
statusText = 'Terminé !';
|
| 408 |
+
break;
|
| 409 |
+
case 'error':
|
| 410 |
+
statusClass = 'error';
|
| 411 |
+
statusIcon = '❌';
|
| 412 |
+
statusText = 'Erreur';
|
| 413 |
+
break;
|
| 414 |
+
}
|
| 415 |
+
|
| 416 |
+
let progressHtml = '';
|
| 417 |
+
if (status.total_pages && status.current_page) {
|
| 418 |
+
const progress = (status.current_page / status.total_pages) * 100;
|
| 419 |
+
progressHtml = `
|
| 420 |
+
<div class="progress-bar">
|
| 421 |
+
<div class="progress-fill" style="width: ${progress}%"></div>
|
| 422 |
+
</div>
|
| 423 |
+
<p style="text-align: center; margin-top: 10px;">
|
| 424 |
+
Page ${status.current_page} sur ${status.total_pages}
|
| 425 |
+
${status.current_part ? `(${status.current_part})` : ''}
|
| 426 |
+
</p>
|
| 427 |
+
`;
|
| 428 |
}
|
| 429 |
+
|
| 430 |
+
let downloadHtml = '';
|
| 431 |
+
if (status.status === 'completed') {
|
| 432 |
+
downloadHtml = `
|
| 433 |
+
<a href="/download/${currentTaskId}" class="download-btn" style="width: 100%; text-align: center; margin-top: 15px;">
|
| 434 |
+
📥 Télécharger le PDF
|
| 435 |
+
</a>
|
| 436 |
+
`;
|
| 437 |
+
}
|
| 438 |
+
|
| 439 |
+
let errorHtml = '';
|
| 440 |
+
if (status.error) {
|
| 441 |
+
errorHtml = `<div class="alert alert-error">${status.error}</div>`;
|
| 442 |
+
}
|
| 443 |
+
|
| 444 |
+
container.innerHTML = `
|
| 445 |
+
<div class="status-card ${statusClass}">
|
| 446 |
+
<h3>${statusIcon} ${statusText}</h3>
|
| 447 |
+
<p><strong>ID de tâche:</strong> ${currentTaskId}</p>
|
| 448 |
+
<p><strong>Créée le:</strong> ${new Date(status.created_at).toLocaleString('fr-FR')}</p>
|
| 449 |
+
${status.completed_at ? `<p><strong>Terminée le:</strong> ${new Date(status.completed_at).toLocaleString('fr-FR')}</p>` : ''}
|
| 450 |
+
${progressHtml}
|
| 451 |
+
${errorHtml}
|
| 452 |
+
${downloadHtml}
|
| 453 |
+
</div>
|
| 454 |
+
`;
|
| 455 |
+
}
|
| 456 |
+
|
| 457 |
+
function showAlert(message, type) {
|
| 458 |
+
const alertClass = type === 'error' ? 'alert-error' : 'alert-success';
|
| 459 |
+
const alertHtml = `<div class="alert ${alertClass}">${message}</div>`;
|
| 460 |
|
| 461 |
+
statusContainer.innerHTML = alertHtml + statusContainer.innerHTML;
|
|
|
|
| 462 |
|
| 463 |
+
// Retirer l'alerte après 5 secondes
|
| 464 |
+
setTimeout(() => {
|
| 465 |
+
const alert = statusContainer.querySelector('.alert');
|
| 466 |
+
if (alert) {
|
| 467 |
+
alert.remove();
|
| 468 |
}
|
| 469 |
+
}, 5000);
|
| 470 |
+
}
|
| 471 |
+
|
| 472 |
+
// Nettoyer l'intervalle quand la page est fermée
|
| 473 |
+
window.addEventListener('beforeunload', () => {
|
| 474 |
+
if (statusInterval) {
|
| 475 |
+
clearInterval(statusInterval);
|
| 476 |
+
}
|
| 477 |
+
});
|
| 478 |
+
|
| 479 |
+
// Auto-formatter le JSON
|
| 480 |
+
jsonInput.addEventListener('blur', () => {
|
| 481 |
+
try {
|
| 482 |
+
const parsed = JSON.parse(jsonInput.value);
|
| 483 |
+
jsonInput.value = JSON.stringify(parsed, null, 2);
|
| 484 |
+
} catch (error) {
|
| 485 |
+
// Ignorer les erreurs de parsing
|
| 486 |
+
}
|
| 487 |
});
|
| 488 |
</script>
|
| 489 |
</body>
|