mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
Phase 1: Replace Parsedown with league/commonmark (4 call sites)
This commit is contained in:
File diff suppressed because one or more lines are too long
2
TODO.md
2
TODO.md
@@ -7,7 +7,7 @@
|
|||||||
- [x] Wire vendor/autoload.php into app/bootstrap.php
|
- [x] Wire vendor/autoload.php into app/bootstrap.php
|
||||||
- [x] Update phpstan.neon (scanDirectories replaces manual Parsedown scan)
|
- [x] Update phpstan.neon (scanDirectories replaces manual Parsedown scan)
|
||||||
- [x] Write docs/system-setup.md (PHP extension requirements)
|
- [x] Write docs/system-setup.md (PHP extension requirements)
|
||||||
- [ ] Phase 1: Replace Parsedown with league/commonmark (4 call sites)
|
- [x] Phase 1: Replace Parsedown with league/commonmark (4 call sites)
|
||||||
- [ ] Phase 2: Replace PeerTubeService HTTP client with Guzzle
|
- [ ] Phase 2: Replace PeerTubeService HTTP client with Guzzle
|
||||||
- [ ] Phase 3: Replace SmtpRelay SMTP socket with PHPMailer
|
- [ ] Phase 3: Replace SmtpRelay SMTP socket with PHPMailer
|
||||||
- [ ] Phase 4 (optional): Replace Crypto with defuse/php-encryption
|
- [ ] Phase 4 (optional): Replace Crypto with defuse/php-encryption
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ require_once __DIR__ . '/../../src/AdminAuth.php';
|
|||||||
AdminAuth::requireLogin();
|
AdminAuth::requireLogin();
|
||||||
require_once __DIR__ . '/../../src/Database.php';
|
require_once __DIR__ . '/../../src/Database.php';
|
||||||
|
|
||||||
|
use League\CommonMark\CommonMarkConverter;
|
||||||
|
|
||||||
if (empty($_SESSION['csrf_token'])) {
|
if (empty($_SESSION['csrf_token'])) {
|
||||||
$_SESSION['csrf_token'] = bin2hex(random_bytes(32));
|
$_SESSION['csrf_token'] = bin2hex(random_bytes(32));
|
||||||
}
|
}
|
||||||
@@ -91,10 +93,8 @@ function renderCollapsed(Database $db, string $key): void
|
|||||||
|
|
||||||
$mdHtml = '';
|
$mdHtml = '';
|
||||||
if ($hasContent) {
|
if ($hasContent) {
|
||||||
require_once APP_ROOT . '/src/Parsedown.php';
|
$converter = new CommonMarkConverter(['html_input' => 'strip']);
|
||||||
$pd = new Parsedown();
|
$mdHtml = $converter->convert($content)->getContent();
|
||||||
$pd->setSafeMode(true);
|
|
||||||
$mdHtml = $pd->text($content);
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<div class="fhb-inline <?= $enabled ? '' : 'fhb-inline--disabled' ?>" data-key="<?= htmlspecialchars($key) ?>">
|
<div class="fhb-inline <?= $enabled ? '' : 'fhb-inline--disabled' ?>" data-key="<?= htmlspecialchars($key) ?>">
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once APP_ROOT . '/src/Database.php';
|
require_once APP_ROOT . '/src/Database.php';
|
||||||
require_once APP_ROOT . '/src/Parsedown.php';
|
|
||||||
require_once APP_ROOT . '/src/ErrorHandler.php';
|
require_once APP_ROOT . '/src/ErrorHandler.php';
|
||||||
require_once APP_ROOT . '/src/EmailObfuscator.php';
|
require_once APP_ROOT . '/src/EmailObfuscator.php';
|
||||||
|
|
||||||
|
use League\CommonMark\CommonMarkConverter;
|
||||||
|
|
||||||
class AboutController
|
class AboutController
|
||||||
{
|
{
|
||||||
private string $defaultContent = "Ce site XAMXAM a été créé pour répertorier et valoriser les mémoires de l'erg – École de Recherches Graphiques de Bruxelles.\n\nL'objectif est à la fois d'offrir une vitrine aux projets des anciennes étudiantes et de mettre en lumière la diversité des disciplines et des parcours qui façonnent l'histoire de l'école à travers les âges, depuis près de 100 ans.";
|
private string $defaultContent = "Ce site XAMXAM a été créé pour répertorier et valoriser les mémoires de l'erg – École de Recherches Graphiques de Bruxelles.\n\nL'objectif est à la fois d'offrir une vitrine aux projets des anciennes étudiantes et de mettre en lumière la diversité des disciplines et des parcours qui façonnent l'histoire de l'école à travers les âges, depuis près de 100 ans.";
|
||||||
@@ -31,12 +32,11 @@ class AboutController
|
|||||||
$contacts = null;
|
$contacts = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$pd = new Parsedown();
|
$converter = new CommonMarkConverter(['html_input' => 'strip']);
|
||||||
$pd->setSafeMode(true);
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'currentNav' => 'apropos',
|
'currentNav' => 'apropos',
|
||||||
'aboutHtml' => EmailObfuscator::obfuscateHtml($pd->text($rawContent)),
|
'aboutHtml' => EmailObfuscator::obfuscateHtml($converter->convert($rawContent)->getContent()),
|
||||||
'contacts' => $contacts,
|
'contacts' => $contacts,
|
||||||
'pageTitle' => 'À Propos – XAMXAM',
|
'pageTitle' => 'À Propos – XAMXAM',
|
||||||
'metaDescription' => "À propos de XAMXAM, le répertoire des mémoires de fin d'études de l'erg – École de Recherches Graphiques de Bruxelles.",
|
'metaDescription' => "À propos de XAMXAM, le répertoire des mémoires de fin d'études de l'erg – École de Recherches Graphiques de Bruxelles.",
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once APP_ROOT . '/src/Database.php';
|
require_once APP_ROOT . '/src/Database.php';
|
||||||
require_once APP_ROOT . '/src/Parsedown.php';
|
|
||||||
require_once APP_ROOT . '/src/ErrorHandler.php';
|
require_once APP_ROOT . '/src/ErrorHandler.php';
|
||||||
require_once APP_ROOT . '/src/EmailObfuscator.php';
|
require_once APP_ROOT . '/src/EmailObfuscator.php';
|
||||||
|
|
||||||
|
use League\CommonMark\CommonMarkConverter;
|
||||||
|
|
||||||
class LicenceController
|
class LicenceController
|
||||||
{
|
{
|
||||||
public static function create(): self
|
public static function create(): self
|
||||||
@@ -25,9 +26,8 @@ class LicenceController
|
|||||||
$pageTitle = 'Licences';
|
$pageTitle = 'Licences';
|
||||||
}
|
}
|
||||||
|
|
||||||
$pd = new Parsedown();
|
$converter = new CommonMarkConverter(['html_input' => 'strip']);
|
||||||
$pd->setSafeMode(true);
|
$html = EmailObfuscator::obfuscateHtml($converter->convert($content)->getContent());
|
||||||
$html = EmailObfuscator::obfuscateHtml($pd->text($content));
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'content' => $content,
|
'content' => $content,
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"2":1779229816,"3":1779229853}
|
[1779231711]
|
||||||
@@ -7,7 +7,6 @@
|
|||||||
* string $helpKey — block key, used as element id.
|
* string $helpKey — block key, used as element id.
|
||||||
*
|
*
|
||||||
* Outputs nothing when $helpContent is empty or whitespace-only.
|
* Outputs nothing when $helpContent is empty or whitespace-only.
|
||||||
* Parsedown must already be autoloaded (it is, via bootstrap → APP_ROOT/src/).
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$helpContent = trim($helpContent ?? '');
|
$helpContent = trim($helpContent ?? '');
|
||||||
@@ -15,13 +14,11 @@ if ($helpContent === '') {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once APP_ROOT . '/src/Parsedown.php';
|
$converter = new League\CommonMark\CommonMarkConverter(['html_input' => 'strip']);
|
||||||
$pd = new Parsedown();
|
$html = $converter->convert($helpContent)->getContent();
|
||||||
$pd->setSafeMode(true);
|
|
||||||
$html = $pd->text($helpContent);
|
|
||||||
?>
|
?>
|
||||||
<div class="student-help-block" id="help-<?= htmlspecialchars($helpKey ?? 'unknown') ?>">
|
<div class="student-help-block" id="help-<?= htmlspecialchars($helpKey ?? 'unknown') ?>">
|
||||||
<?= $html ?>
|
<?= $html ?>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
unset($helpContent, $pd, $html);
|
unset($helpContent, $converter, $html);
|
||||||
|
|||||||
Reference in New Issue
Block a user