Neuigkeiten und Termine (vorgezogen)
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m8s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m12s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m12s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m5s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m6s
CI / Build-Artefakte aktuell (pull_request) Failing after 43s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m8s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m12s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m12s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m5s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m6s
CI / Build-Artefakte aktuell (pull_request) Failing after 43s
- Neuigkeiten mit Kategorien, Titelbild (WebP-Varianten), Lesezeit, geplanter Veröffentlichung und Hervorhebung; Text wird beim Speichern bereinigt - Termine mit Ort, Online-Link, ganztägigen Terminen und .ics-Export - Startseite nach Intranet-Vorbild: Slider, Neuigkeiten, Termine, Aktuelles aus den Bereichen; mobil in sinnvoller Reihenfolge - Admin: Beiträge, Kategorien und Termine - Bildverarbeitung für Shared Hosting: nur eine Vollbild-Kopie im Speicher, Speicherlimit bei Bedarf auf 256 MB angehoben (wie WordPress) - Demo-Inhalte für die Entwicklung Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
f813a0fff3
commit
a36752e09a
103 changed files with 2810 additions and 124 deletions
49
app/Support/RichText.php
Normal file
49
app/Support/RichText.php
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
namespace App\Support;
|
||||
|
||||
use Filament\Forms\Components\RichEditor\RichContentRenderer;
|
||||
use Symfony\Component\HtmlSanitizer\HtmlSanitizer;
|
||||
use Symfony\Component\HtmlSanitizer\HtmlSanitizerConfig;
|
||||
|
||||
/**
|
||||
* Wandelt Inhalte aus dem Rich-Text-Editor in sicheres HTML für das Portal.
|
||||
* Wird beim Speichern aufgerufen; das Ergebnis liegt fertig in der Datenbank.
|
||||
*/
|
||||
class RichText
|
||||
{
|
||||
public function toSafeHtml(?string $content): string
|
||||
{
|
||||
if (blank($content)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$html = RichContentRenderer::make($content)
|
||||
->fileAttachmentsDisk('uploads')
|
||||
->toHtml();
|
||||
|
||||
return $this->sanitizer()->sanitize($html);
|
||||
}
|
||||
|
||||
public function readingMinutes(?string $html): int
|
||||
{
|
||||
$words = str_word_count(strip_tags((string) $html), 0, 'ÄÖÜäöüß');
|
||||
|
||||
return max(1, (int) ceil($words / 200));
|
||||
}
|
||||
|
||||
private function sanitizer(): HtmlSanitizer
|
||||
{
|
||||
$config = (new HtmlSanitizerConfig)
|
||||
->allowSafeElements()
|
||||
->allowLinkSchemes(['https', 'http', 'mailto', 'tel'])
|
||||
->allowRelativeLinks()
|
||||
->allowMediaSchemes(['https', 'http'])
|
||||
->allowRelativeMedias()
|
||||
->forceAttribute('a', 'rel', 'noopener noreferrer')
|
||||
->dropElement('iframe')
|
||||
->withMaxInputLength(500_000);
|
||||
|
||||
return new HtmlSanitizer($config);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue