Jakub Zych 151f87b4b4 feat: delete an owned deck (API, student app route, MCP tool)
DELETE /api/v1/presentations/{slug}?confirm={slug} for a PAT,
DELETE /_presentations/api/v1/mine/{slug} for the app, and
presentations_delete_deck. Slides go through the model so each writes
its delete revision; image rows and blobs are removed too.
2026-11-07 19:18:21 +01:00

Presentations

The shared presentations plugin for SummerCMS applications: slide decks with speaker notes, timings, sections and special slides, edited and versioned in the admin, imported from HTML, served as JSON to a public link and to the owner's speaker view with a phone remote over realtime, and managed by their owners through a token API and MCP tools.

import _ "git.golem15.com/golem15/sm-presentations-plugin"

Module git.golem15.com/golem15/sm-presentations-plugin, package presentations, plugin ID golem15.presentations.

Overview

The plugin is a compiled SummerCMS plugin. Its init registers it with the framework, so an application loads it by listing it in summer.yaml; summer build then emits the blank import above into the application's plugins.gen.go.

It requires golem15.user: every deck has an owner from the users table, the owner routes run behind jwt.auth or user.api_token, and the deck tools are granted through a frontend permission that golem15.user's group editor shows. The plugin ships no frontend pages: the application serves the deck viewer, the speaker view and the remote, and uses the JSON API and the two middlewares below.

Features

  • Tables. golem15_presentations_presentations (title, slug, owner, context, is_published, target_seconds, public_hash, todo, css, theme), golem15_presentations_slides (top-level slides by position, each with at most one special child slide) and golem15_presentations_slide_revisions (append-only snapshots without foreign keys, so a deleted slide keeps its history). Four gormigrate steps create and extend them.
  • Models. models.Presentation, models.Slide and models.SlideRevision. A slide carries title, CSS class, section label, seconds and the HTML fields body, say (what to say), notes, public comment, sources and public sources, plus a todo note. Every saved change appends a revision tagged edit, import, restore or delete.
  • Admin. A Presentations menu with Presentations, Slides and Revisions, behind the permission golem15.presentations.access_presentations. The presentation form edits the deck fields, its slides, its images and its public link (shown with the current hash, which can be regenerated; Published switches it on); slides have an ordering action and their special child; a revision opens as a preview with a Restore action and cannot be edited or deleted.
  • Sanitizing. Slide HTML is cleaned against an allowlist when it is rendered (classes.Clean); an img keeps only a bare file name of an attached raster image. Deck CSS goes through models.SanitizePresentationCSS (no @import, url(), expression() or script, data and network references). A theme is only a key; the application holds the sheets.
  • Public link. A published deck is served at <public_path>/<slug>-<hash>, where the hash is an unguessable 24-character token stored on the deck. The public JSON carries the slide bodies, public comments and public sources (the sources when a slide has no public ones) and leaves what to say, notes and todos out.
  • Speaker view and phone remote. The owner reads the full deck, speaker fields included. The phone sends whitelisted actions and the speaker tab reports its position; the server validates, re-encodes and publishes both on the deck's realtime channel presentations:remote:<deckId>.<tag>, which only the deck's owner may subscribe to.
  • Cast to a TV. The owner mints a cast ticket for one deck, published or not: signed, bound to the deck and its owner, valid 3 hours and revocable. With the ticket alone a TV receiver reads the deck's public projection and its images (never what to say, notes or todos) and gets realtime tokens that may subscribe to that deck's channel only and never publish.
  • Owner API and MCP tools. With a personal API token the owner lists, creates, edits, publishes, searches and times decks, restores revisions and attaches images; the same routes are exposed as presentations_* MCP tools.
  • Import. presentations:import reads a deck HTML file and a public comments file into a deck. See CLI commands.
  • Phrasebooks. lang/en/lang.yaml and lang/pl/lang.yaml.

Usage

Public and speaker API

Under presentations.APIPrefix (/_presentations/api/v1):

Route Access Answer
GET /public/{slugHash} anonymous, 120 a minute the published deck, {"data": …}
GET /public/{slugHash}/images/{name} anonymous, 300 a minute an attached raster image of a published deck
GET /mine jwt.auth the caller's decks
GET /mine/{slug} jwt.auth the caller's deck with speaker fields and, with a remote key, its remote channel
GET /mine/{slug}/images/{name} jwt.auth an attached image of the caller's deck
DELETE /mine/{slug} jwt.auth, 120 a minute {"data":{"id","slug","title","slides","images"}}: the caller's deck is deleted with its slides (each writes a delete revision) and images; the app asks first
POST /mine/{slug}/remote jwt.auth, 240 a minute per user publishes a remote action
POST /mine/{slug}/remote/state jwt.auth, 300 a minute per user publishes the speaker tab's state
POST /mine/{slug}/cast jwt.auth, 30 a minute per user 201 {"data":{"ticket","expires_at"}}: a 3-hour cast ticket for the caller's deck
DELETE /mine/{slug}/cast jwt.auth, 30 a minute per user; the ticket in X-Cast-Ticket 204: the ticket is revoked
GET /cast/deck the X-Cast-Ticket header, 60 a minute per IP and 30 a minute per ticket the ticket's deck as the public projection, images as bare data-deck-image names
GET /cast/realtime the X-Cast-Ticket header, 60 a minute per IP and 30 a minute per ticket {"data":{"token","channel","channel_token","expires_in"}}: 15-minute Centrifugo tokens for the deck's channel only
GET /cast/images/{name} the X-Cast-Ticket header, 300 a minute an attached raster image of the ticket's deck
POST /uploads/{ticket} the signed ticket one image upload, see below

An unknown, unpublished or foreign deck is 404 {"error":true,"message":"Not found."}, a missing database 503. Public answers carry X-Robots-Tag: noindex, nofollow.

The cast ticket travels only in the X-Cast-Ticket header, never in a URL. Every refused ticket (malformed, forged, expired, revoked, lost on restart, or whose owner no longer owns the deck) is 401 {"error":true,"message":"Invalid or expired cast ticket."} before any database read, and the ticket never authenticates an owner route. The live tickets are kept in the app cache; with the default memory cache a restart drops them all, and the phone mints a new one.

Owner management API

Under presentations.ManagePrefix (/api/v1/presentations), behind user.api_token with the read or write scope:

  • GET "", POST "", GET /{slug}, PUT /{slug}: list, create, show and update the caller's decks.
  • With the frontend permission golem15.presentations.access_presentations as well (60 requests a minute per user): GET /{slug}/slides, PATCH /{slug}, DELETE /{slug}?confirm={slug} (deletes the deck, its slides and images; confirm must repeat the slug or the answer is 422), PATCH /{slug}/slides/{id}, PUT /{slug}/slides, POST /{slug}/publish, POST /{slug}/unpublish, GET /{slug}/search, GET /{slug}/timing, GET /{slug}/revisions, GET /{slug}/revisions/{id}, POST /{slug}/revisions/{id}/restore, GET /{slug}/images, POST /{slug}/images (base64), DELETE /{slug}/images/{file} and POST /{slug}/images/upload-url.

Every route loads only the caller's own decks. upload-url returns a one-time URL, valid 10 minutes and bound to the deck and the user, for a multipart upload of up to 10 MB (jpg, jpeg, png, gif or webp; SVG is refused).

MCP tools

The plugin declares the tools list_decks, show_deck, create_deck, search_deck, timing, update_deck, update_slide, replace_slides, publish, unpublish, list_revisions, show_revision, restore_revision, list_images, attach_image, detach_image and create_image_upload, listed as presentations_* and only to users whose groups grant golem15.presentations.access_presentations.

Middlewares

  • presentations.public-page answers 404 before the application's public deck page when the {slugHash} path value does not name a published deck.
  • presentations.realtime-owner guards the application's realtime connection-token route (after jwt.auth): only a user who owns a deck gets a token.

The plugin registers its realtime authorizer for the presentations namespace through lighthouse; the application picks and mounts the driver.

Configuration

config/config.yaml, under golem15.presentations:

Key Default Meaning
public_path /prezentacje Prefix of public deck links in the admin and in the API answers.
remote_key "" Key of the remote channel tags (SUMMER_GOLEM15__PRESENTATIONS__REMOTE_KEY). Empty uses app.key; with both empty there is no remote channel.
cast_app_id "" The Google Cast receiver App ID of the application's /cast page (SUMMER_GOLEM15__PRESENTATIONS__CAST_APP_ID), sent to the owner as cast_app_id in GET /mine/{slug} when it is 8 uppercase hex characters. Not a secret. Empty: the phone remote shows no Cast button.

Images are stored through the framework's attachments (lagoon/attach) in the configured bucket.

API reference

Identifier Description
presentations.Plugin The golem15.presentations plugin: migrations, models, phrasebooks, admin controllers, permissions, navigation, routes, throttle buckets, middlewares, MCP tools, the realtime authorizer and the presentations:import command.
presentations.APIPrefix /_presentations/api/v1, the public, speaker and remote API.
presentations.ManagePrefix /api/v1/presentations, the owner management API.
models.Presentation, models.Slide, models.SlideRevision The deck, slide and revision models.
models.SanitizePresentationCSS Cleans a deck's CSS.
controllers.PermPresentations The permission golem15.presentations.access_presentations.
controllers.PresentationsController, controllers.SlidesController, controllers.RevisionsController The admin controllers.
api.Handlers, api.New The HTTP handlers and their constructor.
api.RemoteKeyOf The remote channel key of an application.
classes.Parse, classes.ParseTodos, classes.Import Deck HTML parsing, the TODO sidecar and the import itself.
classes.Clean The render-time HTML allowlist.
classes.LoadPublic Loads a published deck by its slug-hash segment.
classes.RemoteKey, classes.OwnsDeck The remote channel key rule and the owner check.
classes.IssueCast, classes.CheckCast, classes.RevokeCast Mint, check and revoke a cast ticket against the allow-list in the app cache.
classes.LoadCast, classes.BuildCast Load and project a ticket's deck for the audience, unpublished decks included.
api.CastTicketHeader X-Cast-Ticket, the header that carries a cast ticket.
console.ImportCommand The presentations:import command.

CLI commands

presentations:import <deck> <comments> --slug SLUG --owner EMAIL [--target SECONDS] [--todos FILE] [--dry-run] [--replace]

  • deck is an HTML file whose slides are <section class="slide"> elements, each after a marker comment such as <!-- 1 -->, or <!-- 1s --> for the special slide of slide 1. data-t holds the seconds and data-sec the section label; aside.notes, aside.speak and aside.srcs become notes, what to say and sources.
  • comments is an HTML file of public comments keyed by the same markers; <!-- 2:srcs --> holds slide 2's public sources.
  • --todos is a YAML sidecar with a presentation note and slide notes keyed by marker.
  • Images the deck names with a relative src are read next to the deck file and attached to the deck.
  • --owner is the email of an existing user. An existing slug is refused unless --replace, which replaces its slides. --dry-run parses and plans, prints the report and writes nothing.

Dependencies

  • SummerCMS modules: backpack, bonfire, bouncer, cabana, cooler, lagoon (with attach), lighthouse, pact, party, phrasebook, surf, wire.
  • Compiled plugin: golem15.user (git.golem15.com/golem15/sm-user-plugin).
  • controllers/api/cast_tokens.go imports lighthouse/centrifugo, the only driver that can sign tokens for a non-user identifier and one channel; it also registers the centrifugo driver name, and selecting it stays the application's realtime.driver choice. With any other driver GET /cast/realtime answers 503.
  • Third-party: gorm.io/gorm, gorm.io/driver/postgres, github.com/go-gormigrate/gormigrate/v2, github.com/jackc/pgx/v5, github.com/microcosm-cc/bluemonday, github.com/goccy/go-yaml, gocloud.dev, golang.org/x/net.

Testing

go vet ./...
go test -short ./...

The import tests that write to Postgres run only with SUMMER_DATABASE__DSN set and skip otherwise.

Description
No description provided
Readme 910 KiB
Languages
Go 96.5%
JavaScript 2.8%
CSS 0.7%