diff --git a/TODO.md b/TODO.md index fea61cd..d00e62b 100644 --- a/TODO.md +++ b/TODO.md @@ -21,6 +21,18 @@ - [x] F. `ThesisEditController.php` — Remove separate video/audio/peertube_* handleFilePondQueueFiles calls; also legacy $_FILES path - [x] G. `ThesisCreateController.php` — Same as F +# HTMX Fragment Architecture Reorganization + +- [x] Create shared templates `_licence.php` and `_format-website.php` in `templates/partials/form/` +- [x] Create `src/FragmentRenderer.php` helper +- [x] Create `public/admin/fragments/` and `public/partage/fragments/` subdirectories +- [x] Create thin fragment endpoint files (auth + data prep + render shared template) +- [x] Update all hx-post references in templates to point to new `fragments/` paths +- [x] Update `partage/index.php` routing for new fragments +- [x] Keep old fragment files as thin delegates to new `fragments/` for backward compat +- [x] Update nginx config for partage fragment PHP handling +- [ ] Deploy: `just deploy` + `just deploy-nginx` + ## Previous items - [x] Step 1 — Build 4 PHP endpoints (process.php, revert.php, load.php, remove.php) diff --git a/app/public/admin/fichiers-fragment.php b/app/public/admin/fichiers-fragment.php index 8df172c..fbd904d 100644 --- a/app/public/admin/fichiers-fragment.php +++ b/app/public/admin/fichiers-fragment.php @@ -1,17 +1,6 @@ getConnection(); - -$stmt = $db->prepare('SELECT id FROM format_types WHERE name = ? LIMIT 1'); -$stmt->execute(['Site web']); -$websiteFormatId = $stmt->fetchColumn(); - -if (!$websiteFormatId) { - echo '
'; - exit; -} - -$selectedFormats = isset($_POST['formats']) && is_array($_POST['formats']) - ? array_map('intval', $_POST['formats']) - : []; - -if (!in_array((int)$websiteFormatId, $selectedFormats, true)) { - echo ''; - exit; -} - -$websiteUrl = htmlspecialchars($_POST['website_url'] ?? ''); -$websiteLabel = htmlspecialchars($_POST['website_label'] ?? ''); -?> - +require_once __DIR__ . '/fragments/format-website.php'; diff --git a/app/public/admin/fragments/fichiers.php b/app/public/admin/fragments/fichiers.php new file mode 100644 index 0000000..365ef74 --- /dev/null +++ b/app/public/admin/fragments/fichiers.php @@ -0,0 +1,13 @@ +getConnection(); + +$stmt = $db->prepare('SELECT id FROM format_types WHERE name = ? LIMIT 1'); +$stmt->execute(['Site web']); +$websiteFormatId = $stmt->fetchColumn(); + +$selectedFormats = isset($_POST['formats']) && is_array($_POST['formats']) + ? array_map('intval', $_POST['formats']) + : []; + +FragmentRenderer::render('form/_format-website', [ + 'fieldsetId' => 'edit-website-url-fieldset', + 'selectedFormats' => $selectedFormats, + 'websiteFormatId' => $websiteFormatId, + 'websiteUrl' => $_POST['website_url'] ?? '', + 'websiteLabel' => $_POST['website_label'] ?? '', +]); diff --git a/app/public/admin/fragments/language-autre.php b/app/public/admin/fragments/language-autre.php new file mode 100644 index 0000000..b689c67 --- /dev/null +++ b/app/public/admin/fragments/language-autre.php @@ -0,0 +1,9 @@ +getAllLicenseTypes(); + +FragmentRenderer::render('form/_licence', [ + 'adminMode' => true, + 'accessTypeId' => $_POST['access_type_id'] ?? '', + 'licenseId' => $_POST['license_id'] ?? '', + 'licenseCustom' => $_POST['license_custom'] ?? '', + 'cc2r' => !empty($_POST['cc2r']), + 'wantLicense' => !empty($_POST['want_license']), + 'hxPost' => '/admin/fragments/licence.php', + 'licenseTypes' => $licenseTypes, +]); diff --git a/app/public/admin/fragments/tag-search.php b/app/public/admin/fragments/tag-search.php new file mode 100644 index 0000000..4718c86 --- /dev/null +++ b/app/public/admin/fragments/tag-search.php @@ -0,0 +1,10 @@ +getAllLicenseTypes(); -?> - -