mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
Add Charte static page (public + admin editing)
This commit is contained in:
@@ -23,7 +23,7 @@ if (!isset($_POST['csrf_token'], $_SESSION['csrf_token'])
|
||||
exit;
|
||||
}
|
||||
|
||||
$allowedSlugs = ['about', 'licenses'];
|
||||
$allowedSlugs = ['about', 'licenses', 'charte'];
|
||||
$slug = $_POST['slug'] ?? '';
|
||||
$content = $_POST['content'] ?? '';
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ if (empty($_SESSION["csrf_token"])) {
|
||||
$_SESSION["csrf_token"] = bin2hex(random_bytes(32));
|
||||
}
|
||||
|
||||
$allowedPageSlugs = ["about", "licenses"];
|
||||
$allowedPageSlugs = ["about", "licenses", "charte"];
|
||||
$allowedApropos = ["contacts", "erg_site_url", "source_code_url"];
|
||||
|
||||
$pageSlug = $_GET["slug"] ?? "";
|
||||
|
||||
@@ -10,7 +10,7 @@ if (empty($_SESSION['csrf_token'])) {
|
||||
$_SESSION['csrf_token'] = bin2hex(random_bytes(32));
|
||||
}
|
||||
|
||||
$allowedPageSlugs = ['about', 'licenses'];
|
||||
$allowedPageSlugs = ['about', 'licenses', 'charte'];
|
||||
|
||||
try {
|
||||
$db = new Database();
|
||||
|
||||
42
app/src/Controllers/CharteController.php
Normal file
42
app/src/Controllers/CharteController.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
require_once APP_ROOT . '/src/Database.php';
|
||||
require_once APP_ROOT . '/src/ErrorHandler.php';
|
||||
require_once APP_ROOT . '/src/EmailObfuscator.php';
|
||||
|
||||
use League\CommonMark\CommonMarkConverter;
|
||||
|
||||
class CharteController
|
||||
{
|
||||
public static function create(): self
|
||||
{
|
||||
return new self();
|
||||
}
|
||||
|
||||
public function handle(): array
|
||||
{
|
||||
try {
|
||||
$db = Database::getInstance();
|
||||
$dbPage = $db->getPage('charte');
|
||||
$content = $dbPage ? $dbPage['content'] : '';
|
||||
$pageTitle = $dbPage ? $dbPage['title'] : 'Charte';
|
||||
} catch (Exception $e) {
|
||||
ErrorHandler::log('charte_page', $e);
|
||||
$content = '';
|
||||
$pageTitle = 'Charte';
|
||||
}
|
||||
|
||||
$converter = new CommonMarkConverter(['html_input' => 'strip']);
|
||||
$html = EmailObfuscator::obfuscateHtml($converter->convert($content)->getContent());
|
||||
|
||||
return [
|
||||
'content' => $content,
|
||||
'html' => $html,
|
||||
'pageTitle' => $pageTitle . ' – XAMXAM',
|
||||
'metaDescription' => "Charte d'utilisation de XAMXAM, le répertoire des TFE de l'erg.",
|
||||
'currentNav' => 'charte',
|
||||
'extraCss' => ['/assets/css/apropos.css'],
|
||||
'bodyClass' => 'apropos-body',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@
|
||||
* /tfe/<id> → TfeController → tfe view
|
||||
* /apropos → AboutController → about view
|
||||
* /licence → LicenceController → licence view
|
||||
* /charte → CharteController → charte view
|
||||
* /media.php → MediaController (direct output)
|
||||
* /live-reload → LiveReloadController (direct output)
|
||||
* /partage/<slug> → share-link flow
|
||||
@@ -34,6 +35,8 @@ class Dispatcher
|
||||
'/apropos.php' => ['controller' => 'AboutController', 'action' => 'handle', 'view' => 'public/about'],
|
||||
'/licence' => ['controller' => 'LicenceController', 'action' => 'handle', 'view' => 'public/licence'],
|
||||
'/licence.php' => ['controller' => 'LicenceController', 'action' => 'handle', 'view' => 'public/licence'],
|
||||
'/charte' => ['controller' => 'CharteController', 'action' => 'handle', 'view' => 'public/charte'],
|
||||
'/charte.php' => ['controller' => 'CharteController', 'action' => 'handle', 'view' => 'public/charte'],
|
||||
];
|
||||
|
||||
private string $path;
|
||||
|
||||
@@ -16,3 +16,8 @@
|
||||
{"timestamp":"2026-06-09T15:21:03+00:00","ip":"127.0.0.1","user_agent":"Mozilla/5.0 (X11; Linux x86_64; rv:151.0) Gecko/20100101 Firefox/151.0","resource":"apropos","action":"edit","status":"success","context":{"key":"contacts"}}
|
||||
{"timestamp":"2026-06-09T15:23:37+00:00","ip":"127.0.0.1","user_agent":"Mozilla/5.0 (X11; Linux x86_64; rv:151.0) Gecko/20100101 Firefox/151.0","resource":"apropos","action":"edit","status":"success","context":{"key":"sidebar_links"}}
|
||||
{"timestamp":"2026-06-09T15:23:39+00:00","ip":"127.0.0.1","user_agent":"Mozilla/5.0 (X11; Linux x86_64; rv:151.0) Gecko/20100101 Firefox/151.0","resource":"apropos","action":"edit","status":"success","context":{"key":"sidebar_links"}}
|
||||
{"timestamp":"2026-06-09T17:47:35+00:00","ip":"127.0.0.1","user_agent":"Mozilla/5.0 (X11; Linux x86_64; rv:151.0) Gecko/20100101 Firefox/151.0","resource":"page","action":"edit","status":"success","context":{"slug":"charte"}}
|
||||
{"timestamp":"2026-06-09T17:47:52+00:00","ip":"127.0.0.1","user_agent":"Mozilla/5.0 (X11; Linux x86_64; rv:151.0) Gecko/20100101 Firefox/151.0","resource":"page","action":"edit","status":"success","context":{"slug":"charte"}}
|
||||
{"timestamp":"2026-06-09T17:48:00+00:00","ip":"127.0.0.1","user_agent":"Mozilla/5.0 (X11; Linux x86_64; rv:151.0) Gecko/20100101 Firefox/151.0","resource":"page","action":"edit","status":"success","context":{"slug":"charte"}}
|
||||
{"timestamp":"2026-06-09T17:48:04+00:00","ip":"127.0.0.1","user_agent":"Mozilla/5.0 (X11; Linux x86_64; rv:151.0) Gecko/20100101 Firefox/151.0","resource":"page","action":"edit","status":"success","context":{"slug":"charte"}}
|
||||
{"timestamp":"2026-06-09T17:48:12+00:00","ip":"127.0.0.1","user_agent":"Mozilla/5.0 (X11; Linux x86_64; rv:151.0) Gecko/20100101 Firefox/151.0","resource":"page","action":"edit","status":"success","context":{"slug":"charte"}}
|
||||
|
||||
@@ -50,6 +50,10 @@ $_thesisId = $_GET['id'] ?? null;
|
||||
<a href="/licence"
|
||||
<?= ($_navCurrent === 'licence') ? 'aria-current="page"' : '' ?>>Licences</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/charte"
|
||||
<?= ($_navCurrent === 'charte') ? 'aria-current="page"' : '' ?>>Charte</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/apropos"
|
||||
<?= ($_navCurrent === 'apropos') ? 'aria-current="page"' : '' ?>>À Propos</a>
|
||||
@@ -68,6 +72,10 @@ $_thesisId = $_GET['id'] ?? null;
|
||||
<a href="/licence"
|
||||
<?= ($_navCurrent === 'licence') ? 'aria-current="page"' : '' ?>>Licences</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/charte"
|
||||
<?= ($_navCurrent === 'charte') ? 'aria-current="page"' : '' ?>>Charte</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/apropos"
|
||||
<?= ($_navCurrent === 'apropos') ? 'aria-current="page"' : '' ?>>À Propos</a>
|
||||
|
||||
9
app/templates/public/charte.php
Normal file
9
app/templates/public/charte.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<main class="apropos-main" id="main-content">
|
||||
<div class="prose apropos-single">
|
||||
<?php if (!empty(trim($content))): ?>
|
||||
<?= $html ?>
|
||||
<?php else: ?>
|
||||
<p>Contenu à venir.</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</main>
|
||||
Reference in New Issue
Block a user