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

+5
View File
@@ -36,3 +36,8 @@ THROTTLE_CREATE_PER_HOUR=10
THROTTLE_RECOVER_PER_HOUR=5
# How often presenter and participant pages poll for updates (ms)
POLL_INTERVAL_MS=2000
# Embedded slides (/e/{key}/{slide}, e.g. Canva): heartbeat interval and timeout until pause (s)
EMBED_HEARTBEAT_SECONDS=5
EMBED_TIMEOUT_SECONDS=20
# CSP frame-ancestors of embed pages, e.g. "https://*.canva.com https://*.iframe.ly" ('*' = any site)
EMBED_FRAME_ANCESTORS=*
@@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
use Migrations\BaseMigration;
/**
* Slides embedded in other presentation software (e.g. Canva) and pausing.
*
* polls.embed_key - secret of the embed URLs /e/{key}/{slide}; may only show,
* activate and pause slides (not the admin token)
* polls.embed_seen_at - last heartbeat of the embedded slide that is live;
* null = slide was chosen in Plenario itself (no timeout)
* polls.paused_slide_id - slide that was live before pausing, → resumes it
*/
class AddEmbedToPolls extends BaseMigration
{
/**
* @return void
*/
public function change(): void
{
$this->table('polls')
->addColumn('embed_key', 'string', ['limit' => 64, 'null' => true, 'default' => null, 'after' => 'join_code'])
->addColumn('embed_seen_at', 'datetime', ['null' => true, 'default' => null, 'after' => 'current_slide_id'])
->addColumn('paused_slide_id', 'integer', ['null' => true, 'default' => null, 'after' => 'embed_seen_at'])
->addIndex(['embed_key'], ['unique' => true])
->update();
}
}
+9
View File
@@ -40,6 +40,15 @@ return [
'recoverPerHour' => (int)env('THROTTLE_RECOVER_PER_HOUR', 5),
],
'pollIntervalMs' => (int)env('POLL_INTERVAL_MS', 2000),
// Slides embedded in other presentation software (/e/{key}/{slide}, e.g. Canva).
'embed' => [
// A visible embedded slide reports every N seconds that it is still on screen ...
'heartbeatSeconds' => (int)env('EMBED_HEARTBEAT_SECONDS', 5),
// ... without a report for this long, the poll is paused (presentation moved on / closed).
'timeoutSeconds' => (int)env('EMBED_TIMEOUT_SECONDS', 20),
// CSP frame-ancestors of the embed pages ('*' = any site; the URL itself is the secret).
'frameAncestors' => (string)env('EMBED_FRAME_ANCESTORS', '*'),
],
],
/*
+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);