From 72cb7acae4fbec4918921a73f6f39d27683300d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drix?= Date: Thu, 14 May 2026 23:07:15 +0200 Subject: [PATCH] fix 1.2.1 : cache index.md, H1 rendu, scroll wizard, titre Modifier MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ArticleManager : invalider le cache si index.md est plus récent que meta.json - migration_001 : touch(meta.json) après maj index.md pour forcer l'invalidation - post_view.php : masquer le H1 initial du contenu (déjà affiché par le template) - step1.php : en-tête "Modifier" sans le titre de l'article - wizard.js : retirer scrollToCursor (erroné sur auto-resize) ; Ctrl+Home/End via scrollIntoView Co-Authored-By: Claude Sonnet 4.6 --- CHANGELOG.md | 11 ++++++++ public/assets/js/wizard.js | 27 +++++-------------- public/version.txt | 2 +- .../content/migration_001_add_h1_headings.php | 1 + src/ArticleManager.php | 5 ++-- templates/post_view.php | 4 ++- templates/wizard/step1.php | 6 ++--- 7 files changed, 29 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0add525..9960b0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,17 @@ Format : [Keep a Changelog](https://keepachangelog.com/fr/1.0.0/) — versionnag --- +## [1.2.1] - 2026-05-14 + +### Corrigé +- Cache article invalidé si `index.md` est plus récent que `meta.json` (migration de contenu ne se reflétait pas) +- Migration 001 : `touch(meta.json)` après écriture de `index.md` pour invalider le cache +- `post_view.php` : le `# Titre` Markdown est retiré du rendu (déjà affiché par le template) +- Wizard étape 1 : en-tête affiche « Modifier » sans répéter le titre de l'article +- `wizard.js` : suppression de `scrollToCursor` (calcul erroné sur textarea auto-resize) ; Ctrl+Home / Ctrl+End scrollent correctement via `scrollIntoView` + +--- + ## [1.2.0] - 2026-05-14 ### Ajouté diff --git a/public/assets/js/wizard.js b/public/assets/js/wizard.js index 26454e1..f926ea0 100644 --- a/public/assets/js/wizard.js +++ b/public/assets/js/wizard.js @@ -13,20 +13,13 @@ document.addEventListener('DOMContentLoaded', function () { ta.addEventListener('input', resizeTa); resizeTa(); - function scrollToCursor() { - var lineH = parseFloat(getComputedStyle(ta).lineHeight) || 20; - var padT = parseFloat(getComputedStyle(ta).paddingTop) || 8; - var lines = ta.value.substr(0, ta.selectionStart).split('\n').length; - var cursorY = ta.getBoundingClientRect().top + padT + lines * lineH; - var margin = lineH * 3; - if (cursorY > window.innerHeight - margin) { - window.scrollBy({ top: cursorY - window.innerHeight + margin, behavior: 'instant' }); - } else if (cursorY < margin) { - window.scrollBy({ top: cursorY - margin, behavior: 'instant' }); - } - } - ta.addEventListener('keyup', scrollToCursor); - ta.addEventListener('click', scrollToCursor); + // Ctrl+Home / Ctrl+End : scroller la fenêtre vers le début/fin du textarea + ta.addEventListener('keydown', function (e) { + if (!(e.ctrlKey || e.metaKey) || (e.key !== 'Home' && e.key !== 'End')) return; + requestAnimationFrame(function () { + ta.scrollIntoView({ block: e.key === 'Home' ? 'start' : 'end', behavior: 'smooth' }); + }); + }); } // ─── Ctrl+Enter soumet le formulaire ──────────────────────────────────── @@ -61,12 +54,6 @@ document.addEventListener('DOMContentLoaded', function () { var data = await res.json(); if (data.ok) { indicator.textContent = 'Sauvegardé à ' + data.time; - // Mettre à jour le titre de la page si le serveur l'a extrait - var pageTitle = document.getElementById('wz-page-title'); - if (pageTitle && data.title) { - var prefix = pageTitle.dataset.prefix || ''; - pageTitle.textContent = prefix ? prefix + data.title : data.title; - } } else { indicator.textContent = 'Erreur de sauvegarde'; } diff --git a/public/version.txt b/public/version.txt index 26aaba0..6085e94 100644 --- a/public/version.txt +++ b/public/version.txt @@ -1 +1 @@ -1.2.0 +1.2.1 diff --git a/scripts/content/migration_001_add_h1_headings.php b/scripts/content/migration_001_add_h1_headings.php index 2483b0c..ee4dde7 100644 --- a/scripts/content/migration_001_add_h1_headings.php +++ b/scripts/content/migration_001_add_h1_headings.php @@ -43,6 +43,7 @@ foreach (glob($dataDir . '/*/meta.json') as $metaPath) { } file_put_contents($mdPath, '# ' . $title . "\n\n" . ltrim($content)); + touch($metaPath); $updated++; } diff --git a/src/ArticleManager.php b/src/ArticleManager.php index 1ce4397..769e235 100644 --- a/src/ArticleManager.php +++ b/src/ArticleManager.php @@ -1164,8 +1164,9 @@ class ArticleManager $uuid = basename($dir); $cachePath = $this->articleCachePath($uuid); - // Utiliser le cache si plus récent que meta.json - if (file_exists($cachePath) && filemtime($cachePath) >= filemtime($metaPath)) { + // Utiliser le cache si plus récent que meta.json ET index.md + $contentMtime = file_exists($dir . '/index.md') ? filemtime($dir . '/index.md') : 0; + if (file_exists($cachePath) && filemtime($cachePath) >= filemtime($metaPath) && filemtime($cachePath) >= $contentMtime) { $cached = json_decode((string) file_get_contents($cachePath), true); if (is_array($cached) && !empty($cached['uuid'])) { return $cached; diff --git a/templates/post_view.php b/templates/post_view.php index b14ef62..089f88d 100644 --- a/templates/post_view.php +++ b/templates/post_view.php @@ -9,6 +9,8 @@ $_accentMap = [ ]; $_tocItems = []; $_tocSeen = []; +// Le titre H1 est déjà affiché par le template ; on le retire du rendu. +$_rawForRender = preg_replace('/^\s*# [^\n]*\n*/u', '', $rawContent); $_renderedContent = preg_replace_callback( '/<(h[23])>(.+?)<\/h[23]>/i', function ($m) use (&$_tocItems, &$_tocSeen, $_accentMap) { @@ -31,7 +33,7 @@ $_renderedContent = preg_replace_callback( $_tocItems[] = ['level' => $level, 'text' => $plain, 'id' => $id]; return "<{$tag} id=\"" . htmlspecialchars($id) . "\">{$inner}"; }, - $Parsedown->text($rawContent) + $Parsedown->text($_rawForRender) ); ob_start(); diff --git a/templates/wizard/step1.php b/templates/wizard/step1.php index 33d3ae4..367143d 100644 --- a/templates/wizard/step1.php +++ b/templates/wizard/step1.php @@ -19,8 +19,7 @@ $_hasUuid = $_wizUuid !== '';
-

+

@@ -44,7 +43,8 @@ $_hasUuid = $_wizUuid !== '';
+ style="min-height:320px" + placeholder="# Titre de l'article Votre contenu ici…">