Add embeddable slides and pause mode
CI / Deploy / test (push) Successful in 1m4s
CI / Deploy / deploy (push) Skipped

Every slide gets an embed URL /e/{key}/{id} for presentation software
like Canva. The page goes live while it is visible, keeps itself live
with heartbeats and pauses when it disappears; stale embeds are paused
lazily. The embed key is separate from the admin token and only allows
showing, activating, pausing and voting controls of that slide.

Participants see a pause page while no slide is live. The presenter
can pause (P) and resume the paused slide with the arrow keys; the
dashboard has a pause button.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Opus 5.5 committed 2026-11-07 16:26:05 +01:00
1 parent 58145e9753
commit 07a292d109
19 files changed
+1116 -68

No files matched your search

+16
View File
@@ -38,6 +38,20 @@ return function (RouteBuilder $routes): void {
->setPass(['code'])
->setMethods(['POST']);
// --- embedded slides (secret embed key, e.g. Canva) -----------------
// No CSRF check here (see Application::middleware()): runs in third-party iframes
// without cookies, the key in the URL is the authorisation.
$builder->scope('/e/{key}/{id}', function (RouteBuilder $embed): void {
$patterns = ['key' => '[A-Za-z0-9_-]{20,64}', 'id' => '\d+'];
$embed->connect('/', 'Embed::view', ['_name' => 'embed'])->setPatterns($patterns);
$embed->connect('/state', 'Embed::state', ['_name' => 'embed:state'])->setPatterns($patterns);
foreach (['activate', 'heartbeat', 'pause', 'control'] as $action) {
$embed->connect('/' . $action, 'Embed::' . $action, ['_name' => 'embed:' . $action])
->setPatterns($patterns)->setMethods(['POST']);
}
});
// --- admin (secret token) -----------------------------------------
$builder->scope('/admin/{token}', function (RouteBuilder $admin): void {
$token = ['token' => '[A-Za-z0-9_-]{20,64}', 'id' => '\d+'];
@@ -47,6 +61,8 @@ return function (RouteBuilder $routes): void {
->setPatterns($token)->setMethods(['POST']);
$admin->connect('/rotate-token', 'Admin::rotateToken', ['_name' => 'admin:rotate'])
->setPatterns($token)->setMethods(['POST']);
$admin->connect('/rotate-embed-key', 'Admin::rotateEmbedKey', ['_name' => 'admin:rotate-embed'])
->setPatterns($token)->setMethods(['POST']);
$admin->connect('/delete', 'Admin::delete', ['_name' => 'admin:delete'])
->setPatterns($token)->setMethods(['POST']);
$admin->connect('/present', 'Admin::present', ['_name' => 'admin:present'])->setPatterns($token);