Phase 5: Erscheinungsbild mit Entwurf, Vorschau und Veröffentlichen
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 2m7s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 2m11s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 2m16s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 2m18s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 2m49s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 2m46s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 2m41s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 2m33s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m0s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 2m7s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 2m11s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 2m16s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 2m18s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 2m49s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 2m46s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 2m41s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 2m33s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m0s
- Theme in den Einstellungen (Entwurf/veröffentlicht), Übernahme der Einstellungen aus Phase 0; statische CSS-Datei mit Hash beim Veröffentlichen - Logos hell/dunkel, Signet, App-Symbol → Favicon, Homescreen-Symbole, Web-App-Manifest; SVG-Bereinigung - Markenfarbe exakt, zweite Akzentfarbe, Kopfleiste hell/Marke/dunkel, Kontrastprüfung (WCAG AA) mit automatisch lesbarer Linkfarbe - Lokale Schriften (Latein), Überschriften-Schrift, eigene WOFF2-Schrift, Ecken, Dichte, Dunkelmodus-Regel - Anmeldeseite (geteilt/zentriert, Bild, Texte), Fußzeile, E-Mails im Design - Admin: Live-Vorschau (Startseite, Anmeldung, Beispielseite; hell/dunkel), Veröffentlichen, Verwerfen, Export/Import, Zurücksetzen, eigenes CSS - Admin-Bereich übernimmt Logo, Farbe und Favicon; Whitelabel Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
ee8dde93c0
commit
82bbeef31b
148 changed files with 2884 additions and 362 deletions
92
app/Support/Theme/ThemeTransfer.php
Normal file
92
app/Support/Theme/ThemeTransfer.php
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
|
||||
namespace App\Support\Theme;
|
||||
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Erscheinungsbild als Datei – z. B. vom Test- auf das Produktivsystem.
|
||||
* Bilder und Schrift reisen als Daten-URLs mit.
|
||||
*/
|
||||
class ThemeTransfer
|
||||
{
|
||||
public const FORMAT = 'inhaus-theme';
|
||||
|
||||
private const FILES = ['logo_light', 'logo_dark', 'logo_mark', 'app_icon', 'login_image', 'custom_font'];
|
||||
|
||||
private const MIME = [
|
||||
'image/svg+xml' => 'svg', 'image/png' => 'png', 'image/jpeg' => 'jpg', 'image/webp' => 'webp', 'font/woff2' => 'woff2',
|
||||
];
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $theme
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function export(array $theme): array
|
||||
{
|
||||
$disk = Storage::disk('uploads');
|
||||
$files = [];
|
||||
|
||||
foreach (self::FILES as $key) {
|
||||
if ($theme[$key] && $disk->exists($theme[$key])) {
|
||||
$mime = $key === 'custom_font' ? 'font/woff2' : ($disk->mimeType($theme[$key]) ?: 'application/octet-stream');
|
||||
$files[$key] = 'data:'.$mime.';base64,'.base64_encode((string) $disk->get($theme[$key]));
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'format' => self::FORMAT,
|
||||
'version' => 1,
|
||||
'exported_at' => now()->toIso8601String(),
|
||||
'theme' => collect($theme)->except([...self::FILES, 'icons', 'stylesheet'])->all(),
|
||||
'files' => $files,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed> Werte für den Entwurf
|
||||
*/
|
||||
public function import(string $json): array
|
||||
{
|
||||
$data = json_decode($json, true);
|
||||
|
||||
if (! is_array($data) || ($data['format'] ?? null) !== self::FORMAT || ! is_array($data['theme'] ?? null)) {
|
||||
throw new RuntimeException('Die Datei ist kein exportiertes Erscheinungsbild.');
|
||||
}
|
||||
|
||||
$values = collect($data['theme'])->except([...self::FILES, 'icons', 'stylesheet'])->all();
|
||||
|
||||
foreach (self::FILES as $key) {
|
||||
$values[$key] = null;
|
||||
$uri = $data['files'][$key] ?? null;
|
||||
|
||||
if (! is_string($uri) || ! preg_match('#^data:([a-z0-9.+/-]+);base64,(.+)$#i', $uri, $m)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$extension = self::MIME[strtolower($m[1])] ?? null;
|
||||
$binary = base64_decode($m[2], true);
|
||||
|
||||
if (! $extension || $binary === false || strlen($binary) > 8 * 1024 * 1024) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Inhalt prüfen: Bilder müssen sich lesen lassen, SVG wird von allem Ausführbaren befreit.
|
||||
if ($extension === 'svg' && ($binary = SvgSanitizer::sanitize($binary)) === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (in_array($extension, ['png', 'jpg', 'webp'], true) && @getimagesizefromstring($binary) === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$path = ($key === 'custom_font' ? 'theme/fonts/' : 'theme/').'import-'.Str::random(20).'.'.$extension;
|
||||
Storage::disk('uploads')->put($path, $binary);
|
||||
$values[$key] = $path;
|
||||
}
|
||||
|
||||
return Theme::normalize([...Theme::DEFAULTS, ...$values]);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue