Files
geograsim/App/php/templates/_scripts.php
T
Adminator 9a61f55cb1 Atlas: Infrastruktur + Team-Konventionen + Sprachregel Lernarbeit
- Design-System (assets/css/design-system.css) mit 21 Komponenten,
  iPad-Responsive-Breakpoints, Touch-Ziele 36px, Music-Player,
  Glossar-Tooltips
- Templates (sims/template.html + student/teacher-Dashboard)
- Docs: module-interface.md (inkl. 4a Sprachregel, 4b Leichte Sprache,
  4c iPad), content-architecture.md, crash-recovery.md, music-registry.md
- Admin-Infrastruktur: admin-modules.html + api/admin-modules.php
  (Titel, Emoji, Bild, Status, Dauer, Alter pro Modul)
- Inbox-System: _inbox/README.md + _status.md fuer Atlas + Briefings
  an Klima, Glossar, Lehrplan, Fluss
- Zentrale SFX-Pipeline (scripts/generate-sounds.py)
- DALL-E-Bilder: 8 Badges + 5 Glossar-Repraesentationsbilder (Querformat)
- Logo + Inter-Font lokal
- PHP-APIs: admin, glossar, levels, licenses, progress, waypoints,
  assignments, profile, tickets
- Spielsprache entfernt (admin-modules, admin-levels, schueler)
- Landing-Page-Bearbeitungen (Boote sichtbarer, Button-Hintergrund)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-19 11:51:14 +02:00

74 lines
2.8 KiB
PHP

<?php
/**
* Vite Manifest Reader
* Liest dist/.vite/manifest.json und gibt die korrekten Script-Tags aus.
* Im Dev-Modus (kein manifest vorhanden) wird direkt auf die TS-Quellen verwiesen.
*/
function viteAssets(string $entry): void {
$manifestPath = APP_ROOT . '/dist/.vite/manifest.json';
// Production: Lese Manifest
if (file_exists($manifestPath)) {
$manifest = json_decode(file_get_contents($manifestPath), true);
$chunk = $manifest[$entry] ?? null;
if (!$chunk) return;
// CSS
foreach ($chunk['css'] ?? [] as $css) {
echo '<link rel="stylesheet" href="' . BASE_PATH . '/dist/' . $css . '">' . "\n";
}
// Preload imports
foreach ($chunk['imports'] ?? [] as $importKey) {
$imp = $manifest[$importKey] ?? null;
if ($imp) {
echo '<link rel="modulepreload" crossorigin href="' . BASE_PATH . '/dist/' . $imp['file'] . '">' . "\n";
}
}
// Main entry
echo '<script type="module" crossorigin src="' . BASE_PATH . '/dist/' . $chunk['file'] . '"></script>' . "\n";
}
// Dev fallback: keine Manifest-Datei → direkte TS-Referenz (Vite Dev Server)
}
/** Session-Kontext als JS-Variable injizieren */
function injectSessionContext(): void {
$ctx = [
'sessionId' => Session::studentId(),
'teacherId' => Session::teacherId(),
'baseUrl' => BASE_URL,
'basePath' => BASE_PATH,
];
echo '<script>window.__GGS__ = ' . json_encode($ctx, JSON_UNESCAPED_UNICODE) . ';</script>' . "\n";
}
/** Seite rendern: HTML laden, Session-Kontext + Favicon injizieren, ausgeben */
function renderPage(string $htmlFile): void {
$html = file_get_contents(APP_ROOT . '/' . $htmlFile);
// Favicon-Block (ersetzt alte logo.png Referenz)
$bp = BASE_PATH;
$favicon = <<<HTML
<link rel="icon" type="image/png" href="{$bp}/favicon-96x96.png" sizes="96x96">
<link rel="icon" type="image/svg+xml" href="{$bp}/favicon.svg">
<link rel="shortcut icon" href="{$bp}/favicon.ico">
<link rel="apple-touch-icon" sizes="180x180" href="{$bp}/apple-touch-icon.png">
<link rel="manifest" href="{$bp}/site.webmanifest">
HTML;
// Alten Favicon-Link ersetzen oder vor </head> einfuegen
if (preg_match('/<link[^>]*rel=["\']icon["\'][^>]*>/', $html)) {
$html = preg_replace('/<link[^>]*rel=["\']icon["\'][^>]*>\s*/', '', $html);
}
$html = str_replace('</head>', $favicon . "\n</head>", $html);
// Session-Kontext
$ctx = '<script>window.__GGS__ = ' . json_encode([
'sessionId' => Session::studentId(),
'teacherId' => Session::teacherId(),
'baseUrl' => BASE_URL,
'basePath' => BASE_PATH,
], JSON_UNESCAPED_UNICODE) . ';</script>';
echo str_replace('</body>', $ctx . "\n</body>", $html);
}