| 1 | <?php |
| 2 | declare(strict_types=1); |
| 3 | require __DIR__.'/lib/bootstrap.php'; |
| 4 | $logged = isset($_SESSION['user']) && (localDev() || (($_SESSION['expires'] ?? 0) > time())); |
| 5 | $prefs = ['theme' => 'system', 'font' => 'serif', 'name' => '', 'role' => 'user']; |
| 6 | if ($logged) { |
| 7 | $row = query('SELECT name, role, theme, font FROM users WHERE id=?', [$_SESSION['user']])->fetch(); |
| 8 | if ($row) $prefs = $row; |
| 9 | } |
| 10 | $theme = in_array($prefs['theme'] ?? '', ['system', 'light', 'dark'], true) ? $prefs['theme'] : 'system'; |
| 11 | $font = in_array($prefs['font'] ?? '', ['serif', 'sans', 'rounded'], true) ? $prefs['font'] : 'serif'; |
| 12 | $themeColor = $theme === 'dark' ? '#141210' : '#f4efe6'; |
| 13 | ?> |
| 14 | <!doctype html> |
| 15 | <html lang="nl" data-theme="<?= htmlspecialchars($theme, ENT_QUOTES) ?>" data-font="<?= htmlspecialchars($font, ENT_QUOTES) ?>"> |
| 16 | <head> |
| 17 | <meta charset="utf-8"> |
| 18 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 19 | <meta name="theme-color" content="<?= htmlspecialchars($themeColor, ENT_QUOTES) ?>"> |
| 20 | <title>Verhalenboek</title> |
| 21 | <link rel="icon" href="<?= htmlspecialchars(assetUrl('assets/favicon.svg'), ENT_QUOTES) ?>" type="image/svg+xml"> |
| 22 | <link rel="stylesheet" href="<?= htmlspecialchars(assetUrl('assets/app.css'), ENT_QUOTES) ?>"> |
| 23 | <?php if ($logged): ?><script src="<?= htmlspecialchars(assetUrl('assets/app.js'), ENT_QUOTES) ?>" defer></script><?php endif ?> |
| 24 | </head> |
| 25 | <body> |
| 26 | <?php if (!$logged): ?> |
| 27 | <main class="gate"> |
| 28 | <p class="eyebrow">Elke dag drie verhalen</p> |
| 29 | <h1>Verhalenboek</h1> |
| 30 | <p class="lede">Lees de dagen in volgorde, of verder waar je gebleven was. Inloggen gaat via het account van Tim Falken.</p> |
| 31 | <a class="button primary" href="auth.php">Inloggen</a> |
| 32 | <p class="gate-links"><a href="docs.php">API-documentatie</a></p> |
| 33 | </main> |
| 34 | <?php else: ?> |
| 35 | <header class="topbar"> |
| 36 | <a class="brand" href="#/"><img src="<?= htmlspecialchars(assetUrl('assets/favicon.svg'), ENT_QUOTES) ?>" alt="">Verhalenboek</a> |
| 37 | <nav class="nav" aria-label="Hoofdmenu"> |
| 38 | <a href="#/" data-nav="/">Overzicht</a> |
| 39 | <a href="#/instellingen" data-nav="/instellingen">Instellingen</a> |
| 40 | <?php if (($prefs['role'] ?? '') === 'admin'): ?> |
| 41 | <a href="#/beheer" data-nav="/beheer">Beheer</a> |
| 42 | <a href="#/sleutels" data-nav="/sleutels">Sleutels</a> |
| 43 | <a href="docs.php">API</a> |
| 44 | <?php endif ?> |
| 45 | </nav> |
| 46 | </header> |
| 47 | <main id="app" tabindex="-1"><p class="status">Bezig met laden…</p></main> |
| 48 | <div id="toast" role="status" aria-live="polite"></div> |
| 49 | <div id="read-menu" class="read-menu" role="menu" hidden> |
| 50 | <p data-caption></p> |
| 51 | <button type="button" role="menuitem"></button> |
| 52 | </div> |
| 53 | <?php endif ?> |
| 54 | </body> |
| 55 | </html> |
projects-timfalken-com verhalenboek