Rework contenus-edit: auto-save, OverType toolbar, dynamic sidebar links

- Auto-save: new autosave.js with 1.5s debounce, watches all forms with
  data-autosave, POSTs to form action with Accept: application/json, shows
  saving/saved/error status indicator
- All action handlers (page.php, apropos.php, form-help.php) now detect
  JSON Accept header and return {success, csrf_token} or {error} responses
- OverType toolbar enabled (toolbar:true) on all three markdown editors
  (page, about_page, form_help)
- Sidebar links: replaced fixed erg_site_url / source_code_url rows with
  dynamic sidebar_links array of {label, url} objects. Add/remove via JS.
  Fallback migration reads legacy keys if sidebar_links is empty.
- Updated AboutController and about.php template to render dynamic links
- Updated apropos.css: unified .apropos-toc-link replacing .apropos-toc-erg
  and .apropos-toc-source
- New CSS: autosave-status states, sidebar-link-row layout
- Removed all Enregistrer + Annuler buttons — auto-save and h1 back-arrow
  make them redundant
This commit is contained in:
Pontoporeia
2026-06-09 17:10:49 +02:00
parent a45a2c9ac4
commit c4a550f9d1
13 changed files with 441 additions and 93 deletions

View File

@@ -44,8 +44,19 @@ try {
$editType = 'about_page';
$aboutContacts = $db->getAproposContent('contacts');
$aboutContacts = is_array($aboutContacts) ? $aboutContacts : [];
$ergSiteUrl = $db->getAproposContent('erg_site_url');
$sourceCodeUrl = $db->getAproposContent('source_code_url');
$sidebarLinks = $db->getAproposContent('sidebar_links');
$sidebarLinks = is_array($sidebarLinks) ? $sidebarLinks : [];
// Fallback: migrate legacy individual sidebar link keys
if (empty($sidebarLinks)) {
$ergSiteUrl = $db->getAproposContent('erg_site_url');
$sourceCodeUrl = $db->getAproposContent('source_code_url');
if ($ergSiteUrl) {
$sidebarLinks[] = ['label' => 'Site de l\'erg', 'url' => $ergSiteUrl];
}
if ($sourceCodeUrl) {
$sidebarLinks[] = ['label' => 'Code source', 'url' => $sourceCodeUrl];
}
}
} else {
$editType = "page";
}
@@ -72,7 +83,7 @@ $extraJsInline = '';
if ($editType === 'page' || $editType === 'about_page') {
$initialContent = $page["content"] ?? "";
$extraJs = ["/assets/js/vendor/overtype.min.js"];
$extraJs = ["/assets/js/vendor/overtype.min.js", "/assets/js/app/autosave.js"];
$extraJsInline = <<<'JS'
var OT = window.OverType.default || window.OverType;
var hidden = document.getElementById('content');
@@ -80,12 +91,13 @@ var editor = new OT(document.getElementById('editor'), {
value: hidden.value,
minHeight: '400px',
spellcheck: false,
toolbar: true,
onChange: function(value) { hidden.value = value; }
});
JS;
} elseif ($editType === 'form_help') {
$initialContent = $formHelpContent;
$extraJs = ["/assets/js/vendor/overtype.min.js"];
$extraJs = ["/assets/js/vendor/overtype.min.js", "/assets/js/app/autosave.js"];
$extraJsInline = <<<'JS'
var OT = window.OverType.default || window.OverType;
var hidden = document.getElementById('content');
@@ -93,9 +105,12 @@ var editor = new OT(document.getElementById('editor'), {
value: hidden.value,
minHeight: '400px',
spellcheck: false,
toolbar: true,
onChange: function(value) { hidden.value = value; }
});
JS;
} elseif ($editType === 'apropos') {
$extraJs = ["/assets/js/app/autosave.js"];
}
$isAdmin = true;