feat: Kür-Hub mit Einladungen, Uploads und API
- PHP-App unter hub/ für rinkplanner-hub.programmschmiede.de - MariaDB-Schema, Argon2id, Sessions, CSRF und Ratenbegrenzung - Einladungscodes, Admin-Bereich und Kür-Pakete mit Audiodatei - JSON-API v1 mit Bearer-Tokens für die Godot-App - Deployment und Erstinstallation über tools/deploy_hub.sh - Doku und Credentials-Vorlage ergänzt
This commit is contained in:
parent
e79b477ee0
commit
055a2919c3
38 changed files with 5111 additions and 0 deletions
2
hub/views/.htaccess
Normal file
2
hub/views/.htaccess
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
Require all denied
|
||||
Options -Indexes
|
||||
7
hub/views/_admin_nav.php
Normal file
7
hub/views/_admin_nav.php
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?php /** @var string $active */ ?>
|
||||
<nav class="admin-tabs">
|
||||
<a class="<?= $active === 'invites' ? 'active' : '' ?>" href="<?= e(url('/admin/invites')) ?>">Einladungen</a>
|
||||
<a class="<?= $active === 'users' ? 'active' : '' ?>" href="<?= e(url('/admin/users')) ?>">Benutzer</a>
|
||||
<a class="<?= $active === 'routines' ? 'active' : '' ?>" href="<?= e(url('/admin/routines')) ?>">Küren</a>
|
||||
<a class="<?= $active === 'audit' ? 'active' : '' ?>" href="<?= e(url('/admin/audit')) ?>">Audit-Log</a>
|
||||
</nav>
|
||||
77
hub/views/account.php
Normal file
77
hub/views/account.php
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
<?php /** @var array $tokens */ ?>
|
||||
<?php $user = auth_user(); ?>
|
||||
<section class="page-head">
|
||||
<div>
|
||||
<h1>Konto</h1>
|
||||
<p class="muted"><?= e($user['username']) ?> · <?= e($user['role'] === 'admin' ? 'Administrator' : 'Beta-Nutzer') ?></p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<?php if ($user['must_change_password'] === 1): ?>
|
||||
<div class="flash flash-info">Bitte ein neues Passwort setzen, bevor du den Hub weiter nutzt.</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="columns">
|
||||
<section class="panel">
|
||||
<h2>Passwort ändern</h2>
|
||||
<form method="post" action="<?= e(url('/account/password')) ?>" class="stack">
|
||||
<?= csrf_field() ?>
|
||||
<label>
|
||||
Aktuelles Passwort
|
||||
<input type="password" name="current_password" autocomplete="current-password" required>
|
||||
</label>
|
||||
<label>
|
||||
Neues Passwort
|
||||
<input type="password" name="password" autocomplete="new-password" required>
|
||||
<span class="hint">Mindestens 10 Zeichen.</span>
|
||||
</label>
|
||||
<label>
|
||||
Neues Passwort wiederholen
|
||||
<input type="password" name="password_repeat" autocomplete="new-password" required>
|
||||
</label>
|
||||
<button class="primary" type="submit">Passwort speichern</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section class="panel">
|
||||
<h2>API-Tokens</h2>
|
||||
<p class="muted">Für die Godot-App. Ein Token ersetzt Benutzername und Passwort im Client und lässt sich jederzeit widerrufen.</p>
|
||||
<form method="post" action="<?= e(url('/account/tokens')) ?>" class="inline-form">
|
||||
<?= csrf_field() ?>
|
||||
<input type="text" name="name" maxlength="64" placeholder="Name, z. B. Büro-PC" required>
|
||||
<button type="submit">Token erzeugen</button>
|
||||
</form>
|
||||
|
||||
<?php if ($tokens): ?>
|
||||
<div class="table-wrap">
|
||||
<table class="list compact">
|
||||
<thead>
|
||||
<tr><th>Name</th><th>Prefix</th><th>Erstellt</th><th>Zuletzt</th><th>Status</th><th></th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($tokens as $token): ?>
|
||||
<tr>
|
||||
<td><?= e($token['name']) ?></td>
|
||||
<td><code><?= e($token['prefix']) ?>…</code></td>
|
||||
<td><?= e(fmt_dt($token['created_at'])) ?></td>
|
||||
<td><?= e(fmt_dt($token['last_used_at'])) ?></td>
|
||||
<td><?= $token['revoked_at'] !== null ? 'widerrufen' : 'aktiv' ?></td>
|
||||
<td>
|
||||
<?php if ($token['revoked_at'] === null): ?>
|
||||
<form class="inline" method="post" action="<?= e(url('/account/tokens/revoke')) ?>">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="token_id" value="<?= (int) $token['id'] ?>">
|
||||
<button class="link-button danger" type="submit">widerrufen</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<p class="muted small">Noch kein Token erzeugt.</p>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
</div>
|
||||
34
hub/views/admin_audit.php
Normal file
34
hub/views/admin_audit.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php /** @var array $entries */ ?>
|
||||
<div class="page-head">
|
||||
<div>
|
||||
<h1>Verwaltung</h1>
|
||||
<p class="muted">Die letzten <?= count($entries) ?> Ereignisse.</p>
|
||||
</div>
|
||||
</div>
|
||||
<?php $active = 'audit'; require HUB_ROOT . '/views/_admin_nav.php'; ?>
|
||||
|
||||
<section class="panel">
|
||||
<?php if (!$entries): ?>
|
||||
<p class="muted">Noch keine Einträge.</p>
|
||||
<?php else: ?>
|
||||
<div class="table-wrap">
|
||||
<table class="list compact">
|
||||
<thead>
|
||||
<tr><th>Zeit</th><th>Akteur</th><th>Aktion</th><th>Objekt</th><th>Detail</th><th>IP</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($entries as $entry): ?>
|
||||
<tr>
|
||||
<td><?= e(fmt_dt($entry['created_at'])) ?></td>
|
||||
<td><?= e($entry['actor_name'] ?: '–') ?></td>
|
||||
<td><code><?= e($entry['action']) ?></code></td>
|
||||
<td><?= e(trim(($entry['subject_type'] ?? '') . ' ' . ($entry['subject_id'] ?? ''))) ?: '–' ?></td>
|
||||
<td><?= e($entry['detail'] ?: '–') ?></td>
|
||||
<td><?= e($entry['ip'] ?: '–') ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
83
hub/views/admin_invites.php
Normal file
83
hub/views/admin_invites.php
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
<?php /** @var array $invites */ ?>
|
||||
<div class="page-head">
|
||||
<div>
|
||||
<h1>Verwaltung</h1>
|
||||
<p class="muted">Einladungen für die geschlossene Beta.</p>
|
||||
</div>
|
||||
</div>
|
||||
<?php $active = 'invites'; require HUB_ROOT . '/views/_admin_nav.php'; ?>
|
||||
|
||||
<section class="panel">
|
||||
<h2>Neue Einladung</h2>
|
||||
<p class="muted">Der Code wird nach dem Anlegen genau einmal angezeigt. Er gilt für ein Konto.</p>
|
||||
<form method="post" action="<?= e(url('/admin/invites')) ?>" class="stack">
|
||||
<?= csrf_field() ?>
|
||||
<div class="grid-3">
|
||||
<label>
|
||||
Notiz (intern)
|
||||
<input type="text" name="note" maxlength="190" placeholder="z. B. Verein Nord">
|
||||
</label>
|
||||
<label>
|
||||
E-Mail binden (optional)
|
||||
<input type="email" name="email" maxlength="190">
|
||||
<span class="hint">Nur diese Adresse kann den Code nutzen.</span>
|
||||
</label>
|
||||
<label>
|
||||
Gültig (Tage)
|
||||
<input type="number" name="expires_days" min="0" max="365" value="30">
|
||||
<span class="hint">0 = unbegrenzt.</span>
|
||||
</label>
|
||||
</div>
|
||||
<button class="primary" type="submit">Einladung erzeugen</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section class="panel">
|
||||
<h2>Einladungen</h2>
|
||||
<?php if (!$invites): ?>
|
||||
<p class="muted">Noch keine Einladungen.</p>
|
||||
<?php else: ?>
|
||||
<div class="table-wrap">
|
||||
<table class="list compact">
|
||||
<thead>
|
||||
<tr><th>Erstellt</th><th>Notiz</th><th>E-Mail</th><th>Status</th><th>Von / an</th><th>Gültig bis</th><th></th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($invites as $invite): ?>
|
||||
<?php
|
||||
$status = invite_status($invite);
|
||||
$statusClass = [
|
||||
'offen' => 'open',
|
||||
'eingelöst' => 'used',
|
||||
'abgelaufen' => 'expired',
|
||||
'widerrufen' => 'revoked',
|
||||
][$status] ?? 'expired';
|
||||
?>
|
||||
<tr>
|
||||
<td><?= e(fmt_dt($invite['created_at'])) ?></td>
|
||||
<td><?= e($invite['note'] ?: '–') ?></td>
|
||||
<td><?= e($invite['email'] ?: '–') ?></td>
|
||||
<td><span class="status status-<?= e($statusClass) ?>"><?= e($status) ?></span></td>
|
||||
<td>
|
||||
<?= e($invite['creator_name'] ?: '–') ?>
|
||||
<?php if (!empty($invite['used_name'])): ?>
|
||||
<span class="muted">→ <?= e($invite['used_name']) ?></span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td><?= e(fmt_dt($invite['expires_at'])) ?></td>
|
||||
<td>
|
||||
<?php if ($status === 'offen'): ?>
|
||||
<form class="inline" method="post" action="<?= e(url('/admin/invites/revoke')) ?>">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="invite_id" value="<?= (int) $invite['id'] ?>">
|
||||
<button class="link-button danger" type="submit">widerrufen</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
86
hub/views/admin_routines.php
Normal file
86
hub/views/admin_routines.php
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
<?php /** @var array $items */ ?>
|
||||
<?php /** @var int $total */ ?>
|
||||
<?php /** @var int $page */ ?>
|
||||
<?php /** @var int $pages */ ?>
|
||||
<?php /** @var string $query */ ?>
|
||||
<?php
|
||||
$linkFor = static function (int $targetPage) use ($query): string {
|
||||
$params = [];
|
||||
if ($query !== '') {
|
||||
$params['q'] = $query;
|
||||
}
|
||||
if ($targetPage > 1) {
|
||||
$params['page'] = $targetPage;
|
||||
}
|
||||
return url('/admin/routines') . ($params ? '?' . http_build_query($params) : '');
|
||||
};
|
||||
?>
|
||||
<div class="page-head">
|
||||
<div>
|
||||
<h1>Verwaltung</h1>
|
||||
<p class="muted"><?= (int) $total ?> Küren insgesamt, auch versteckte.</p>
|
||||
</div>
|
||||
</div>
|
||||
<?php $active = 'routines'; require HUB_ROOT . '/views/_admin_nav.php'; ?>
|
||||
|
||||
<div class="toolbar">
|
||||
<form method="get" action="<?= e(url('/admin/routines')) ?>" class="search">
|
||||
<input type="search" name="q" value="<?= e_attr($query) ?>" placeholder="Titel, Skater, Benutzer …">
|
||||
<button type="submit">Suchen</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<?php if (!$items): ?>
|
||||
<div class="empty"><p>Keine Küren gefunden.</p></div>
|
||||
<?php else: ?>
|
||||
<div class="table-wrap">
|
||||
<table class="list compact">
|
||||
<thead>
|
||||
<tr><th>Titel</th><th>Von</th><th>Status</th><th>Rev.</th><th>Aktualisiert</th><th>Downloads</th><th>Aktionen</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($items as $item): ?>
|
||||
<tr>
|
||||
<td><a href="<?= e(url('/routines/' . (int) $item['id'])) ?>"><?= e($item['title']) ?></a></td>
|
||||
<td><?= e($item['owner_username']) ?></td>
|
||||
<td><span class="status status-<?= $item['status'] === 'published' ? 'open' : 'expired' ?>"><?= e($item['status']) ?></span></td>
|
||||
<td><?= $item['revision'] !== null ? (int) $item['revision'] : '–' ?></td>
|
||||
<td><?= e(fmt_dt($item['updated_at'])) ?></td>
|
||||
<td><?= (int) $item['download_count'] ?></td>
|
||||
<td>
|
||||
<div class="row-actions">
|
||||
<form class="inline" method="post" action="<?= e(url('/admin/routines/action')) ?>">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="routine_id" value="<?= (int) $item['id'] ?>">
|
||||
<input type="hidden" name="action" value="<?= $item['status'] === 'published' ? 'hide' : 'publish' ?>">
|
||||
<button class="link-button" type="submit"><?= $item['status'] === 'published' ? 'verstecken' : 'veröffentlichen' ?></button>
|
||||
</form>
|
||||
<details class="danger-zone">
|
||||
<summary>löschen</summary>
|
||||
<form method="post" action="<?= e(url('/admin/routines/action')) ?>" class="stack-tight">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="routine_id" value="<?= (int) $item['id'] ?>">
|
||||
<input type="hidden" name="action" value="delete">
|
||||
<label class="check small">
|
||||
<input type="checkbox" name="confirm" value="1" required>
|
||||
endgültig löschen
|
||||
</label>
|
||||
<button class="link-button danger" type="submit">Löschen bestätigen</button>
|
||||
</form>
|
||||
</details>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<?php if ($pages > 1): ?>
|
||||
<nav class="pagination">
|
||||
<?php if ($page > 1): ?><a href="<?= e($linkFor($page - 1)) ?>">← Zurück</a><?php endif; ?>
|
||||
<span>Seite <?= (int) $page ?> von <?= (int) $pages ?></span>
|
||||
<?php if ($page < $pages): ?><a href="<?= e($linkFor($page + 1)) ?>">Weiter →</a><?php endif; ?>
|
||||
</nav>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
84
hub/views/admin_users.php
Normal file
84
hub/views/admin_users.php
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
<?php /** @var array $users */ ?>
|
||||
<?php $me = auth_user(); ?>
|
||||
<div class="page-head">
|
||||
<div>
|
||||
<h1>Verwaltung</h1>
|
||||
<p class="muted">Beta-Konten verwalten.</p>
|
||||
</div>
|
||||
</div>
|
||||
<?php $active = 'users'; require HUB_ROOT . '/views/_admin_nav.php'; ?>
|
||||
|
||||
<section class="panel">
|
||||
<h2>Benutzer</h2>
|
||||
<div class="table-wrap">
|
||||
<table class="list compact">
|
||||
<thead>
|
||||
<tr><th>Benutzer</th><th>Rolle</th><th>Status</th><th>Küren</th><th>Registriert</th><th>Letzte Anmeldung</th><th>Aktionen</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($users as $user): ?>
|
||||
<tr>
|
||||
<td>
|
||||
<strong><?= e($user['display_name']) ?></strong>
|
||||
<span class="muted">@<?= e($user['username']) ?></span>
|
||||
<?php if (!empty($user['email'])): ?>
|
||||
<div class="muted small"><?= e($user['email']) ?></div>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td><?= $user['role'] === 'admin' ? 'Admin' : 'Nutzer' ?></td>
|
||||
<td>
|
||||
<span class="status status-<?= $user['status'] === 'active' ? 'open' : 'expired' ?>">
|
||||
<?= $user['status'] === 'active' ? 'aktiv' : 'gesperrt' ?>
|
||||
</span>
|
||||
</td>
|
||||
<td><?= (int) $user['routine_count'] ?></td>
|
||||
<td><?= e(fmt_dt($user['created_at'])) ?></td>
|
||||
<td><?= e(fmt_dt($user['last_login_at'])) ?></td>
|
||||
<td>
|
||||
<?php if ((int) $user['id'] === (int) $me['id']): ?>
|
||||
<span class="muted small">eigenes Konto</span>
|
||||
<?php else: ?>
|
||||
<div class="row-actions">
|
||||
<?php if ($user['status'] === 'active'): ?>
|
||||
<form class="inline" method="post" action="<?= e(url('/admin/users/action')) ?>">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="user_id" value="<?= (int) $user['id'] ?>">
|
||||
<input type="hidden" name="action" value="disable">
|
||||
<button class="link-button danger" type="submit">sperren</button>
|
||||
</form>
|
||||
<?php else: ?>
|
||||
<form class="inline" method="post" action="<?= e(url('/admin/users/action')) ?>">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="user_id" value="<?= (int) $user['id'] ?>">
|
||||
<input type="hidden" name="action" value="enable">
|
||||
<button class="link-button" type="submit">entsperren</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
<form class="inline" method="post" action="<?= e(url('/admin/users/action')) ?>">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="user_id" value="<?= (int) $user['id'] ?>">
|
||||
<input type="hidden" name="action" value="reset">
|
||||
<button class="link-button" type="submit">Passwort zurücksetzen</button>
|
||||
</form>
|
||||
<details class="danger-zone">
|
||||
<summary>löschen</summary>
|
||||
<form method="post" action="<?= e(url('/admin/users/action')) ?>" class="stack-tight">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="user_id" value="<?= (int) $user['id'] ?>">
|
||||
<input type="hidden" name="action" value="delete">
|
||||
<label class="check small">
|
||||
<input type="checkbox" name="confirm" value="1" required>
|
||||
mit allen Küren löschen
|
||||
</label>
|
||||
<button class="link-button danger" type="submit">Löschen bestätigen</button>
|
||||
</form>
|
||||
</details>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
110
hub/views/dashboard.php
Normal file
110
hub/views/dashboard.php
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
<?php /** @var array $items */ ?>
|
||||
<?php /** @var int $total */ ?>
|
||||
<?php /** @var int $page */ ?>
|
||||
<?php /** @var int $pages */ ?>
|
||||
<?php /** @var string $query */ ?>
|
||||
<?php /** @var bool $mine */ ?>
|
||||
<?php
|
||||
$linkFor = static function (int $targetPage) use ($query, $mine): string {
|
||||
$params = [];
|
||||
if ($query !== '') {
|
||||
$params['q'] = $query;
|
||||
}
|
||||
if ($mine) {
|
||||
$params['mine'] = '1';
|
||||
}
|
||||
if ($targetPage > 1) {
|
||||
$params['page'] = $targetPage;
|
||||
}
|
||||
return url('/') . ($params ? '?' . http_build_query($params) : '');
|
||||
};
|
||||
?>
|
||||
<div class="page-head">
|
||||
<div>
|
||||
<h1>Küren</h1>
|
||||
<p class="muted"><?= (int) $total ?> <?= $total === 1 ? 'Kür' : 'Küren' ?> im Hub<?= $mine ? ' (nur deine)' : '' ?>.</p>
|
||||
</div>
|
||||
<a class="button primary" href="<?= e(url('/upload')) ?>">Kür hochladen</a>
|
||||
</div>
|
||||
|
||||
<div class="toolbar">
|
||||
<form method="get" action="<?= e(url('/')) ?>" class="search">
|
||||
<input type="search" name="q" value="<?= e_attr($query) ?>" placeholder="Titel, Skater, Musik, Benutzer …">
|
||||
<?php if ($mine): ?><input type="hidden" name="mine" value="1"><?php endif; ?>
|
||||
<button type="submit">Suchen</button>
|
||||
</form>
|
||||
<div class="tabs">
|
||||
<a class="<?= $mine ? '' : 'active' ?>" href="<?= e(url('/')) ?>">Alle</a>
|
||||
<a class="<?= $mine ? 'active' : '' ?>" href="<?= e(url('/?mine=1')) ?>">Meine Küren</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (!$items): ?>
|
||||
<div class="empty">
|
||||
<p>Keine Küren gefunden.</p>
|
||||
<?php if ($query !== ''): ?>
|
||||
<p class="muted">Suche zurücksetzen oder <a href="<?= e(url('/upload')) ?>">selbst eine Kür hochladen</a>.</p>
|
||||
<?php else: ?>
|
||||
<p class="muted">Der Hub ist noch leer. <a href="<?= e(url('/upload')) ?>">Erste Kür hochladen</a>.</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="table-wrap">
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Titel</th>
|
||||
<th>Skater</th>
|
||||
<th>Musik</th>
|
||||
<th>Rev.</th>
|
||||
<th>Größe</th>
|
||||
<th>Aktualisiert</th>
|
||||
<th>Von</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($items as $item): ?>
|
||||
<tr>
|
||||
<td>
|
||||
<a class="title-link" href="<?= e(url('/routines/' . (int) $item['id'])) ?>"><?= e($item['title']) ?></a>
|
||||
<?php if ($item['status'] !== 'published'): ?>
|
||||
<span class="badge">versteckt</span>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($item['category'])): ?>
|
||||
<span class="badge badge-soft"><?= e($item['category']) ?></span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td><?= e($item['skater_name'] ?? '–') ?></td>
|
||||
<td>
|
||||
<?= e($item['music_title'] ?: ($item['audio_original_name'] ?? '–')) ?>
|
||||
<?php if (!empty($item['music_artist'])): ?>
|
||||
<span class="muted">· <?= e($item['music_artist']) ?></span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td><?= $item['revision'] !== null ? (int) $item['revision'] : '–' ?></td>
|
||||
<td>
|
||||
<?= e(human_bytes((int) ($item['routine_bytes'] ?? 0))) ?>
|
||||
<?php if (!empty($item['audio_bytes'])): ?>
|
||||
<span class="muted">+ <?= e(human_bytes((int) $item['audio_bytes'])) ?></span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td><?= e(fmt_dt($item['updated_at'])) ?></td>
|
||||
<td><?= e($item['owner_display_name'] ?: $item['owner_username']) ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<?php if ($pages > 1): ?>
|
||||
<nav class="pagination">
|
||||
<?php if ($page > 1): ?>
|
||||
<a href="<?= e($linkFor($page - 1)) ?>">← Zurück</a>
|
||||
<?php endif; ?>
|
||||
<span>Seite <?= (int) $page ?> von <?= (int) $pages ?></span>
|
||||
<?php if ($page < $pages): ?>
|
||||
<a href="<?= e($linkFor($page + 1)) ?>">Weiter →</a>
|
||||
<?php endif; ?>
|
||||
</nav>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
7
hub/views/error.php
Normal file
7
hub/views/error.php
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?php /** @var int $status */ ?>
|
||||
<?php /** @var string $message */ ?>
|
||||
<section class="auth-card">
|
||||
<p class="eyebrow">Fehler <?= (int) $status ?></p>
|
||||
<h1><?= e($message) ?></h1>
|
||||
<p class="muted">Zurück zur <a href="<?= e(url('/')) ?>">Küren-Übersicht</a>.</p>
|
||||
</section>
|
||||
65
hub/views/layout.php
Normal file
65
hub/views/layout.php
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
/** @var string $title */
|
||||
/** @var string $content */
|
||||
/** @var array|null $user */
|
||||
$flashes = flash_pull();
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title><?= e($title) ?> · Rinkplanner-Hub</title>
|
||||
<link rel="stylesheet" href="<?= e(url('/assets/hub.css')) ?>">
|
||||
</head>
|
||||
<body>
|
||||
<header class="topbar">
|
||||
<a class="brand" href="<?= e(url('/')) ?>">
|
||||
<span class="brand-mark">R</span>
|
||||
<span>Rinkplanner <strong>Hub</strong></span>
|
||||
</a>
|
||||
<nav class="nav">
|
||||
<?php if ($user !== null): ?>
|
||||
<a href="<?= e(url('/')) ?>">Küren</a>
|
||||
<a href="<?= e(url('/upload')) ?>">Hochladen</a>
|
||||
<a href="<?= e(url('/account')) ?>"><?= e($user['display_name']) ?></a>
|
||||
<?php if (($user['role'] ?? '') === 'admin'): ?>
|
||||
<a class="nav-admin" href="<?= e(url('/admin/invites')) ?>">Verwaltung</a>
|
||||
<?php endif; ?>
|
||||
<form class="inline" method="post" action="<?= e(url('/logout')) ?>">
|
||||
<?= csrf_field() ?>
|
||||
<button class="link-button" type="submit">Abmelden</button>
|
||||
</form>
|
||||
<?php else: ?>
|
||||
<a href="<?= e(url('/login')) ?>">Anmelden</a>
|
||||
<?php endif; ?>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="page">
|
||||
<?php if ($flashes): ?>
|
||||
<div class="flashes">
|
||||
<?php foreach ($flashes as $flash): ?>
|
||||
<?php if (($flash['type'] ?? '') === 'secret'): ?>
|
||||
<div class="flash flash-secret">
|
||||
<strong><?= e($flash['label'] ?? 'Geheimnis') ?></strong>
|
||||
<code><?= e($flash['value'] ?? '') ?></code>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="flash flash-<?= e($flash['type'] ?? 'info') ?>">
|
||||
<?= e($flash['message'] ?? '') ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?= $content ?>
|
||||
</main>
|
||||
|
||||
<footer class="footer">
|
||||
<span>Geschlossene Beta · Rinkplanner-Hub</span>
|
||||
<a href="https://rinkplanner.programmschmiede.de/">Zur Rinkplanner-Seite</a>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
31
hub/views/login.php
Normal file
31
hub/views/login.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php /** @var string $error */ ?>
|
||||
<?php /** @var string $login */ ?>
|
||||
<?php /** @var string $next */ ?>
|
||||
<section class="auth-card">
|
||||
<h1>Anmelden</h1>
|
||||
<p class="muted">Der Kür-Hub ist in einer geschlossenen Beta. Zugang gibt es per Einladungscode.</p>
|
||||
|
||||
<?php if ($error !== ''): ?>
|
||||
<div class="flash flash-error"><?= e($error) ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<form method="post" action="<?= e(url('/login')) ?>" class="stack">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="next" value="<?= e_attr($next) ?>">
|
||||
<label>
|
||||
Benutzername oder E-Mail
|
||||
<input type="text" name="login" value="<?= e_attr($login) ?>" autocomplete="username" required autofocus>
|
||||
</label>
|
||||
<label>
|
||||
Passwort
|
||||
<input type="password" name="password" autocomplete="current-password" required>
|
||||
</label>
|
||||
<label class="check">
|
||||
<input type="checkbox" name="remember" value="1">
|
||||
Angemeldet bleiben (30 Tage)
|
||||
</label>
|
||||
<button class="primary" type="submit">Anmelden</button>
|
||||
</form>
|
||||
|
||||
<p class="muted small">Noch keinen Zugang? Ein Beta-Code kommt von der Hub-Administration.</p>
|
||||
</section>
|
||||
62
hub/views/register.php
Normal file
62
hub/views/register.php
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
<?php /** @var array|null $invite */ ?>
|
||||
<?php /** @var string $code */ ?>
|
||||
<?php /** @var array $errors */ ?>
|
||||
<?php /** @var array $input */ ?>
|
||||
<section class="auth-card wide">
|
||||
<h1>Beta-Zugang einlösen</h1>
|
||||
<p class="muted">Ein Einladungscode legt genau ein Konto an. Der Code verliert danach seine Gültigkeit.</p>
|
||||
|
||||
<?php if ($errors): ?>
|
||||
<div class="flash flash-error">
|
||||
<ul class="plain">
|
||||
<?php foreach ($errors as $error): ?>
|
||||
<li><?= e($error) ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<form method="post" action="<?= e(url('/register')) ?>" class="stack">
|
||||
<?= csrf_field() ?>
|
||||
<label>
|
||||
Einladungscode
|
||||
<input type="text" name="code" value="<?= e_attr($code) ?>" placeholder="RHUB-XXXX-XXXX-XXXX-XXXX" required>
|
||||
</label>
|
||||
<div class="grid-2">
|
||||
<label>
|
||||
Benutzername
|
||||
<input type="text" name="username" value="<?= e_attr($input['username']) ?>" autocomplete="username" required>
|
||||
<span class="hint">3–32 Zeichen, nur Kleinbuchstaben, Ziffern, Punkt, Bindestrich, Unterstrich.</span>
|
||||
</label>
|
||||
<label>
|
||||
Anzeigename
|
||||
<input type="text" name="display_name" value="<?= e_attr($input['display_name']) ?>" maxlength="64">
|
||||
</label>
|
||||
</div>
|
||||
<label>
|
||||
E-Mail (optional)
|
||||
<input type="email" name="email" value="<?= e_attr($input['email']) ?>" autocomplete="email"<?= $invite !== null && !empty($invite['email']) ? ' readonly' : '' ?>>
|
||||
<?php if ($invite !== null && !empty($invite['email'])): ?>
|
||||
<span class="hint">Diese Einladung ist an <?= e($invite['email']) ?> gebunden.</span>
|
||||
<?php endif; ?>
|
||||
</label>
|
||||
<div class="grid-2">
|
||||
<label>
|
||||
Passwort
|
||||
<input type="password" name="password" autocomplete="new-password" required>
|
||||
<span class="hint">Mindestens 10 Zeichen.</span>
|
||||
</label>
|
||||
<label>
|
||||
Passwort wiederholen
|
||||
<input type="password" name="password_repeat" autocomplete="new-password" required>
|
||||
</label>
|
||||
</div>
|
||||
<label class="check">
|
||||
<input type="checkbox" name="rights" value="1" required>
|
||||
Ich akzeptiere die Beta-Regeln und teile keine Inhalte, an denen ich keine Rechte habe.
|
||||
</label>
|
||||
<button class="primary" type="submit">Konto anlegen</button>
|
||||
</form>
|
||||
|
||||
<p class="muted small">Schon ein Konto? <a href="<?= e(url('/login')) ?>">Anmelden</a></p>
|
||||
</section>
|
||||
93
hub/views/routine.php
Normal file
93
hub/views/routine.php
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
<?php /** @var array $routine */ ?>
|
||||
<?php /** @var bool $can_edit */ ?>
|
||||
<?php /** @var bool $is_admin */ ?>
|
||||
<?php $audioName = $routine['audio_original_name'] ?? ''; ?>
|
||||
<article class="detail">
|
||||
<div class="page-head">
|
||||
<div>
|
||||
<p class="eyebrow"><a href="<?= e(url('/')) ?>">Küren</a> / Kür</p>
|
||||
<h1><?= e($routine['title']) ?></h1>
|
||||
<p class="muted">
|
||||
<?= e($routine['owner_display_name'] ?: $routine['owner_username']) ?>
|
||||
· Revision <?= (int) ($routine['revision'] ?? 0) ?>
|
||||
· <?= e(fmt_dt($routine['updated_at'])) ?>
|
||||
<?php if ($routine['status'] !== 'published'): ?>
|
||||
· <span class="badge">versteckt</span>
|
||||
<?php endif; ?>
|
||||
</p>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<?php if (!empty($routine['routine_path'])): ?>
|
||||
<a class="button primary" href="<?= e(url('/routines/' . (int) $routine['id'] . '/download')) ?>">Kür herunterladen</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($audioName !== ''): ?>
|
||||
<a class="button" href="<?= e(url('/routines/' . (int) $routine['id'] . '/audio')) ?>">Musik herunterladen</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($can_edit): ?>
|
||||
<div class="owner-bar">
|
||||
<span class="muted">Du kannst diese Kür verwalten.</span>
|
||||
<a class="button small" href="<?= e(url('/routines/' . (int) $routine['id'] . '/revise')) ?>">Neue Revision hochladen</a>
|
||||
<?php if ($routine['status'] === 'published'): ?>
|
||||
<form class="inline" method="post" action="<?= e(url('/routines/' . (int) $routine['id'] . '/hide')) ?>">
|
||||
<?= csrf_field() ?>
|
||||
<button class="button small danger-ghost" type="submit">Aus dem Hub nehmen</button>
|
||||
</form>
|
||||
<?php else: ?>
|
||||
<form class="inline" method="post" action="<?= e(url('/routines/' . (int) $routine['id'] . '/publish')) ?>">
|
||||
<?= csrf_field() ?>
|
||||
<button class="button small" type="submit">Wieder veröffentlichen</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
<?php if ($is_admin): ?>
|
||||
<a class="button small danger-ghost" href="<?= e(url('/admin/routines?q=' . rawurlencode($routine['title']))) ?>">In der Verwaltung öffnen</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($routine['description'])): ?>
|
||||
<section class="panel">
|
||||
<h2>Beschreibung</h2>
|
||||
<p class="preline"><?= e($routine['description']) ?></p>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($audioName !== ''): ?>
|
||||
<section class="panel">
|
||||
<h2>Musik</h2>
|
||||
<audio controls preload="none" src="<?= e(url('/routines/' . (int) $routine['id'] . '/audio')) ?>"></audio>
|
||||
<p class="muted small"><?= e($audioName) ?> · <?= e(human_bytes((int) ($routine['audio_bytes'] ?? 0))) ?></p>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
<section class="panel">
|
||||
<h2>Details</h2>
|
||||
<dl class="facts">
|
||||
<div><dt>Skater</dt><dd><?= e($routine['skater_name'] ?: '–') ?></dd></div>
|
||||
<div><dt>Kategorie</dt><dd><?= e($routine['category'] ?: '–') ?></dd></div>
|
||||
<div><dt>Musiktitel</dt><dd><?= e($routine['music_title'] ?: '–') ?></dd></div>
|
||||
<div><dt>Musik</dt><dd><?= e($routine['music_artist'] ?: '–') ?></dd></div>
|
||||
<div><dt>Kür-Datei</dt><dd><?= e($routine['routine_original_name'] ?? '–') ?> · <?= e(human_bytes((int) ($routine['routine_bytes'] ?? 0))) ?></dd></div>
|
||||
<div><dt>Audio-Datei</dt><dd><?= e($audioName !== '' ? $audioName . ' · ' . human_bytes((int) ($routine['audio_bytes'] ?? 0)) : '–') ?></dd></div>
|
||||
<div><dt>Downloads</dt><dd><?= (int) $routine['download_count'] ?></dd></div>
|
||||
<div><dt>Eingestellt</dt><dd><?= e(fmt_dt($routine['created_at'])) ?></dd></div>
|
||||
</dl>
|
||||
</section>
|
||||
|
||||
<section class="panel">
|
||||
<h2>Prüfsummen</h2>
|
||||
<div class="hash">
|
||||
<span>Kür</span>
|
||||
<code><?= e($routine['routine_sha256'] ?? '–') ?></code>
|
||||
</div>
|
||||
<?php if ($audioName !== ''): ?>
|
||||
<div class="hash">
|
||||
<span>Musik</span>
|
||||
<code><?= e($routine['audio_sha256'] ?? '–') ?></code>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<p class="muted small">Beim Download prüfen, ob die SHA-256-Summe zur Kür passt.</p>
|
||||
</section>
|
||||
</article>
|
||||
66
hub/views/upload.php
Normal file
66
hub/views/upload.php
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
<?php /** @var array $errors */ ?>
|
||||
<?php /** @var array $input */ ?>
|
||||
<?php /** @var array|null $routine */ ?>
|
||||
<?php $isRevision = $routine !== null; ?>
|
||||
<section class="auth-card wide">
|
||||
<h1><?= $isRevision ? 'Neue Revision' : 'Kür hochladen' ?></h1>
|
||||
<?php if ($isRevision): ?>
|
||||
<p class="muted">Neue Fassung von „<?= e($routine['title']) ?>“. Die bisherige Revision bleibt erhalten.</p>
|
||||
<?php else: ?>
|
||||
<p class="muted">Lade die Kür-JSON und – falls die Kür Musik nutzt – die zugehörige Audiodatei hoch. Beide gehören als Paket zusammen.</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($errors): ?>
|
||||
<div class="flash flash-error">
|
||||
<ul class="plain">
|
||||
<?php foreach ($errors as $error): ?>
|
||||
<li><?= e($error) ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<form method="post" enctype="multipart/form-data"
|
||||
action="<?= e(url($isRevision ? '/routines/' . (int) $routine['id'] . '/revise' : '/upload')) ?>"
|
||||
class="stack">
|
||||
<?= csrf_field() ?>
|
||||
<div class="grid-2">
|
||||
<label>
|
||||
Kür-Datei (.json)
|
||||
<input type="file" name="routine" accept=".json,application/json" required>
|
||||
<span class="hint">Aus Rinkplanner gespeicherte Kür, max. <?= e(human_bytes((int) config('app.max_routine_bytes', 8 * 1024 * 1024))) ?>.</span>
|
||||
</label>
|
||||
<label>
|
||||
Musikdatei (MP3/OGG/WAV/M4A/AAC)
|
||||
<input type="file" name="audio" accept=".mp3,.ogg,.wav,.m4a,.aac,audio/*">
|
||||
<span class="hint">Dateiname muss exakt dem Feld „music_file“ der Kür entsprechen.</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<label>
|
||||
Beschreibung (optional)
|
||||
<textarea name="description" rows="4" maxlength="2000"><?= e($input['description']) ?></textarea>
|
||||
</label>
|
||||
|
||||
<div class="grid-2">
|
||||
<label>
|
||||
Musiktitel (optional)
|
||||
<input type="text" name="music_title" maxlength="190" value="<?= e_attr($input['music_title']) ?>">
|
||||
</label>
|
||||
<label>
|
||||
Interpret (optional)
|
||||
<input type="text" name="music_artist" maxlength="190" value="<?= e_attr($input['music_artist']) ?>">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<label class="check">
|
||||
<input type="checkbox" name="rights" value="1" required>
|
||||
Ich habe die Rechte an Kür und Musik und darf sie im geschlossenen Beta-Hub teilen.
|
||||
</label>
|
||||
|
||||
<div class="actions">
|
||||
<button class="primary" type="submit"><?= $isRevision ? 'Revision veröffentlichen' : 'Kür veröffentlichen' ?></button>
|
||||
<a class="button" href="<?= e(url($isRevision ? '/routines/' . (int) $routine['id'] : '/')) ?>">Abbrechen</a>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
Loading…
Add table
Add a link
Reference in a new issue