Spaces:
Sleeping
Sleeping
Update templates/index.html
Browse files- templates/index.html +76 -63
templates/index.html
CHANGED
|
@@ -128,23 +128,41 @@
|
|
| 128 |
font-size: 16px;
|
| 129 |
}
|
| 130 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
.code-section {
|
| 132 |
-
|
| 133 |
-
border-radius: 8px;
|
| 134 |
-
overflow: hidden;
|
| 135 |
-
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
|
| 136 |
}
|
| 137 |
|
| 138 |
.code-header {
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
|
|
|
|
|
|
| 148 |
|
| 149 |
.code-content {
|
| 150 |
margin: 0;
|
|
@@ -155,29 +173,44 @@
|
|
| 155 |
font-family: 'Courier New', monospace;
|
| 156 |
font-size: 14px;
|
| 157 |
line-height: 1.5;
|
|
|
|
| 158 |
}
|
| 159 |
|
| 160 |
.output-section {
|
| 161 |
background-color: var(--output-bg);
|
| 162 |
padding: 15px;
|
| 163 |
-
border-
|
| 164 |
-
border-top: 1px solid #ddd;
|
| 165 |
color: #333;
|
| 166 |
font-family: 'Courier New', monospace;
|
| 167 |
font-size: 14px;
|
| 168 |
white-space: pre-wrap;
|
| 169 |
overflow-x: auto;
|
|
|
|
|
|
|
| 170 |
}
|
| 171 |
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
border-left: 4px solid var(--primary-color);
|
| 177 |
-
border-radius: 0 8px 8px 0;
|
| 178 |
-
overflow-x: auto; /* Pour les formules LaTeX larges */
|
| 179 |
-
white-space: pre-wrap; /* Preserve whitespace/line breaks from stream */
|
| 180 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 181 |
|
| 182 |
.latex-display {
|
| 183 |
overflow-x: auto;
|
|
@@ -221,25 +254,23 @@
|
|
| 221 |
100% { opacity: 0.6; }
|
| 222 |
}
|
| 223 |
|
| 224 |
-
/* Styles spécifiques à MathJax pour le rendu */
|
| 225 |
-
/* Ensure rendered math doesn't cause excessive layout shifts or overflow */
|
| 226 |
mjx-container {
|
| 227 |
overflow-x: auto;
|
| 228 |
overflow-y: hidden;
|
| 229 |
-
display: block;
|
| 230 |
-
margin: 1em 0;
|
| 231 |
-
text-align: initial;
|
|
|
|
| 232 |
}
|
| 233 |
-
mjx-assistive-mml {
|
| 234 |
display: none !important;
|
| 235 |
}
|
| 236 |
|
| 237 |
-
/* Ensure inline math flows correctly */
|
| 238 |
.MathJax nobr,.MathJax .mjx-chtml{
|
| 239 |
-
display: inline-block !important;
|
| 240 |
-
white-space: normal !important;
|
| 241 |
}
|
| 242 |
-
.step-section span.MathJax_Preview {
|
| 243 |
display: none !important;
|
| 244 |
}
|
| 245 |
|
|
@@ -310,7 +341,6 @@
|
|
| 310 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js"></script>
|
| 311 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/languages/python.min.js"></script>
|
| 312 |
|
| 313 |
-
<!-- MathJax Configuration -->
|
| 314 |
<script>
|
| 315 |
window.MathJax = {
|
| 316 |
tex: {
|
|
@@ -321,10 +351,10 @@
|
|
| 321 |
packages: {'[+]': ['ams', 'noerrors', 'physics', 'cancel', 'color', 'mhchem', 'mathtools']}
|
| 322 |
},
|
| 323 |
options: {
|
| 324 |
-
enableMenu: false,
|
| 325 |
-
ignoreHtmlClass: 'code-content',
|
| 326 |
-
processHtmlClass: 'step-section|latex-display',
|
| 327 |
-
skipHtmlTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
|
| 328 |
},
|
| 329 |
loader: {
|
| 330 |
load: ['[tex]/ams', '[tex]/noerrors', '[tex]/physics', '[tex]/cancel', '[tex]/color', '[tex]/mhchem', '[tex]/mathtools']
|
|
@@ -334,7 +364,6 @@
|
|
| 334 |
}
|
| 335 |
};
|
| 336 |
</script>
|
| 337 |
-
<!-- Load MathJax library -->
|
| 338 |
<script id="MathJax-script" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-svg.js"></script>
|
| 339 |
|
| 340 |
<script>
|
|
@@ -360,7 +389,7 @@
|
|
| 360 |
|
| 361 |
solutionOutput.style.display = 'block';
|
| 362 |
loadingIndicator.style.display = 'flex';
|
| 363 |
-
solution.innerHTML = '';
|
| 364 |
|
| 365 |
fetch('/solved', {
|
| 366 |
method: 'POST',
|
|
@@ -374,15 +403,12 @@
|
|
| 374 |
function processStream({ done, value }) {
|
| 375 |
if (done) {
|
| 376 |
loadingIndicator.style.display = 'none';
|
| 377 |
-
// Optional: Final typeset on the whole container if needed, but per-chunk should be enough
|
| 378 |
-
// MathJax.typesetPromise([solution]).catch(e => console.error('Final MathJax typesetting error:', e));
|
| 379 |
return;
|
| 380 |
}
|
| 381 |
|
| 382 |
buffer += decoder.decode(value, { stream: true });
|
| 383 |
-
// Split by two newlines to get distinct chunks from the stream
|
| 384 |
const lines = buffer.split('\n\n');
|
| 385 |
-
buffer = lines.pop();
|
| 386 |
|
| 387 |
for (const line of lines) {
|
| 388 |
if (line.startsWith('data: ')) {
|
|
@@ -390,7 +416,6 @@
|
|
| 390 |
const data = JSON.parse(line.substr(6));
|
| 391 |
|
| 392 |
if (data.mode) {
|
| 393 |
-
// Update loading indicator based on mode
|
| 394 |
if (data.mode === 'thinking') {
|
| 395 |
loadingIndicator.className = 'thinking-indicator';
|
| 396 |
loadingIndicator.innerHTML = '<i class="fas fa-brain indicator-icon"></i><span>Je réfléchis au problème...</span>';
|
|
@@ -408,14 +433,10 @@
|
|
| 408 |
|
| 409 |
if (data.content) {
|
| 410 |
const content = data.content;
|
| 411 |
-
|
| 412 |
-
// Create a container for this new content chunk
|
| 413 |
const contentContainer = document.createElement('div');
|
| 414 |
|
| 415 |
if (content.includes('```python')) {
|
| 416 |
-
// Code block
|
| 417 |
const codeHtml = content.replace(/```python\n([\s\S]*?)\n```/g, function(match, p1) {
|
| 418 |
-
// Use <pre> and <code> for Highlight.js
|
| 419 |
return `<div class="code-section">
|
| 420 |
<div class="code-header">
|
| 421 |
<span>Code Python</span>
|
|
@@ -425,26 +446,21 @@
|
|
| 425 |
});
|
| 426 |
contentContainer.innerHTML = codeHtml;
|
| 427 |
solution.appendChild(contentContainer);
|
| 428 |
-
// Apply syntax highlighting
|
| 429 |
contentContainer.querySelectorAll('pre code').forEach((block) => {
|
| 430 |
hljs.highlightElement(block);
|
| 431 |
});
|
| 432 |
-
}
|
| 433 |
-
|
| 434 |
const outputHtml = content.replace(/Résultat d'exécution:\n```\n([\s\S]*?)\n```/g, function(match, p1) {
|
| 435 |
return `<div class="output-section">${p1}</div>`;
|
| 436 |
});
|
| 437 |
contentContainer.innerHTML = outputHtml;
|
| 438 |
solution.appendChild(contentContainer);
|
| 439 |
-
}
|
| 440 |
-
|
| 441 |
-
// Add a class that MathJax is configured to process.
|
| 442 |
contentContainer.className = 'step-section';
|
| 443 |
contentContainer.innerHTML = content;
|
| 444 |
solution.appendChild(contentContainer);
|
| 445 |
-
|
| 446 |
-
// Tell MathJax to process the newly added content container
|
| 447 |
-
// MathJax.typesetPromise takes an array of elements or element IDs.
|
| 448 |
MathJax.typesetPromise([contentContainer]).catch(e => console.error('MathJax typesetting error:', e));
|
| 449 |
}
|
| 450 |
}
|
|
@@ -458,7 +474,7 @@
|
|
| 458 |
errorDiv.style.borderRadius = '5px';
|
| 459 |
errorDiv.textContent = `Erreur: ${data.error}`;
|
| 460 |
solution.appendChild(errorDiv);
|
| 461 |
-
loadingIndicator.style.display = 'none';
|
| 462 |
}
|
| 463 |
} catch (e) {
|
| 464 |
console.error('Error parsing JSON from stream:', e, line);
|
|
@@ -466,14 +482,11 @@
|
|
| 466 |
}
|
| 467 |
}
|
| 468 |
|
| 469 |
-
// Scroll to bottom as new content arrives
|
| 470 |
window.scrollTo(0, document.body.scrollHeight);
|
| 471 |
|
| 472 |
-
// Read the next chunk from the stream
|
| 473 |
return reader.read().then(processStream);
|
| 474 |
}
|
| 475 |
|
| 476 |
-
// Start reading the stream
|
| 477 |
return reader.read().then(processStream);
|
| 478 |
})
|
| 479 |
.catch(error => {
|
|
@@ -485,7 +498,7 @@
|
|
| 485 |
errorDiv.style.borderRadius = '5px';
|
| 486 |
errorDiv.textContent = `Erreur de connexion ou du serveur: ${error}`;
|
| 487 |
solution.appendChild(errorDiv);
|
| 488 |
-
loadingIndicator.style.display = 'none';
|
| 489 |
console.error('Fetch error:', error);
|
| 490 |
});
|
| 491 |
});
|
|
|
|
| 128 |
font-size: 16px;
|
| 129 |
}
|
| 130 |
|
| 131 |
+
/* Modified styles for continuous flow */
|
| 132 |
+
.step-section, .code-section, .output-section {
|
| 133 |
+
margin: 0; /* Remove vertical margins between blocks */
|
| 134 |
+
padding: 15px; /* Keep internal padding */
|
| 135 |
+
border-radius: 0; /* Remove rounded corners between blocks */
|
| 136 |
+
border-left: none; /* Remove left border */
|
| 137 |
+
overflow-x: auto;
|
| 138 |
+
white-space: pre-wrap;
|
| 139 |
+
background-color: transparent; /* Ensure consistent background or use #fff from parent */
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
.step-section {
|
| 143 |
+
/* If you want a subtle indicator without making it a block */
|
| 144 |
+
border-left: 4px solid var(--primary-color);
|
| 145 |
+
padding-left: calc(15px - 4px); /* Adjust padding to keep content aligned */
|
| 146 |
+
background-color: #f9f9f9; /* Background for step sections */
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
|
| 150 |
.code-section {
|
| 151 |
+
/* Code section has its own internal padding and background */
|
|
|
|
|
|
|
|
|
|
| 152 |
}
|
| 153 |
|
| 154 |
.code-header {
|
| 155 |
+
background-color: #343a40;
|
| 156 |
+
color: white;
|
| 157 |
+
padding: 8px 15px;
|
| 158 |
+
font-size: 14px;
|
| 159 |
+
font-family: 'Courier New', monospace;
|
| 160 |
+
display: flex;
|
| 161 |
+
justify-content: space-between;
|
| 162 |
+
align-items: center;
|
| 163 |
+
border-top-left-radius: 8px; /* Keep top radius for first code block */
|
| 164 |
+
border-top-right-radius: 8px;
|
| 165 |
+
}
|
| 166 |
|
| 167 |
.code-content {
|
| 168 |
margin: 0;
|
|
|
|
| 173 |
font-family: 'Courier New', monospace;
|
| 174 |
font-size: 14px;
|
| 175 |
line-height: 1.5;
|
| 176 |
+
/* No border-radius here, managed by parent or siblings */
|
| 177 |
}
|
| 178 |
|
| 179 |
.output-section {
|
| 180 |
background-color: var(--output-bg);
|
| 181 |
padding: 15px;
|
| 182 |
+
border-top: 1px solid #ddd; /* Separator from code */
|
|
|
|
| 183 |
color: #333;
|
| 184 |
font-family: 'Courier New', monospace;
|
| 185 |
font-size: 14px;
|
| 186 |
white-space: pre-wrap;
|
| 187 |
overflow-x: auto;
|
| 188 |
+
border-bottom-left-radius: 8px; /* Keep bottom radius for last output block */
|
| 189 |
+
border-bottom-right-radius: 8px;
|
| 190 |
}
|
| 191 |
|
| 192 |
+
/* Add border-radius back to the very first and very last child inside #solution */
|
| 193 |
+
#solution > div:first-child {
|
| 194 |
+
border-top-left-radius: 8px;
|
| 195 |
+
border-top-right-radius: 8px;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
}
|
| 197 |
+
/* Special case for first code header */
|
| 198 |
+
#solution .code-section:first-child .code-header {
|
| 199 |
+
border-top-left-radius: 8px;
|
| 200 |
+
border-top-right-radius: 8px;
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
|
| 204 |
+
#solution > div:last-child {
|
| 205 |
+
border-bottom-left-radius: 8px;
|
| 206 |
+
border-bottom-right-radius: 8px;
|
| 207 |
+
}
|
| 208 |
+
/* Special case for last code content (if not followed by output) */
|
| 209 |
+
#solution .code-section:last-child .code-content:last-child:not(+.output-section) {
|
| 210 |
+
border-bottom-left-radius: 8px;
|
| 211 |
+
border-bottom-right-radius: 8px;
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
|
| 215 |
.latex-display {
|
| 216 |
overflow-x: auto;
|
|
|
|
| 254 |
100% { opacity: 0.6; }
|
| 255 |
}
|
| 256 |
|
|
|
|
|
|
|
| 257 |
mjx-container {
|
| 258 |
overflow-x: auto;
|
| 259 |
overflow-y: hidden;
|
| 260 |
+
display: block;
|
| 261 |
+
margin: 1em 0;
|
| 262 |
+
text-align: initial;
|
| 263 |
+
padding: 0 !important;
|
| 264 |
}
|
| 265 |
+
mjx-assistive-mml {
|
| 266 |
display: none !important;
|
| 267 |
}
|
| 268 |
|
|
|
|
| 269 |
.MathJax nobr,.MathJax .mjx-chtml{
|
| 270 |
+
display: inline-block !important;
|
| 271 |
+
white-space: normal !important;
|
| 272 |
}
|
| 273 |
+
.step-section span.MathJax_Preview {
|
| 274 |
display: none !important;
|
| 275 |
}
|
| 276 |
|
|
|
|
| 341 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js"></script>
|
| 342 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/languages/python.min.js"></script>
|
| 343 |
|
|
|
|
| 344 |
<script>
|
| 345 |
window.MathJax = {
|
| 346 |
tex: {
|
|
|
|
| 351 |
packages: {'[+]': ['ams', 'noerrors', 'physics', 'cancel', 'color', 'mhchem', 'mathtools']}
|
| 352 |
},
|
| 353 |
options: {
|
| 354 |
+
enableMenu: false,
|
| 355 |
+
ignoreHtmlClass: 'code-content',
|
| 356 |
+
processHtmlClass: 'step-section|latex-display',
|
| 357 |
+
skipHtmlTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
|
| 358 |
},
|
| 359 |
loader: {
|
| 360 |
load: ['[tex]/ams', '[tex]/noerrors', '[tex]/physics', '[tex]/cancel', '[tex]/color', '[tex]/mhchem', '[tex]/mathtools']
|
|
|
|
| 364 |
}
|
| 365 |
};
|
| 366 |
</script>
|
|
|
|
| 367 |
<script id="MathJax-script" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-svg.js"></script>
|
| 368 |
|
| 369 |
<script>
|
|
|
|
| 389 |
|
| 390 |
solutionOutput.style.display = 'block';
|
| 391 |
loadingIndicator.style.display = 'flex';
|
| 392 |
+
solution.innerHTML = '';
|
| 393 |
|
| 394 |
fetch('/solved', {
|
| 395 |
method: 'POST',
|
|
|
|
| 403 |
function processStream({ done, value }) {
|
| 404 |
if (done) {
|
| 405 |
loadingIndicator.style.display = 'none';
|
|
|
|
|
|
|
| 406 |
return;
|
| 407 |
}
|
| 408 |
|
| 409 |
buffer += decoder.decode(value, { stream: true });
|
|
|
|
| 410 |
const lines = buffer.split('\n\n');
|
| 411 |
+
buffer = lines.pop();
|
| 412 |
|
| 413 |
for (const line of lines) {
|
| 414 |
if (line.startsWith('data: ')) {
|
|
|
|
| 416 |
const data = JSON.parse(line.substr(6));
|
| 417 |
|
| 418 |
if (data.mode) {
|
|
|
|
| 419 |
if (data.mode === 'thinking') {
|
| 420 |
loadingIndicator.className = 'thinking-indicator';
|
| 421 |
loadingIndicator.innerHTML = '<i class="fas fa-brain indicator-icon"></i><span>Je réfléchis au problème...</span>';
|
|
|
|
| 433 |
|
| 434 |
if (data.content) {
|
| 435 |
const content = data.content;
|
|
|
|
|
|
|
| 436 |
const contentContainer = document.createElement('div');
|
| 437 |
|
| 438 |
if (content.includes('```python')) {
|
|
|
|
| 439 |
const codeHtml = content.replace(/```python\n([\s\S]*?)\n```/g, function(match, p1) {
|
|
|
|
| 440 |
return `<div class="code-section">
|
| 441 |
<div class="code-header">
|
| 442 |
<span>Code Python</span>
|
|
|
|
| 446 |
});
|
| 447 |
contentContainer.innerHTML = codeHtml;
|
| 448 |
solution.appendChild(contentContainer);
|
|
|
|
| 449 |
contentContainer.querySelectorAll('pre code').forEach((block) => {
|
| 450 |
hljs.highlightElement(block);
|
| 451 |
});
|
| 452 |
+
}
|
| 453 |
+
else if (content.includes('Résultat d\'exécution:')) {
|
| 454 |
const outputHtml = content.replace(/Résultat d'exécution:\n```\n([\s\S]*?)\n```/g, function(match, p1) {
|
| 455 |
return `<div class="output-section">${p1}</div>`;
|
| 456 |
});
|
| 457 |
contentContainer.innerHTML = outputHtml;
|
| 458 |
solution.appendChild(contentContainer);
|
| 459 |
+
}
|
| 460 |
+
else {
|
|
|
|
| 461 |
contentContainer.className = 'step-section';
|
| 462 |
contentContainer.innerHTML = content;
|
| 463 |
solution.appendChild(contentContainer);
|
|
|
|
|
|
|
|
|
|
| 464 |
MathJax.typesetPromise([contentContainer]).catch(e => console.error('MathJax typesetting error:', e));
|
| 465 |
}
|
| 466 |
}
|
|
|
|
| 474 |
errorDiv.style.borderRadius = '5px';
|
| 475 |
errorDiv.textContent = `Erreur: ${data.error}`;
|
| 476 |
solution.appendChild(errorDiv);
|
| 477 |
+
loadingIndicator.style.display = 'none';
|
| 478 |
}
|
| 479 |
} catch (e) {
|
| 480 |
console.error('Error parsing JSON from stream:', e, line);
|
|
|
|
| 482 |
}
|
| 483 |
}
|
| 484 |
|
|
|
|
| 485 |
window.scrollTo(0, document.body.scrollHeight);
|
| 486 |
|
|
|
|
| 487 |
return reader.read().then(processStream);
|
| 488 |
}
|
| 489 |
|
|
|
|
| 490 |
return reader.read().then(processStream);
|
| 491 |
})
|
| 492 |
.catch(error => {
|
|
|
|
| 498 |
errorDiv.style.borderRadius = '5px';
|
| 499 |
errorDiv.textContent = `Erreur de connexion ou du serveur: ${error}`;
|
| 500 |
solution.appendChild(errorDiv);
|
| 501 |
+
loadingIndicator.style.display = 'none';
|
| 502 |
console.error('Fetch error:', error);
|
| 503 |
});
|
| 504 |
});
|