Presenter: the HalfStack window, drawn by the server, never scrolling
GET /p/{session}/notes serves the presenter window for a session with
a position (presenter_window.go, presenter.html, presenter.css): the
mockup's header, Now, Next and Notes on a 12x12 grid read from the
slides-presenter cookie, live slides at their step behind the font
gate, notes split at (Press.) with the current part bright. Forms work
with scripts off, ?slide=N&step=k draws that state and ?pick=1 is the
picker; a press from the picker lands on the window. Legacy sessions
keep the old presenter view. present.js ticks the timer and leaves a
stale ?slide/&step when the talk moves.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
18 files changed,
+2,043
−44
internal/slides/credits/assets.json+1 −1internal/slides/icons/icons.go+5 −0internal/slides/locales/en.toml+31 −0internal/slides/presentation.go+14 −6internal/slides/presenter_window.go+508 −0internal/slides/presenting_position.go+5 −2internal/slides/render.go+5 −2internal/slides/static/present.js+25 −0internal/slides/static/presenter.css+659 −0internal/slides/templates/presenter.html+125 −0internal/slides/templates/presenter_pick.html+43 −0internal/slidestest/fontgate_test.go+5 −4internal/slidestest/fonts_browser_test.go+62 −22internal/slidestest/leaving_browser_test.go+1 −1internal/slidestest/present_steps_test.go+20 −0internal/slidestest/present_test.go+31 −6internal/slidestest/presenter_window_browser_test.go+124 −0internal/slidestest/presenter_window_test.go+379 −0
diff --git a/internal/slides/credits/assets.json b/internal/slides/credits/assets.json| index 92618b6..eedf8e8 100644 |
| --- a/internal/slides/credits/assets.json |
| +++ b/internal/slides/credits/assets.json |
| @@ -68,7 +68,7 @@ |
| "internal/slides/static/fonts/LiberationSerif-Regular.woff2": "922f544d0eabdf45ecd389b3bb35367e670b736e40851d01e53c150352c012f2", |
| "internal/slides/static/fontsgate.971e476eab8b8588.js": "971e476eab8b8588be520ac38eb823ab19beb2567db734555a7edc40d58567b2", |
| "internal/slides/static/fontshold.876f3d8d396da42f.js": "876f3d8d396da42f81954539f30b7200edfcde719d2920504707822f176a36ab", |
| - "internal/slides/static/present.js": "40314fa19cd2a822fc860f69190a4571c55dc2097e1104024ebf78ef60ae746d", |
| + "internal/slides/static/present.js": "a5a6802d7f40986c3692a16029f554d50ec6a14e0168a362697ce1313f964de4", |
| "internal/slides/static/rastrillo.js": "13a8ca6fa9ac25833f6485ab50a521dff7bd811372025dc5141b96522b60098b", |
| "internal/slides/static/select.js": "e231bad4b964464addfacd52d2260d4bdc0a02938fc033a25fdd9cbeb3671be1", |
| "internal/slides/static/shell.js": "bdc4d635fb8f14ef7089f7f692290baea645b13543be36328e7667fe8aed2caf", |
diff --git a/internal/slides/icons/icons.go b/internal/slides/icons/icons.go| index f004132..49333cc 100644 |
| --- a/internal/slides/icons/icons.go |
| +++ b/internal/slides/icons/icons.go |
| @@ -48,6 +48,11 @@ var icons = map[string]template.HTML{ |
| "monitor-smartphone": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8"/><path d="M10 19v-3.96 3.15"/><path d="M7 19h5"/><rect width="6" height="10" x="16" y="12" rx="2"/></svg>`, |
| "notebook-pen": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4"/><path d="M2 6h4"/><path d="M2 10h4"/><path d="M2 14h4"/><path d="M2 18h4"/><path d="M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z"/></svg>`, |
| "smartphone": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><rect width="14" height="20" x="5" y="2" rx="2" ry="2"/><path d="M12 18h.01"/></svg>`, |
| + "arrow-right": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="M5 12h14"/><path d="m12 5 7 7-7 7"/></svg>`, |
| + "shrink": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="m15 15 6 6m-6-6v4.8m0-4.8h4.8"/><path d="M9 19.8V15m0 0H4.2M9 15l-6 6"/><path d="M15 4.2V9m0 0h4.8M15 9l6-6"/><path d="M9 4.2V9m0 0H4.2M9 9 3 3"/></svg>`, |
| + "move-vertical": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="M12 2v20"/><path d="m8 18 4 4 4-4"/><path d="m8 6 4-4 4 4"/></svg>`, |
| + "a-arrow-down": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="m14 12 4 4 4-4"/><path d="M18 16V7"/><path d="m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16"/><path d="M3.304 13h6.392"/></svg>`, |
| + "a-arrow-up": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="m14 11 4-4 4 4"/><path d="M18 16V7"/><path d="m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16"/><path d="M3.304 13h6.392"/></svg>`, |
| } |
| // Icon renders one icon by its Lucide slug. An unknown slug renders |
diff --git a/internal/slides/locales/en.toml b/internal/slides/locales/en.toml| index 531135b..9c6f6b2 100644 |
| --- a/internal/slides/locales/en.toml |
| +++ b/internal/slides/locales/en.toml |
| @@ -672,6 +672,37 @@ slides.present.press.next = "Next" |
| slides.present.press.back = "Back" |
| slides.present.step.count = "step {n} of {total}" |
| +# The presenter window (spec §5): its header, the ⋯ menu, what comes |
| +# next, the notes tools, and the scriptless picker. The mode is the |
| +# short or the full version of the talk; BLACK says the room sees |
| +# nothing. |
| +slides.present.pick.open = "Go to a slide" |
| +slides.present.pick.title = "Go to a slide" |
| +slides.present.pick.count = "{total} slides" |
| +slides.present.pick.full = "full version only" |
| +slides.present.mode.core = "Short" |
| +slides.present.mode.full = "Full" |
| +slides.present.black = "BLACK" |
| +slides.present.timer.reset = "Click to reset the timer" |
| +slides.present.more = "More" |
| +slides.present.menu.pair = "Pair a phone as a remote…" |
| +slides.present.menu.window = "Open the slide window" |
| +slides.present.menu.full = "Switch to the full version" |
| +slides.present.menu.core = "Switch to the short version" |
| +slides.present.menu.arrange = "Arrange this window…" |
| +slides.present.menu.back = "Back to the deck" |
| +slides.present.menu.end = "End presenting" |
| +slides.present.next.step = "Next step" |
| +slides.present.next.slide = "Next slide" |
| +slides.present.next.end = "End of the talk" |
| +slides.present.notes.tools = "Notes" |
| +slides.present.notes.fit = "Fit the notes to the panel" |
| +slides.present.notes.scroll = "Scroll the notes" |
| +slides.present.notes.smaller = "Smaller notes" |
| +slides.present.notes.larger = "Larger notes" |
| +slides.present.empty.title = "Nothing to present" |
| +slides.present.empty.body = "Every slide in this deck is parked, or there are none yet. Unpark a slide in the editor to present it." |
| + |
| # A session that is over — ended, or past its twelve hours. A 410, and |
| # worded as one: the talk finished, which is a different thing from an |
| # address that was never real. |
diff --git a/internal/slides/presentation.go b/internal/slides/presentation.go| index c0a26fd..51a1131 100644 |
| --- a/internal/slides/presentation.go |
| +++ b/internal/slides/presentation.go |
| @@ -830,21 +830,29 @@ func clampSlide(index, count int) int { |
| // presenterNotes is the presenter view: what is on screen, what is |
| // next, the notes, the clock, and — once — how to pair a phone. |
| // |
| -// Who may read it: the presenter's own signed-in session, or whoever |
| -// holds the remote token. Never the session sqid alone, which is the |
| -// address that goes on a projector. |
| +// Who may read it: whoever may drive the talk (mayDrive), the |
| +// presenter's own signed-in session or whoever holds the remote token. |
| +// Never the session sqid alone, which is the address that goes on a |
| +// projector. |
| +// |
| +// A session with a position gets the presenter window |
| +// (presenter_window.go); one begun before keeps this view. |
| func (a *app) presenterNotes(w http.ResponseWriter, r *http.Request) { |
| p, ok := a.presentationFor(w, r) |
| if !ok { |
| return |
| } |
| token := r.URL.Query().Get("t") |
| - holder := remoteTokenOK(p, token) |
| - presenter := p.Actor != "" && a.presenterActor(r) == p.Actor |
| - if !holder && !presenter { |
| + if !a.mayDrive(r, p, token) { |
| a.notFound(w, r) |
| return |
| } |
| + if p.Positional { |
| + a.presenterWindow(w, r, p, token) |
| + return |
| + } |
| + holder := remoteTokenOK(p, token) |
| + presenter := p.Actor != "" && a.presenterActor(r) == p.Actor |
| d, ok := a.deckOf(w, r, p) |
| if !ok { |
| return |
diff --git a/internal/slides/presenter_window.go b/internal/slides/presenter_window.go| new file mode 100644 |
| index 0000000..3a060f6 |
| --- /dev/null |
| +++ b/internal/slides/presenter_window.go |
| @@ -0,0 +1,508 @@ |
| +// presenter_window.go is the presenter window (spec §5), drawn by the |
| +// server: GET /p/{session}/notes for a session with a position. |
| +// |
| +// The layout is Paul's mockup (docs/superpowers/specs/2026-11-17- |
| +// presenter-mockup.html), its ids become presenter-* attributes, and |
| +// static/presenter.css is its stylesheet. A header (where the talk is, |
| +// the step count, the mode, BLACK, the timer, the clock and the ⋯ |
| +// menu), then three panels on a 12×12 grid: the slide on screen now, |
| +// what comes next, and the notes. |
| +// |
| +// Everything here works with scripts off (S20): each control is a form |
| +// that posts a press and redirects back (presenting_position.go's |
| +// pressLanding), ?slide=N&step=k draws that state, and ?pick=1 is the |
| +// slide picker as a page of one-button forms (P4). The slides are drawn |
| +// live, at their step, so the page takes the font gate. |
| +// |
| +// Sessions begun before positions keep presentation.go's presenter |
| +// view, whose slides are pictures. |
| +package slides |
| + |
| +import ( |
| + "fmt" |
| + "html/template" |
| + "net/http" |
| + "net/url" |
| + "strconv" |
| + "strings" |
| + "time" |
| + |
| + "amadan.net/oficina/slides/internal/slides/deck" |
| + slidehtml "amadan.net/oficina/slides/internal/slides/render" |
| + "amadan.net/rastrillo/rastrillo" |
| +) |
| + |
| +// presenterPrefsCookie holds how a person likes the window: the notes |
| +// fitted or scrolling, their text size, and where the three panels sit. |
| +// It is read here; the window's script writes it (Tasks 11 and 13), as |
| +// "fit.24.0,0,7,8;0,8,7,4;7,0,5,12" percent-encoded, because a cookie |
| +// value cannot hold a ";". Path /p, a year, SameSite=Lax. |
| +const presenterPrefsCookie = "slides-presenter" |
| + |
| +// presenterGrid is the panels' grid: 12 columns by 12 rows. |
| +const presenterGrid = 12 |
| + |
| +// panel is one panel's place on the grid, in cells from the top left. |
| +type panel struct{ X, Y, W, H int } |
| + |
| +// presenterPrefs is the cookie, read. |
| +type presenterPrefs struct { |
| + Notes string // "fit" or "scroll" |
| + Size int // 16 to 48, even; default 24 |
| + Panels [3]panel // now, next, notes on a 12×12 grid |
| +} |
| + |
| +// defaultPresenterPrefs is the mockup's window: the slide on screen |
| +// over the one coming next on the left, the notes down the right. |
| +var defaultPresenterPrefs = presenterPrefs{ |
| + Notes: "fit", |
| + Size: 24, |
| + Panels: [3]panel{{0, 0, 7, 8}, {0, 8, 7, 4}, {7, 0, 5, 12}}, |
| +} |
| + |
| +// presenterPanels names the panels in the order Panels holds them. |
| +var presenterPanels = [3]string{"now", "next", "notes"} |
| + |
| +// readPresenterPrefs is the request's preferences. Anything malformed, |
| +// off the grid, under 2×2 or overlapping gives the defaults, whole: a |
| +// cookie half believed would put a panel where nobody put it. |
| +func readPresenterPrefs(r *http.Request) presenterPrefs { |
| + c, err := r.Cookie(presenterPrefsCookie) |
| + if err != nil { |
| + return defaultPresenterPrefs |
| + } |
| + raw, err := url.PathUnescape(c.Value) |
| + if err != nil { |
| + return defaultPresenterPrefs |
| + } |
| + prefs, ok := parsePresenterPrefs(raw) |
| + if !ok { |
| + return defaultPresenterPrefs |
| + } |
| + return prefs |
| +} |
| + |
| +// parsePresenterPrefs reads "notes.size.x,y,w,h;x,y,w,h;x,y,w,h". |
| +func parsePresenterPrefs(raw string) (presenterPrefs, bool) { |
| + fields := strings.Split(raw, ".") |
| + if len(fields) != 3 { |
| + return presenterPrefs{}, false |
| + } |
| + var p presenterPrefs |
| + switch fields[0] { |
| + case "fit", "scroll": |
| + p.Notes = fields[0] |
| + default: |
| + return presenterPrefs{}, false |
| + } |
| + size, ok := smallNumber(fields[1]) |
| + if !ok || size < 16 || size > 48 || size%2 != 0 { |
| + return presenterPrefs{}, false |
| + } |
| + p.Size = size |
| + rects := strings.Split(fields[2], ";") |
| + if len(rects) != len(p.Panels) { |
| + return presenterPrefs{}, false |
| + } |
| + for i, rect := range rects { |
| + nums := strings.Split(rect, ",") |
| + if len(nums) != 4 { |
| + return presenterPrefs{}, false |
| + } |
| + var v [4]int |
| + for j, n := range nums { |
| + if v[j], ok = smallNumber(n); !ok { |
| + return presenterPrefs{}, false |
| + } |
| + } |
| + pl := panel{X: v[0], Y: v[1], W: v[2], H: v[3]} |
| + if pl.W < 2 || pl.H < 2 || pl.X+pl.W > presenterGrid || pl.Y+pl.H > presenterGrid { |
| + return presenterPrefs{}, false |
| + } |
| + p.Panels[i] = pl |
| + } |
| + for i := range p.Panels { |
| + for j := i + 1; j < len(p.Panels); j++ { |
| + if overlap(p.Panels[i], p.Panels[j]) { |
| + return presenterPrefs{}, false |
| + } |
| + } |
| + } |
| + return p, true |
| +} |
| + |
| +// smallNumber is one or two ASCII digits: every number the cookie |
| +// holds, and nothing else (no sign, no space, no leading plus). |
| +func smallNumber(s string) (int, bool) { |
| + if len(s) == 0 || len(s) > 2 { |
| + return 0, false |
| + } |
| + for _, c := range s { |
| + if c < '0' || c > '9' { |
| + return 0, false |
| + } |
| + } |
| + n, err := strconv.Atoi(s) |
| + return n, err == nil |
| +} |
| + |
| +func overlap(a, b panel) bool { |
| + return a.X < b.X+b.W && b.X < a.X+a.W && a.Y < b.Y+b.H && b.Y < a.Y+a.H |
| +} |
| + |
| +// css is the arrangement as the page's own stylesheet, so the first |
| +// paint is final (spec §5.4). It applies only where the panels are |
| +// arranged at all: below 720px wide or 560px tall they stack in a fixed |
| +// order (static/presenter.css). |
| +func (p presenterPrefs) css() template.CSS { |
| + var b strings.Builder |
| + b.WriteString("@media (min-width: 720px) and (min-height: 560px) {\n") |
| + for i, name := range presenterPanels { |
| + pl := p.Panels[i] |
| + fmt.Fprintf(&b, " [presenter-panel=%q] { grid-area: %d / %d / span %d / span %d; }\n", |
| + name, pl.Y+1, pl.X+1, pl.H, pl.W) |
| + } |
| + b.WriteString("}\n") |
| + fmt.Fprintf(&b, "[presenter-notes] { font-size: %dpx; }\n", p.Size) |
| + return template.CSS(b.String()) |
| +} |
| + |
| +// presenterOp is one press a form sends: the op, a slide for a goto, |
| +// the remote token when the window was opened with one, and a fresh |
| +// press id (a Positional session requires one). |
| +type presenterOp struct { |
| + Op, Slide, Token, Press string |
| +} |
| + |
| +// notePart is one part of a slide's notes (deck.NoteParts): State is |
| +// "now" for the part being said, "past" or "later" for the dimmed rest, |
| +// and empty for notes with no press line, which stay plain (§10). |
| +type notePart struct { |
| + HTML template.HTML |
| + State string |
| +} |
| + |
| +// presenterWindowPage is the window. |
| +type presenterWindowPage struct { |
| + shell |
| + // ArrangeCSS is the arrangement and the notes' size, from the cookie. |
| + ArrangeCSS template.CSS |
| + Action string |
| + |
| + // What the page's root says, for static/present.js: the session, |
| + // the slide drawn (its number in the full talk), the step, the mode |
| + // and whether the room sees black, so it reloads when an event says |
| + // otherwise; the token when this window was opened with one. |
| + Session string |
| + Token string |
| + Slide int |
| + Step int |
| + Mode string |
| + Blackout bool |
| + |
| + Counter string |
| + PickHref string |
| + PickLabel string |
| + // StepCount is "step 2 of 4", empty on a slide with no steps; |
| + // Track is its segments, one per press, true for those made. |
| + StepCount string |
| + Track []bool |
| + ModeBadge string |
| + BlackLabel string |
| + |
| + Back, Forward presenterOp |
| + BackLabel, ForwardLabel string |
| + |
| + Timer string |
| + TimerSince int64 |
| + TimerLabel string |
| + TimerReset presenterOp |
| + Clock string |
| + ClockLabel string |
| + |
| + MoreLabel string |
| + Menu presenterMenu |
| + |
| + Now template.HTML |
| + NextLabel string |
| + Next template.HTML |
| + |
| + Parts []notePart |
| + NoNotes string |
| + NotesFit bool |
| + ToolsLabel string |
| + FitLabel string |
| + ScrollLabel string |
| + SmallerLabel string |
| + LargerLabel string |
| + |
| + Empty bool |
| + EmptyTitle string |
| + EmptyBody string |
| +} |
| + |
| +// presenterMenu is the ⋯ menu's six rows (§5.6). Pairing and arranging |
| +// arrive in Task 13: the pair form posts to a route that comes then, |
| +// and Arrange is a button that needs the window's script. |
| +type presenterMenu struct { |
| + PairAction string |
| + PairLabel string |
| + WindowHref string |
| + WindowLabel string |
| + Mode presenterOp |
| + ModeLabel string |
| + ArrangeLabel string |
| + DeckHref string |
| + DeckLabel string |
| + End presenterOp |
| + EndLabel string |
| +} |
| + |
| +// presenterPickPage is ?pick=1: every slide in the talk, as forms. |
| +type presenterPickPage struct { |
| + shell |
| + Title string |
| + Count string |
| + Action string |
| + WindowHref string |
| + FullLabel string |
| + Items []pickItem |
| +} |
| + |
| +// pickItem is one slide in the picker. The current one is a link back |
| +// to the window, which moves nothing; every other is a goto. |
| +type pickItem struct { |
| + Number int |
| + Title string |
| + Thumb string |
| + Full bool |
| + Current bool |
| + Op presenterOp |
| +} |
| + |
| +// presenterWindow serves the window, or with ?pick=1 its picker, for a |
| +// session with a position. The caller has already checked mayDrive. |
| +func (a *app) presenterWindow(w http.ResponseWriter, r *http.Request, p Presentation, token string) { |
| + d, ok := a.deckOf(w, r, p) |
| + if !ok { |
| + return |
| + } |
| + h, view, err := a.openDeck(r.Context(), d) |
| + if err != nil { |
| + a.fail(w, r, "open deck", err) |
| + return |
| + } |
| + defer h.Close(r.Context()) |
| + view = view.ForReaders() |
| + |
| + // Only a token that drives is carried on: a signed-in presenter |
| + // with a stale one in the address is let in by the cookie. |
| + if !remoteTokenOK(p, token) { |
| + token = "" |
| + } |
| + link := func(query url.Values) string { |
| + if token != "" { |
| + query.Set("t", token) |
| + } |
| + out := "/p/" + p.Sqid + "/notes" |
| + if enc := query.Encode(); enc != "" { |
| + out += "?" + enc |
| + } |
| + return out |
| + } |
| + op := func(name string) presenterOp { |
| + return presenterOp{Op: name, Token: token, Press: newPressID()} |
| + } |
| + |
| + q := r.URL.Query() |
| + mode := positionOf(p).Mode |
| + if q.Get("pick") == "1" && len(view.Slides) > 0 { |
| + a.presenterPick(w, r, view, p, link, op) |
| + return |
| + } |
| + |
| + prefs := readPresenterPrefs(r) |
| + now := time.Now().UTC() |
| + page := presenterWindowPage{ |
| + shell: presentShellFor(r, rastrillo.T(r, "slides.present.notes.title"), view.Meta.Title), |
| + ArrangeCSS: prefs.css(), |
| + Action: "/p/" + p.Sqid + "/command", |
| + Session: p.Sqid, |
| + Token: token, |
| + Mode: string(mode), |
| + |
| + BlackLabel: rastrillo.T(r, "slides.present.black"), |
| + Timer: "0:00", |
| + TimerLabel: rastrillo.T(r, "slides.present.timer.reset"), |
| + TimerReset: op("timer-reset"), |
| + Clock: clockWords(now), |
| + ClockLabel: rastrillo.T(r, "slides.present.clock"), |
| + MoreLabel: rastrillo.T(r, "slides.present.more"), |
| + Menu: presenterMenu{ |
| + PairAction: "/p/" + p.Sqid + "/pair", |
| + PairLabel: rastrillo.T(r, "slides.present.menu.pair"), |
| + WindowHref: "/p/" + p.Sqid, |
| + WindowLabel: rastrillo.T(r, "slides.present.menu.window"), |
| + Mode: op("mode"), |
| + ModeLabel: rastrillo.T(r, "slides.present.menu.full"), |
| + ArrangeLabel: rastrillo.T(r, "slides.present.menu.arrange"), |
| + DeckHref: "/d/" + d.Sqid + "/edit", |
| + DeckLabel: rastrillo.T(r, "slides.present.menu.back"), |
| + End: op("end"), |
| + EndLabel: rastrillo.T(r, "slides.present.menu.end"), |
| + }, |
| + |
| + NoNotes: rastrillo.T(r, "slides.notes.none"), |
| + NotesFit: prefs.Notes == "fit", |
| + ToolsLabel: rastrillo.T(r, "slides.present.notes.tools"), |
| + FitLabel: rastrillo.T(r, "slides.present.notes.fit"), |
| + ScrollLabel: rastrillo.T(r, "slides.present.notes.scroll"), |
| + SmallerLabel: rastrillo.T(r, "slides.present.notes.smaller"), |
| + LargerLabel: rastrillo.T(r, "slides.present.notes.larger"), |
| + } |
| + if token != "" { |
| + page.Menu.WindowHref += "?t=" + url.QueryEscape(token) |
| + } |
| + if mode == deck.ModeFull { |
| + page.Menu.ModeLabel = rastrillo.T(r, "slides.present.menu.core") |
| + } |
| + if p.TimerAt != nil { |
| + page.TimerSince = p.TimerAt.Unix() |
| + page.Timer = timerWords(now.Sub(*p.TimerAt)) |
| + } |
| + |
| + if len(view.Slides) == 0 { |
| + page.Empty = true |
| + page.EmptyTitle = rastrillo.T(r, "slides.present.empty.title") |
| + page.EmptyBody = rastrillo.T(r, "slides.present.empty.body") |
| + render(w, "presenter", page) |
| + return |
| + } |
| + |
| + at, ok := stepPlace(view, p, q) |
| + if !ok { |
| + a.notFound(w, r) |
| + return |
| + } |
| + index, step := at.index, at.step |
| + s := view.Slides[index] |
| + presses := len(deck.Presses(s)) |
| + page.shell.Fonts = newFontGate(r, view) |
| + page.Slide, page.Step = index+1, step |
| + page.Blackout = p.Blackout && at.live |
| + |
| + place, places := talkPlace(view, mode, index) |
| + page.Counter = rastrillo.Tf(r, "slides.present.progress", "n", place, "total", places) |
| + page.PickHref = link(url.Values{"pick": {"1"}}) |
| + page.PickLabel = rastrillo.T(r, "slides.present.pick.open") |
| + if presses > 0 { |
| + page.StepCount = rastrillo.Tf(r, "slides.present.step.count", "n", step, "total", presses) |
| + page.Track = make([]bool, presses) |
| + for i := range page.Track { |
| + page.Track[i] = i < step |
| + } |
| + } |
| + for _, sl := range view.Slides { |
| + if sl.Talk == "full" { |
| + page.ModeBadge = rastrillo.T(r, "slides.present.mode."+string(mode)) |
| + break |
| + } |
| + } |
| + page.Back, page.Forward = op("prev"), op("next") |
| + page.BackLabel, page.ForwardLabel = pressLabels(r, p) |
| + |
| + base := assetBaseFor("/p/" + p.Sqid) |
| + draw := func(i, k int) (template.HTML, error) { |
| + return slidehtml.SlideWith(view, i, slidehtml.Desktop, slidehtml.Options{AssetBase: base, Reveal: &k}) |
| + } |
| + if page.Now, err = draw(index, step); err != nil { |
| + a.fail(w, r, "render the slide on screen", err) |
| + return |
| + } |
| + switch next := nextInTalk(view, mode, index); { |
| + case step < presses: |
| + page.NextLabel = rastrillo.T(r, "slides.present.next.step") |
| + page.Next, err = draw(index, step+1) |
| + case next >= 0: |
| + page.NextLabel = rastrillo.T(r, "slides.present.next.slide") |
| + page.Next, err = draw(next, 0) |
| + default: |
| + page.NextLabel = rastrillo.T(r, "slides.present.next.end") |
| + } |
| + if err != nil { |
| + a.fail(w, r, "render the slide coming next", err) |
| + return |
| + } |
| + page.Parts = noteParts(s.Notes, step) |
| + render(w, "presenter", page) |
| +} |
| + |
| +// noteParts is a slide's notes as the window shows them at step (§10): |
| +// split at the press lines, the part for the step bright and the rest |
| +// dimmed. Presses past the last part keep the last part bright. Notes |
| +// with no press line are one plain part. |
| +func noteParts(notes deck.Text, step int) []notePart { |
| + if len(notes) == 0 { |
| + return nil |
| + } |
| + parts := deck.NoteParts(notes) |
| + if len(parts) == 1 { |
| + return []notePart{{HTML: slidehtml.Notes(parts[0])}} |
| + } |
| + bright := min(max(step, 0), len(parts)-1) |
| + out := make([]notePart, len(parts)) |
| + for i, part := range parts { |
| + state := "now" |
| + switch { |
| + case i < bright: |
| + state = "past" |
| + case i > bright: |
| + state = "later" |
| + } |
| + out[i] = notePart{HTML: slidehtml.Notes(part), State: state} |
| + } |
| + return out |
| +} |
| + |
| +// presenterPick is the scriptless picker (P4): every slide in the talk, |
| +// full-only ones marked, each a form that goes there. A press from it |
| +// lands on the window, not back here (pressLanding drops ?pick). |
| +func (a *app) presenterPick(w http.ResponseWriter, r *http.Request, view *deck.Deck, p Presentation, |
| + link func(url.Values) string, op func(string) presenterOp) { |
| + cur, _, _ := sessionPlace(view, p) |
| + full := deck.TalkOrder(view, deck.ModeFull) |
| + page := presenterPickPage{ |
| + shell: presentShellFor(r, rastrillo.T(r, "slides.present.pick.title"), view.Meta.Title), |
| + Title: rastrillo.T(r, "slides.present.pick.title"), |
| + Count: rastrillo.Tf(r, "slides.present.pick.count", "total", len(full)), |
| + Action: "/p/" + p.Sqid + "/command", |
| + WindowHref: link(url.Values{}), |
| + FullLabel: rastrillo.T(r, "slides.present.pick.full"), |
| + } |
| + for n, i := range full { |
| + s := view.Slides[i] |
| + item := pickItem{ |
| + Number: n + 1, |
| + Title: slideLabel(r, s, i+1), |
| + Thumb: "/p/" + p.Sqid + "/slides/" + url.PathEscape(s.ID) + ".svg", |
| + Full: s.Talk == "full", |
| + Current: i == cur, |
| + } |
| + if !item.Current { |
| + item.Op = op("goto") |
| + item.Op.Slide = strconv.Itoa(n + 1) |
| + } |
| + page.Items = append(page.Items, item) |
| + } |
| + render(w, "presenter_pick", page) |
| +} |
| + |
| +// timerWords is the talk's timer: minutes and seconds, and hours once |
| +// there are any. |
| +func timerWords(d time.Duration) string { |
| + s := max(int(d/time.Second), 0) |
| + if s >= 3600 { |
| + return fmt.Sprintf("%d:%02d:%02d", s/3600, s/60%60, s%60) |
| + } |
| + return fmt.Sprintf("%d:%02d", s/60, s%60) |
| +} |
diff --git a/internal/slides/presenting_position.go b/internal/slides/presenting_position.go| index 78487e1..267e5cd 100644 |
| --- a/internal/slides/presenting_position.go |
| +++ b/internal/slides/presenting_position.go |
| @@ -168,14 +168,17 @@ func (a *app) presentPress(w http.ResponseWriter, r *http.Request, p Presentatio |
| // pressLanding is where a form's press sends the browser back to: the |
| // page it came from, saying the slide and step the talk is now at, so a |
| // projector with scripts off draws that state (stepPlace) and a press |
| -// resubmitted lands on the same page as the first. ref is already known |
| -// to be this app's own. |
| +// resubmitted lands on the same page as the first. A press made from the |
| +// presenter window's picker (?pick=1) lands on the window itself. ref is |
| +// already known to be this app's own. |
| func pressLanding(ref string, at positionAnswer) string { |
| u, err := url.Parse(ref) |
| if err != nil { |
| return ref |
| } |
| q := u.Query() |
| + // A press from the presenter window's picker lands on the window. |
| + q.Del("pick") |
| q.Set("slide", strconv.Itoa(at.number)) |
| q.Set("step", strconv.Itoa(at.Step)) |
| u.RawQuery = q.Encode() |
diff --git a/internal/slides/render.go b/internal/slides/render.go| index 486dd46..cafad90 100644 |
| --- a/internal/slides/render.go |
| +++ b/internal/slides/render.go |
| @@ -123,8 +123,11 @@ var pageFiles = map[string][]string{ |
| // where it posts. |
| "present": {"templates/present_controls.html"}, |
| "present_notes": {"templates/present_controls.html"}, |
| - "remote": {"templates/present_controls.html"}, |
| - "remote_pair": nil, |
| + // The presenter window and its scriptless picker (presenter_window.go). |
| + "presenter": nil, |
| + "presenter_pick": nil, |
| + "remote": {"templates/present_controls.html"}, |
| + "remote_pair": nil, |
| } |
| // linkPages are names a handler uses for a page built from another |
diff --git a/internal/slides/static/present.js b/internal/slides/static/present.js| index 79d0da9..0d1272d 100644 |
| --- a/internal/slides/static/present.js |
| +++ b/internal/slides/static/present.js |
| @@ -400,6 +400,16 @@ |
| if (!displayed) return; |
| } |
| reloadedFor = want; |
| + // A page that names its state (?slide=N&step=k, where a scriptless |
| + // press lands it) would only draw that state again: it goes to where |
| + // the session is instead. |
| + var here = new URL(window.location.href); |
| + if (here.searchParams.has('slide') || here.searchParams.has('step')) { |
| + here.searchParams.delete('slide'); |
| + here.searchParams.delete('step'); |
| + window.location.replace(here.href); |
| + return; |
| + } |
| window.location.reload(); |
| } |
| @@ -490,4 +500,19 @@ |
| tick(); |
| setInterval(tick, 15000); |
| } |
| + |
| + // The presenter window's timer: minutes and seconds since the talk's |
| + // first press, and hours once there are any. Numbers only, so there is |
| + // no sentence to keep out of this file. Absent until the first press. |
| + var timer = document.querySelector('[data-timer-since]'); |
| + function two(n) { return (n < 10 ? '0' : '') + n; } |
| + function tickTimer() { |
| + var s = Math.max(0, Math.floor(Date.now() / 1000 - Number(timer.getAttribute('data-timer-since')))); |
| + var h = Math.floor(s / 3600), m = Math.floor(s / 60) % 60; |
| + timer.textContent = h ? h + ':' + two(m) + ':' + two(s % 60) : m + ':' + two(s % 60); |
| + } |
| + if (timer) { |
| + tickTimer(); |
| + setInterval(tickTimer, 1000); |
| + } |
| })(); |
diff --git a/internal/slides/static/presenter.css b/internal/slides/static/presenter.css| new file mode 100644 |
| index 0000000..e4634ef |
| --- /dev/null |
| +++ b/internal/slides/static/presenter.css |
| @@ -0,0 +1,659 @@ |
| +/* presenter.css — the presenter window (templates/presenter.html) and |
| + its scriptless picker (templates/presenter_pick.html). |
| + |
| + Copied from Paul's mockup (docs/superpowers/specs/2026-11-17- |
| + presenter-mockup.html): the HalfStack deck's presenter view, its |
| + palette and its proportions, with the mockup's ids as presenter-* |
| + attributes. Dimmed text uses the mockup's muted grey rather than its |
| + faint one wherever it is words, so it keeps 4.5:1 on the background. |
| + |
| + The window never scrolls (spec §5.1): html and body are exactly the |
| + viewport and hide what would overflow, every track of every grid is |
| + allowed to shrink to nothing, and only the notes (and the picker's |
| + list) scroll, inside themselves. Below 720px wide or 560px tall the |
| + panels stack in a fixed order; at or above it they sit on the 12×12 |
| + grid, where the page's own <style> places them (the cookie's |
| + arrangement, presenter_window.go). */ |
| + |
| +:root { |
| + color-scheme: dark; |
| + --p-bg: #0b0b0f; |
| + --p-ink: #efefec; |
| + --p-ink-2: #c4c4cc; |
| + --p-muted: #9a9aa6; |
| + --p-faint: #6c6c78; |
| + --p-accent: #ffb454; |
| + --p-panel: #111118; |
| + --p-raised: #181820; |
| + --p-border: #26262f; |
| + --p-paper: #faf6ee; |
| + --p-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace; |
| + --p-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; |
| + --p-ease: cubic-bezier(0.16, 1, 0.3, 1); |
| +} |
| + |
| +/* No gutter kept for a scrollbar the window never has (tokens.css |
| + reserves one on every other page). */ |
| +html { |
| + scrollbar-gutter: auto; |
| +} |
| + |
| +html, |
| +body { |
| + margin: 0; |
| + block-size: 100%; |
| + inline-size: 100%; |
| + overflow: hidden; |
| +} |
| + |
| +body { |
| + background: var(--p-bg); |
| + color: var(--p-ink); |
| + font: 16px/1.5 var(--p-sans); |
| + -webkit-font-smoothing: antialiased; |
| +} |
| + |
| +[estilo-shell] { |
| + block-size: 100%; |
| +} |
| + |
| +[presenter], |
| +[presenter-pick] { |
| + box-sizing: border-box; |
| + block-size: 100dvh; |
| + inline-size: 100%; |
| + overflow: hidden; |
| + padding: 16px 28px; |
| + background: var(--p-bg); |
| + color: var(--p-ink); |
| + font-family: var(--p-sans); |
| + scrollbar-width: thin; |
| + scrollbar-color: #3a3a46 transparent; |
| +} |
| + |
| +[presenter] *, |
| +[presenter-pick] * { |
| + box-sizing: border-box; |
| +} |
| + |
| +[presenter] ::selection { |
| + background: rgb(255 180 84 / 0.3); |
| + color: var(--p-ink); |
| +} |
| + |
| +:where([presenter], [presenter-pick]) button { |
| + font: inherit; |
| + color: inherit; |
| + cursor: pointer; |
| + background: none; |
| + border: 0; |
| + margin: 0; |
| + padding: 0; |
| +} |
| + |
| +:where([presenter], [presenter-pick]) form { |
| + margin: 0; |
| + display: contents; |
| +} |
| + |
| +:where([presenter], [presenter-pick]) a { |
| + color: inherit; |
| + text-decoration: none; |
| +} |
| + |
| +[presenter] :focus-visible, |
| +[presenter-pick] :focus-visible { |
| + outline: 2px solid var(--p-accent); |
| + outline-offset: 2px; |
| +} |
| + |
| +[presenter] svg.icon { |
| + inline-size: 20px; |
| + block-size: 20px; |
| + flex: none; |
| + stroke-width: 1.75; |
| +} |
| + |
| +/* The window: the header, then what is left for the panels. */ |
| +[presenter] { |
| + display: grid; |
| + grid-template-columns: minmax(0, 1fr); |
| + grid-template-rows: auto minmax(0, 1fr); |
| +} |
| + |
| +/* ---- the header ---- */ |
| +[presenter-head] { |
| + position: relative; |
| + display: flex; |
| + flex-wrap: wrap; |
| + align-items: center; |
| + gap: 8px 16px; |
| + min-inline-size: 0; |
| + margin-block-end: 16px; |
| + padding-block-end: 12px; |
| + border-block-end: 1px solid var(--p-border); |
| + font-family: var(--p-mono); |
| + font-variant-numeric: tabular-nums; |
| +} |
| + |
| +[presenter-pos] { |
| + display: inline-flex; |
| + align-items: center; |
| + gap: 10px; |
| + padding: 8px 14px; |
| + border-radius: 8px; |
| + font-size: 24px; |
| + line-height: 1.2; |
| + color: var(--p-ink); |
| + white-space: nowrap; |
| + transition: background-color 0.2s var(--p-ease); |
| +} |
| + |
| +[presenter-pos]:hover { |
| + background: var(--p-raised); |
| +} |
| + |
| +[presenter-pos] svg.icon { |
| + color: var(--p-faint); |
| +} |
| + |
| +[presenter-stepcount] { |
| + display: inline-flex; |
| + align-items: center; |
| + gap: 10px; |
| + padding: 6px 12px; |
| + border-radius: 8px; |
| + background: var(--p-raised); |
| +} |
| + |
| +[presenter-track] { |
| + display: flex; |
| + gap: 5px; |
| + inline-size: 96px; |
| +} |
| + |
| +[presenter-track] i { |
| + flex: 1; |
| + block-size: 6px; |
| + border-radius: 3px; |
| + background: #2c2c36; |
| +} |
| + |
| +[presenter-track] i[data-done] { |
| + background: var(--p-accent); |
| +} |
| + |
| +[presenter-steptext] { |
| + font: 18px/1.3 var(--p-mono); |
| + color: var(--p-ink-2); |
| + white-space: nowrap; |
| +} |
| + |
| +[presenter-mode] { |
| + padding: 4px 12px; |
| + border-radius: 999px; |
| + background: var(--p-raised); |
| + color: var(--p-ink-2); |
| + font-size: 16px; |
| + letter-spacing: 0.06em; |
| + text-transform: uppercase; |
| +} |
| + |
| +[presenter-black] { |
| + padding: 4px 12px; |
| + border-radius: 4px; |
| + border: 1px solid var(--p-accent); |
| + color: var(--p-accent); |
| + font-size: 16px; |
| + letter-spacing: 0.14em; |
| +} |
| + |
| +/* Back and Next: the scriptless presses, quiet beside the timer. */ |
| +[presenter-presses] { |
| + display: inline-flex; |
| + gap: 6px; |
| + margin-inline-start: auto; |
| +} |
| + |
| +[presenter-press] { |
| + min-block-size: 40px; |
| + padding: 6px 14px; |
| + border-radius: 8px; |
| + border: 1px solid var(--p-border); |
| + color: var(--p-ink-2); |
| + font-size: 16px; |
| +} |
| + |
| +[presenter-press]:hover { |
| + background: var(--p-raised); |
| + color: var(--p-ink); |
| +} |
| + |
| +[presenter-elapsed] { |
| + padding: 4px 14px; |
| + border-radius: 8px; |
| + font: 40px/1.1 var(--p-mono); |
| + color: var(--p-ink); |
| + transition: background-color 0.2s var(--p-ease); |
| +} |
| + |
| +[presenter-elapsed]:hover { |
| + background: var(--p-raised); |
| +} |
| + |
| +[presenter-clock] { |
| + font-size: 22px; |
| + color: var(--p-muted); |
| + white-space: nowrap; |
| +} |
| + |
| +/* The ⋯ menu: a <details>, so it opens with scripts off. */ |
| +[presenter-more-menu] { |
| + display: inline-block; |
| +} |
| + |
| +[presenter-more] { |
| + inline-size: 40px; |
| + block-size: 40px; |
| + display: grid; |
| + place-items: center; |
| + border-radius: 8px; |
| + color: var(--p-muted); |
| + cursor: pointer; |
| + list-style: none; |
| +} |
| + |
| +[presenter-more]::-webkit-details-marker { |
| + display: none; |
| +} |
| + |
| +[presenter-more]:hover, |
| +[presenter-more-menu][open] > [presenter-more] { |
| + background: var(--p-raised); |
| + color: var(--p-ink); |
| +} |
| + |
| +[presenter-menu] { |
| + position: absolute; |
| + z-index: 4; |
| + inset-block-start: calc(100% + 8px); |
| + inset-inline-end: 0; |
| + min-inline-size: min(280px, 100%); |
| + max-inline-size: 100%; |
| + max-block-size: calc(100dvh - 96px); |
| + overflow-y: auto; |
| + padding: 8px; |
| + display: grid; |
| + gap: 2px; |
| + border-radius: 12px; |
| + background: var(--p-panel); |
| + border: 1px solid var(--p-border); |
| + box-shadow: 0 12px 16px rgb(0 0 0 / 0.5); |
| + font: 17px/1.5 var(--p-sans); |
| +} |
| + |
| +[presenter-menu] button, |
| +[presenter-menu] a { |
| + display: block; |
| + padding: 10px 14px; |
| + border-radius: 8px; |
| + text-align: start; |
| + color: var(--p-ink-2); |
| +} |
| + |
| +[presenter-menu] button:hover, |
| +[presenter-menu] a:hover { |
| + background: var(--p-raised); |
| + color: var(--p-ink); |
| +} |
| + |
| +[presenter-menu] hr { |
| + inline-size: 100%; |
| + border: 0; |
| + border-block-start: 1px solid var(--p-border); |
| + margin: 4px 0; |
| +} |
| + |
| +/* ---- the panels ---- */ |
| +/* Stacked, in a fixed order: now, next, notes. */ |
| +[presenter-panels] { |
| + min-block-size: 0; |
| + min-inline-size: 0; |
| + display: grid; |
| + grid-template-columns: minmax(0, 1fr); |
| + grid-template-rows: minmax(0, 5fr) minmax(0, 3fr) minmax(0, 6fr); |
| + row-gap: 12px; |
| +} |
| + |
| +@media (min-width: 720px) and (min-height: 560px) { |
| + [presenter-panels] { |
| + grid-template-columns: repeat(12, minmax(0, 1fr)); |
| + grid-template-rows: repeat(12, minmax(0, 1fr)); |
| + gap: 0; |
| + margin: -8px -16px; |
| + } |
| + |
| + [presenter-panel] { |
| + padding: 8px 16px; |
| + } |
| +} |
| + |
| +[presenter-panel] { |
| + position: relative; |
| + min-inline-size: 0; |
| + min-block-size: 0; |
| + overflow: hidden; |
| + display: flex; |
| + flex-direction: column; |
| + gap: 10px; |
| +} |
| + |
| +/* The room a slide may take: 16:9 inside whatever the panel has left. */ |
| +[presenter-fit] { |
| + flex: 1 1 0; |
| + min-block-size: 0; |
| + container-type: size; |
| +} |
| + |
| +[presenter-frame] { |
| + inline-size: min(100cqw, 100cqh * 16 / 9); |
| + aspect-ratio: 16 / 9; |
| + overflow: hidden; |
| + border-radius: 4px; |
| + background: var(--p-paper); |
| + box-shadow: 0 8px 16px rgb(0 0 0 / 0.45); |
| +} |
| + |
| +[presenter-frame] > [slides-slide] { |
| + inline-size: 100%; |
| + block-size: 100%; |
| +} |
| + |
| +[presenter-panel="next"] [presenter-frame] { |
| + opacity: 0.92; |
| +} |
| + |
| +/* The end of the talk: an empty frame. */ |
| +[presenter-frame][data-end] { |
| + background: transparent; |
| + border: 1px dashed var(--p-border); |
| + box-shadow: none; |
| +} |
| + |
| +[presenter-frame][data-black] { |
| + background: #000; |
| +} |
| + |
| +[presenter-frame][data-black] > * { |
| + visibility: hidden; |
| +} |
| + |
| +[presenter-next-label] { |
| + display: flex; |
| + align-items: center; |
| + gap: 8px; |
| + margin: 0; |
| + flex: none; |
| + font: 16px/1.5 var(--p-mono); |
| + letter-spacing: 0.14em; |
| + text-transform: uppercase; |
| + color: var(--p-accent); |
| +} |
| + |
| +/* ---- the notes ---- */ |
| +[presenter-notes] { |
| + flex: 1 1 0; |
| + min-inline-size: 0; |
| + min-block-size: 0; |
| + overflow-y: auto; |
| + background: var(--p-panel); |
| + border: 1px solid var(--p-border); |
| + border-radius: 12px; |
| + padding: 60px 32px 28px; |
| + line-height: 1.45; |
| + color: var(--p-ink-2); |
| + font-family: var(--p-sans); |
| +} |
| + |
| +[presenter-notes] p { |
| + margin: 0 0 0.5em; |
| + max-inline-size: 30em; |
| +} |
| + |
| +[presenter-notes] section { |
| + padding-block: 0.35em; |
| +} |
| + |
| +[presenter-notes] section:empty { |
| + display: none; |
| +} |
| + |
| +[presenter-notes] section + section { |
| + border-block-start: 1px solid var(--p-border); |
| + margin-block-start: 0.5em; |
| + padding-block-start: 0.6em; |
| +} |
| + |
| +[presenter-notes] section[data-part="past"], |
| +[presenter-notes] section[data-part="later"] { |
| + color: var(--p-muted); |
| +} |
| + |
| +[presenter-notes] section[data-part="now"] { |
| + color: var(--p-ink); |
| +} |
| + |
| +[presenter-nonotes] { |
| + color: var(--p-muted); |
| +} |
| + |
| +[presenter-tools] { |
| + position: absolute; |
| + inset-block-start: 10px; |
| + inset-inline-end: 10px; |
| + display: flex; |
| + gap: 2px; |
| + padding: 4px; |
| + border-radius: 10px; |
| + background: rgb(24 24 32 / 0.92); |
| + border: 1px solid var(--p-border); |
| + opacity: 0.55; |
| + transition: opacity 0.2s var(--p-ease); |
| +} |
| + |
| +@media (min-width: 720px) and (min-height: 560px) { |
| + [presenter-tools] { |
| + inset-block-start: 18px; |
| + inset-inline-end: 26px; |
| + } |
| +} |
| + |
| +[presenter-panel="notes"]:hover [presenter-tools], |
| +[presenter-tools]:focus-within { |
| + opacity: 1; |
| +} |
| + |
| +[presenter-tools] button { |
| + inline-size: 36px; |
| + block-size: 36px; |
| + display: grid; |
| + place-items: center; |
| + border-radius: 8px; |
| + color: var(--p-muted); |
| +} |
| + |
| +[presenter-tools] button:hover, |
| +[presenter-tools] button[aria-pressed="true"] { |
| + background: var(--p-raised); |
| + color: var(--p-accent); |
| +} |
| + |
| +[presenter-tools] hr { |
| + inline-size: 1px; |
| + block-size: 20px; |
| + align-self: center; |
| + border: 0; |
| + background: var(--p-border); |
| + margin: 0 4px; |
| +} |
| + |
| +[presenter-empty] { |
| + align-self: center; |
| + justify-self: center; |
| + max-inline-size: 40rem; |
| + overflow: hidden; |
| +} |
| + |
| +/* ---- small windows: the stacked window's header gets quieter ---- */ |
| +@media (max-width: 719.98px), (max-height: 559.98px) { |
| + [presenter], |
| + [presenter-pick] { |
| + padding: 10px 14px; |
| + } |
| + |
| + [presenter-head] { |
| + gap: 6px 10px; |
| + margin-block-end: 10px; |
| + padding-block-end: 8px; |
| + } |
| + |
| + [presenter-pos] { |
| + padding: 4px 8px; |
| + font-size: 18px; |
| + } |
| + |
| + [presenter-stepcount] { |
| + padding: 4px 8px; |
| + } |
| + |
| + [presenter-track] { |
| + inline-size: 56px; |
| + } |
| + |
| + [presenter-steptext] { |
| + font-size: 15px; |
| + } |
| + |
| + [presenter-mode], |
| + [presenter-black], |
| + [presenter-press] { |
| + font-size: 14px; |
| + } |
| + |
| + [presenter-press] { |
| + min-block-size: 36px; |
| + padding: 4px 10px; |
| + } |
| + |
| + [presenter-presses] { |
| + margin-inline-start: 0; |
| + } |
| + |
| + [presenter-elapsed] { |
| + padding: 2px 8px; |
| + font-size: 24px; |
| + } |
| + |
| + [presenter-clock] { |
| + font-size: 16px; |
| + } |
| + |
| + [presenter-more] { |
| + inline-size: 36px; |
| + block-size: 36px; |
| + } |
| + |
| + [presenter-notes] { |
| + padding: 52px 16px 12px; |
| + } |
| + |
| + [presenter-next-label] { |
| + font-size: 13px; |
| + } |
| +} |
| + |
| +/* ---- the scriptless picker ---- */ |
| +[presenter-pick] { |
| + display: grid; |
| + grid-template-rows: auto minmax(0, 1fr); |
| + gap: 12px; |
| +} |
| + |
| +[presenter-pick-head] { |
| + display: flex; |
| + flex-wrap: wrap; |
| + align-items: baseline; |
| + gap: 8px 16px; |
| +} |
| + |
| +[presenter-pick-head] h1 { |
| + margin: 0; |
| + font-size: 24px; |
| +} |
| + |
| +[presenter-pick-count] { |
| + margin: 0; |
| + font: 14px/1.5 var(--p-mono); |
| + color: var(--p-muted); |
| +} |
| + |
| +[presenter-pick-list] { |
| + min-block-size: 0; |
| + overflow-y: auto; |
| + margin: 0; |
| + padding: 2px; |
| + list-style: none; |
| + display: grid; |
| + grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); |
| + align-content: start; |
| + gap: 12px 10px; |
| +} |
| + |
| +[presenter-pick-item] { |
| + display: grid; |
| + gap: 6px; |
| + inline-size: 100%; |
| + padding: 6px; |
| + border-radius: 8px; |
| + text-align: start; |
| + color: var(--p-ink-2); |
| + font-size: 14px; |
| + line-height: 1.35; |
| +} |
| + |
| +[presenter-pick-item]:hover, |
| +[presenter-pick-item][aria-current="true"] { |
| + background: var(--p-raised); |
| + color: var(--p-ink); |
| +} |
| + |
| +[presenter-pick-item] img { |
| + display: block; |
| + inline-size: 100%; |
| + block-size: auto; |
| + aspect-ratio: 16 / 9; |
| + border-radius: 3px; |
| + background: var(--p-paper); |
| +} |
| + |
| +[presenter-pick-item][aria-current="true"] img { |
| + outline: 2px solid var(--p-accent); |
| + outline-offset: 2px; |
| +} |
| + |
| +[presenter-pick-item] b { |
| + font: 600 14px/1.35 var(--p-mono); |
| + margin-inline-end: 6px; |
| +} |
| + |
| +[presenter-pick-item] em { |
| + font-style: normal; |
| + color: var(--p-muted); |
| +} |
| + |
| +@media (prefers-reduced-motion: reduce) { |
| + [presenter] *, |
| + [presenter-pick] * { |
| + transition: none !important; |
| + } |
| +} |
diff --git a/internal/slides/templates/presenter.html b/internal/slides/templates/presenter.html| new file mode 100644 |
| index 0000000..a0b603a |
| --- /dev/null |
| +++ b/internal/slides/templates/presenter.html |
| @@ -0,0 +1,125 @@ |
| +{{/* presenter — GET /p/{session}/notes for a session with a position: |
| + the presenter window (spec §5), drawn by the server. |
| + |
| + Paul's mockup (docs/superpowers/specs/2026-11-17-presenter-mockup.html) |
| + with its ids as presenter-* attributes: the header, then the three |
| + panels — the slide on screen now, what comes next, the notes — |
| + placed on a 12×12 grid by the cookie's arrangement (presenter_window.go |
| + writes it into the <style> below, so the first paint is final). |
| + |
| + It never scrolls: static/presenter.css makes html and body exactly |
| + the viewport. Only the notes scroll, inside their own panel. |
| + |
| + With scripts off every control is a form that posts a press and |
| + redirects back to ?slide=N&step=k, which draws that state; the |
| + position is a link to the picker (?pick=1). With them, present.js |
| + reloads the page when the talk moves elsewhere and ticks the clock |
| + and the timer. Task 10's bundle replaces that with a window that |
| + moves at once. */}} |
| +{{define "page-head"}}<link rel="stylesheet" href="{{asset "static/slides.css"}}"> |
| +<link rel="stylesheet" href="{{asset "static/presenter.css"}}"> |
| +<style>{{.ArrangeCSS}}</style> |
| +<script defer src="{{asset "static/present.js"}}"></script>{{end}} |
| +{{define "presenter-fields"}}<input type="hidden" name="op" value="{{.Op}}"> |
| +{{- with .Slide}}<input type="hidden" name="slide" value="{{.}}">{{end}} |
| +{{- with .Token}}<input type="hidden" name="t" value="{{.}}">{{end}} |
| +<input type="hidden" name="press" value="{{.Press}}">{{end}} |
| +{{define "main"}}<main id="main" presenter data-session="{{.Session}}" |
| + {{- if not .Empty}} data-slide="{{.Slide}}" data-step="{{.Step}}" data-mode="{{.Mode}}"{{end}} |
| + data-blackout="{{if .Blackout}}true{{else}}false{{end}}" |
| + {{- with .Token}} data-remote-token="{{.}}"{{end}}> |
| +<div presenter-head> |
| + {{- if not .Empty}} |
| + <a presenter-pos slides-counter href="{{.PickHref}}" title="{{.PickLabel}}">{{.Counter}}{{icon "chevron-down"}}</a> |
| + {{- if .StepCount}} |
| + <span presenter-stepcount role="status"><span presenter-track aria-hidden="true"> |
| + {{- range .Track}}<i{{if .}} data-done{{end}}></i>{{end -}} |
| + </span><span presenter-steptext>{{.StepCount}}</span></span> |
| + {{- end}} |
| + {{- with .ModeBadge}} |
| + <span presenter-mode>{{.}}</span> |
| + {{- end}} |
| + {{- if .Blackout}} |
| + <span presenter-black>{{.BlackLabel}}</span> |
| + {{- end}} |
| + <span presenter-presses> |
| + <form method="post" action="{{.Action}}" data-busy="false"> |
| + {{template "presenter-fields" .Back}} |
| + <button type="submit" presenter-press="prev">{{.BackLabel}}</button> |
| + </form> |
| + <form method="post" action="{{.Action}}" data-busy="false"> |
| + {{template "presenter-fields" .Forward}} |
| + <button type="submit" presenter-press="next">{{.ForwardLabel}}</button> |
| + </form> |
| + </span> |
| + {{- end}} |
| + <form presenter-timer method="post" action="{{.Action}}" data-busy="false"> |
| + {{template "presenter-fields" .TimerReset}} |
| + <button type="submit" presenter-elapsed title="{{.TimerLabel}}" |
| + {{- if .TimerSince}} data-timer-since="{{.TimerSince}}"{{end}}>{{.Timer}}</button> |
| + </form> |
| + <span presenter-clock title="{{.ClockLabel}}" data-clock>{{.Clock}}</span> |
| + <details presenter-more-menu> |
| + <summary presenter-more aria-label="{{.MoreLabel}}" title="{{.MoreLabel}}">{{icon "ellipsis"}}</summary> |
| + <div presenter-menu> |
| + {{- with .Menu}} |
| + <form method="post" action="{{.PairAction}}" target="slides-pair" data-busy="false"> |
| + <button type="submit">{{.PairLabel}}</button> |
| + </form> |
| + <a href="{{.WindowHref}}" target="slides-window">{{.WindowLabel}}</a> |
| + <form method="post" action="{{$.Action}}" data-busy="false"> |
| + {{template "presenter-fields" .Mode}} |
| + <button type="submit">{{.ModeLabel}}</button> |
| + </form> |
| + <button type="button" presenter-arrange>{{.ArrangeLabel}}</button> |
| + <hr> |
| + <a href="{{.DeckHref}}">{{.DeckLabel}}</a> |
| + <form method="post" action="{{$.Action}}" data-busy="false"> |
| + {{template "presenter-fields" .End}} |
| + <button type="submit">{{.EndLabel}}</button> |
| + </form> |
| + {{- end}} |
| + </div> |
| + </details> |
| +</div> |
| +{{if .Empty}} |
| +<div presenter-empty> |
| + {{template "empty-state" dict "Title" .EmptyTitle "Body" .EmptyBody}} |
| +</div> |
| +{{else}} |
| +<div presenter-panels> |
| + <div presenter-panel="now"> |
| + <div presenter-fit> |
| + <div presenter-frame{{if .Blackout}} data-black{{end}}>{{.Now}}</div> |
| + </div> |
| + </div> |
| + <div presenter-panel="next"> |
| + <p presenter-next-label>{{icon "arrow-right"}}<span>{{.NextLabel}}</span></p> |
| + <div presenter-fit> |
| + {{- if .Next}} |
| + <div presenter-frame>{{.Next}}</div> |
| + {{- else}} |
| + <div presenter-frame data-end></div> |
| + {{- end}} |
| + </div> |
| + </div> |
| + <div presenter-panel="notes"> |
| + <div presenter-notes data-notes-mode="{{if .NotesFit}}fit{{else}}scroll{{end}}" tabindex="0"> |
| + {{- range .Parts}} |
| + <section presenter-part{{with .State}} data-part="{{.}}"{{end}}>{{.HTML}}</section> |
| + {{- else}} |
| + <p presenter-nonotes>{{.NoNotes}}</p> |
| + {{- end}} |
| + </div> |
| + <div presenter-tools role="toolbar" aria-label="{{.ToolsLabel}}"> |
| + <button type="button" presenter-notes-fit aria-pressed="{{if .NotesFit}}true{{else}}false{{end}}" aria-label="{{.FitLabel}}" title="{{.FitLabel}}">{{icon "shrink"}}</button> |
| + <button type="button" presenter-notes-scroll aria-pressed="{{if .NotesFit}}false{{else}}true{{end}}" aria-label="{{.ScrollLabel}}" title="{{.ScrollLabel}}">{{icon "move-vertical"}}</button> |
| + <hr> |
| + <button type="button" presenter-notes-smaller aria-label="{{.SmallerLabel}}" title="{{.SmallerLabel}}">{{icon "a-arrow-down"}}</button> |
| + <button type="button" presenter-notes-larger aria-label="{{.LargerLabel}}" title="{{.LargerLabel}}">{{icon "a-arrow-up"}}</button> |
| + </div> |
| + </div> |
| +</div> |
| +{{end}} |
| +</main>{{end}} |
| +{{define "content"}}{{end}} |
diff --git a/internal/slides/templates/presenter_pick.html b/internal/slides/templates/presenter_pick.html| new file mode 100644 |
| index 0000000..ad02e40 |
| --- /dev/null |
| +++ b/internal/slides/templates/presenter_pick.html |
| @@ -0,0 +1,43 @@ |
| +{{/* presenter_pick — GET /p/{session}/notes?pick=1: the presenter |
| + window's slide picker with scripts off (P4). |
| + |
| + Every slide in the talk, parked ones left out and full-only ones |
| + marked, each a one-button form styled as a link: going to a slide |
| + moves the talk, so it cannot be a GET. A press from here lands on |
| + the window (pressLanding drops ?pick). The slide on screen now is a |
| + plain link back to the window, which moves nothing. |
| + |
| + Like the window it never scrolls as a page; the list scrolls inside |
| + itself. */}} |
| +{{define "page-head"}}<link rel="stylesheet" href="{{asset "static/presenter.css"}}">{{end}} |
| +{{define "presenter-fields"}}<input type="hidden" name="op" value="{{.Op}}"> |
| +{{- with .Slide}}<input type="hidden" name="slide" value="{{.}}">{{end}} |
| +{{- with .Token}}<input type="hidden" name="t" value="{{.}}">{{end}} |
| +<input type="hidden" name="press" value="{{.Press}}">{{end}} |
| +{{define "main"}}<main id="main" presenter-pick> |
| +<div presenter-pick-head> |
| + <h1>{{.Title}}</h1> |
| + <p presenter-pick-count>{{.Count}}</p> |
| +</div> |
| +<ol presenter-pick-list> |
| + {{- range .Items}} |
| + <li> |
| + {{- if .Current}} |
| + <a presenter-pick-item aria-current="true" href="{{$.WindowHref}}"> |
| + <img src="{{.Thumb}}" alt="" loading="lazy" width="1920" height="1080"> |
| + <span><b>{{.Number}}</b>{{.Title}}{{if .Full}} <em>· {{$.FullLabel}}</em>{{end}}</span> |
| + </a> |
| + {{- else}} |
| + <form method="post" action="{{$.Action}}" data-busy="false"> |
| + {{template "presenter-fields" .Op}} |
| + <button type="submit" presenter-pick-item> |
| + <img src="{{.Thumb}}" alt="" loading="lazy" width="1920" height="1080"> |
| + <span><b>{{.Number}}</b>{{.Title}}{{if .Full}} <em>· {{$.FullLabel}}</em>{{end}}</span> |
| + </button> |
| + </form> |
| + {{- end}} |
| + </li> |
| + {{- end}} |
| +</ol> |
| +</main>{{end}} |
| +{{define "content"}}{{end}} |
diff --git a/internal/slidestest/fontgate_test.go b/internal/slidestest/fontgate_test.go| index 5bd9590..e8419fc 100644 |
| --- a/internal/slidestest/fontgate_test.go |
| +++ b/internal/slidestest/fontgate_test.go |
| @@ -80,9 +80,10 @@ func gateOn(t *testing.T, where, page string) (preloads []string, carries bool) |
| // Every page that draws a slide in the deck's faces carries the gate — |
| // the viewer in each of its modes, the projector, the follow view and |
| -// the editor — and no other page does. The presenter view and the |
| -// remote show their slides as pictures and their notes in the chrome's |
| -// face, so there is nothing on them a web face could reach. |
| +// the editor, and the presenter window, whose slides are live — and no |
| +// other page does. The remote shows its slides as pictures and its |
| +// notes in the chrome's face, so there is nothing on it a web face |
| +// could reach. |
| func TestOnlySlideSurfacesCarryTheGateAndPreloadOnlyDeckFaces(t *testing.T) { |
| a := newApp(t) |
| cookies := signedIn(t, a, allowedAddress) |
| @@ -108,7 +109,7 @@ func TestOnlySlideSurfacesCarryTheGateAndPreloadOnlyDeckFaces(t *testing.T) { |
| {share + "?follow=1", nil, true}, |
| {"/p/" + session, nil, true}, |
| {"/p/" + session + "?t=" + token, nil, true}, |
| - {"/p/" + session + "/notes?t=" + token, nil, false}, |
| + {"/p/" + session + "/notes?t=" + token, nil, true}, |
| {"/p/" + session + "/remote?t=" + token, nil, false}, |
| {"/", cookies, false}, |
| {"/signin", nil, false}, |
diff --git a/internal/slidestest/fonts_browser_test.go b/internal/slidestest/fonts_browser_test.go| index 7a633e7..0ad1192 100644 |
| --- a/internal/slidestest/fonts_browser_test.go |
| +++ b/internal/slidestest/fonts_browser_test.go |
| @@ -692,35 +692,75 @@ func TestFontThePreloadsAreTheFacesTheGateLoads(t *testing.T) { |
| webEverywhere(t, p) |
| } |
| -// The presenter view and the remote draw their slides as pictures and |
| -// their notes in the chrome's face: no web face is ever in their |
| -// document, and no font file is fetched for them. So there is nothing |
| -// on them that could change face mid-talk. |
| +// The remote draws its slides as pictures and its notes in the chrome's |
| +// face: no web face is ever in its document, and no font file is |
| +// fetched for it, so nothing on it could change face mid-talk. The |
| +// presenter window draws its slides live (Task 9), so it takes the |
| +// gate: its slides are in the deck's faces once shown, and its own |
| +// words, the notes among them, stay in the chrome's. |
| func TestFontThePresenterAndRemoteDrawInNoWebFace(t *testing.T) { |
| fr := newFontRig(t) |
| sqid := fr.deck(t, "Talk", paperDeck) |
| fr.ops(t, sqid, `[{"op":"set_notes","id":"slideone0001","markdown":"Notes with **bold** and `+"`code`"+`."}]`) |
| session, token := startPresenting(t, fr.app, "/d/"+sqid, fr.cookies) |
| - for _, path := range []string{"/p/" + session + "/notes?t=" + token, "/p/" + session + "/remote?t=" + token} { |
| - before := fr.hits("/static/fonts/") |
| - fr.rig.Run(fr.navigate(path), chromedp.WaitReady(`main`, chromedp.ByQuery), chromedp.Sleep(1500*time.Millisecond)) |
| - var out struct { |
| - Web int |
| - Liberty []string |
| - } |
| - fr.eval(t, `(() => ({ Web: [...document.fonts].filter((f) => /liberation/i.test(f.family)).length, |
| - Liberty: [...document.querySelectorAll('main *')].filter((e) => e.childNodes.length && [...e.childNodes].some((n) => n.nodeType === 3 && n.data.trim())) |
| - .map((e) => getComputedStyle(e).fontFamily).filter((f) => /liberation/i.test(f)) }))()`, &out) |
| - if out.Web != 0 { |
| - t.Errorf("%s: %d web faces in the document", path, out.Web) |
| - } |
| - if len(out.Liberty) != 0 { |
| - t.Errorf("%s: text set in a deck face: %v", path, out.Liberty) |
| - } |
| - if after := fr.hits("/static/fonts/"); after != before { |
| - t.Errorf("%s fetched %d font files", path, after-before) |
| + |
| + remote := "/p/" + session + "/remote?t=" + token |
| + before := fr.hits("/static/fonts/") |
| + fr.rig.Run(fr.navigate(remote), chromedp.WaitReady(`main`, chromedp.ByQuery), chromedp.Sleep(1500*time.Millisecond)) |
| + var out struct { |
| + Web int |
| + Liberty []string |
| + } |
| + fr.eval(t, `(() => ({ Web: [...document.fonts].filter((f) => /liberation/i.test(f.family)).length, |
| + Liberty: [...document.querySelectorAll('main *')].filter((e) => e.childNodes.length && [...e.childNodes].some((n) => n.nodeType === 3 && n.data.trim())) |
| + .map((e) => getComputedStyle(e).fontFamily).filter((f) => /liberation/i.test(f)) }))()`, &out) |
| + if out.Web != 0 { |
| + t.Errorf("%s: %d web faces in the document", remote, out.Web) |
| + } |
| + if len(out.Liberty) != 0 { |
| + t.Errorf("%s: text set in a deck face: %v", remote, out.Liberty) |
| + } |
| + if after := fr.hits("/static/fonts/"); after != before { |
| + t.Errorf("%s fetched %d font files", remote, after-before) |
| + } |
| + |
| + window := "/p/" + session + "/notes?t=" + token |
| + before = fr.hits("/static/fonts/") |
| + fr.goTo(t, window) |
| + var got struct { |
| + Gate bool |
| + Loaded int |
| + Slide []string |
| + Chrome []string |
| + Visible bool |
| + } |
| + fr.eval(t, `document.fonts.ready.then(() => { |
| + const texts = (root, inside) => [...root.querySelectorAll('*')].filter((e) => (e.closest('[slides-slide]') !== null) === inside && |
| + [...e.childNodes].some((n) => n.nodeType === 3 && n.data.trim())).map((e) => getComputedStyle(e).fontFamily); |
| + const main = document.querySelector('main'); |
| + return { Gate: !!document.querySelector('meta[name="slides-fonts"]'), |
| + Loaded: [...document.fonts].filter((f) => /liberation/i.test(f.family) && f.status === 'loaded').length, |
| + Slide: texts(document.querySelector('[presenter-panel="now"]'), true), |
| + Chrome: texts(main, false).filter((f) => /liberation/i.test(f)), |
| + Visible: getComputedStyle(document.querySelector('[presenter-panel="now"] [slides-slide]')).visibility === 'visible' }; |
| + })`, &got) |
| + if !got.Gate { |
| + t.Errorf("%s: the presenter window does not take the font gate", window) |
| + } |
| + if got.Loaded == 0 || fr.hits("/static/fonts/") == before { |
| + t.Errorf("%s: no deck face was loaded for the live slides (%d loaded)", window, got.Loaded) |
| + } |
| + if !got.Visible || len(got.Slide) == 0 { |
| + t.Fatalf("%s: the current slide is not shown (visible %v, %d runs of text)", window, got.Visible, len(got.Slide)) |
| + } |
| + for _, f := range got.Slide { |
| + if !strings.Contains(strings.ToLower(f), "liberation") { |
| + t.Errorf("%s: slide text in %q, not the deck's face", window, f) |
| } |
| } |
| + if len(got.Chrome) != 0 { |
| + t.Errorf("%s: the window's own words are set in a deck face: %v", window, got.Chrome) |
| + } |
| } |
| // inFallback matches a face description of a Liberation family drawn in |
diff --git a/internal/slidestest/leaving_browser_test.go b/internal/slidestest/leaving_browser_test.go| index 149a0de..100fee8 100644 |
| --- a/internal/slidestest/leaving_browser_test.go |
| +++ b/internal/slidestest/leaving_browser_test.go |
| @@ -148,7 +148,7 @@ func leaveAndComeBack(t *testing.T, surface string, cmd *exec.Cmd) { |
| caughtUp = `(document.querySelector('[slides-surface]') || { getAttribute: () => '' }).getAttribute('data-slide') === '2'` |
| case "presenter": |
| path = "/p/" + session + "/notes?t=" + token |
| - caughtUp = `(document.querySelector('[slides-preview]') || { getAttribute: () => '' }).getAttribute('data-slide') === '2'` |
| + caughtUp = `(document.querySelector('[presenter]') || { getAttribute: () => '' }).getAttribute('data-slide') === '2'` |
| case "remote": |
| path = "/p/" + session + "/remote?t=" + token |
| caughtUp = `(document.querySelector('[slides-remote]') || { getAttribute: () => '' }).getAttribute('data-slide') === '2'` |
diff --git a/internal/slidestest/present_steps_test.go b/internal/slidestest/present_steps_test.go| index 815d089..6293085 100644 |
| --- a/internal/slidestest/present_steps_test.go |
| +++ b/internal/slidestest/present_steps_test.go |
| @@ -241,6 +241,22 @@ func pictures(page string) (current, next string) { |
| return current, next |
| } |
| +var panelSlide = regexp.MustCompile(`(?s)<div presenter-panel="(now|next)">.*?<section slides-slide[^>]*data-id="([^"]+)"`) |
| + |
| +// panelSlides is the presenter window's two slides, named as pictures |
| +// would be, so one comparison serves both screens. |
| +func panelSlides(session, page string) (current, next string) { |
| + for _, m := range panelSlide.FindAllStringSubmatch(page, -1) { |
| + name := "/p/" + session + "/slides/" + m[2] + ".svg" |
| + if m[1] == "now" { |
| + current = name |
| + } else { |
| + next = name |
| + } |
| + } |
| + return current, next |
| +} |
| + |
| // TestComingNextIsInTheTalkBeingGiven: the slide the remote and the |
| // presenter view show coming next is the next one of the talk being |
| // given, so the short version never previews a full-only slide, and |
| @@ -263,6 +279,10 @@ func TestComingNextIsInTheTalkBeingGiven(t *testing.T) { |
| for _, screen := range []string{"remote", "notes"} { |
| page := mustGet(t, a, "/p/"+session+"/"+screen+"?t="+url.QueryEscape(token), http.StatusOK, nil).Body.String() |
| current, next := pictures(page) |
| + if screen == "notes" { |
| + // The presenter window draws its slides live (Task 9). |
| + current, next = panelSlides(session, page) |
| + } |
| if current != "/p/"+session+"/slides/plain.svg" || next != "/p/"+session+"/slides/"+c.next+".svg" { |
| t.Errorf("%s in %s mode: pictures %q then %q, want plain then %s", screen, c.mode, current, next, c.next) |
| } |
diff --git a/internal/slidestest/present_test.go b/internal/slidestest/present_test.go| index c69115f..be285c5 100644 |
| --- a/internal/slidestest/present_test.go |
| +++ b/internal/slidestest/present_test.go |
| @@ -43,6 +43,30 @@ func codeOn(t *testing.T, page string) string { |
| return m[1] |
| } |
| +// sessionCode is a session's pairing code, read off its row: the |
| +// presenter window shows no pairing block (pairing moves to its ⋯ menu, |
| +// Task 13), so a test that needs the code takes it from where it is. |
| +func sessionCode(t *testing.T, a *testApp, session string) string { |
| + t.Helper() |
| + var code string |
| + if err := a.db.G.Raw("SELECT code FROM presentations WHERE sqid = ?", session).Row().Scan(&code); err != nil { |
| + t.Fatalf("read the pairing code of %s: %v", session, err) |
| + } |
| + return code |
| +} |
| + |
| +// preDeploy makes a session one begun before positions, as migration |
| +// 0009 left such a row: it keeps the old presenter view, pairing block |
| +// and all. |
| +func preDeploy(t *testing.T, a *testApp, session string) { |
| + t.Helper() |
| + if err := a.db.G.Exec(`UPDATE presentations |
| + SET positional = NULL, slide_id = NULL, step = NULL, mode = NULL, seq = NULL, timer_at = NULL |
| + WHERE sqid = ?`, session).Error; err != nil { |
| + t.Fatalf("make %s a pre-deploy session: %v", session, err) |
| + } |
| +} |
| + |
| // startPresenting presses Present on a deck and returns the session's |
| // sqid and a freshly paired remote token (pairThroughRow). |
| func startPresenting(t *testing.T, a *testApp, deckPath string, cookies []*http.Cookie) (string, string) { |
| @@ -121,6 +145,10 @@ func TestPresentCreatesSessionWithCodeAndRemoteUrl(t *testing.T) { |
| } |
| session, token := startPresenting(t, a, path, cookies) |
| + // The pairing block is the old presenter view's, which a session |
| + // begun before positions keeps; a new session pairs from the |
| + // presenter window's menu (Task 13). |
| + preDeploy(t, a, session) |
| notes := mustGet(t, a, "/p/"+session+"/notes?t="+token, http.StatusOK, cookies).Body.String() |
| code := codeOn(t, notes) |
| @@ -374,8 +402,7 @@ func TestEndedSessionIs410(t *testing.T) { |
| path := sampleDeck(t, a, cookies) |
| session, token := startPresenting(t, a, path, cookies) |
| - notes := mustGet(t, a, "/p/"+session+"/notes?t="+token, http.StatusOK, cookies).Body.String() |
| - code := codeOn(t, notes) |
| + code := sessionCode(t, a, session) |
| mustGet(t, a, "/r/"+code+"?t="+token, http.StatusSeeOther, nil) |
| if rec := command(t, a, session, "end", token, "", nil); rec.Code != http.StatusNoContent { |
| @@ -420,8 +447,7 @@ func TestDeletingADeckEndsItsPresentations(t *testing.T) { |
| path := sampleDeck(t, a, cookies) |
| session, token := startPresenting(t, a, path, cookies) |
| - notes := mustGet(t, a, "/p/"+session+"/notes?t="+token, http.StatusOK, cookies).Body.String() |
| - code := codeOn(t, notes) |
| + code := sessionCode(t, a, session) |
| mustGet(t, a, "/p/"+session, http.StatusOK, nil) |
| // A projector watching, so this asserts what a projector actually |
| @@ -520,8 +546,7 @@ func TestScriptlessRemoteButtonsAreForms(t *testing.T) { |
| // The pair page is the way in for a typed code, and it is a form |
| // too — the QR is the shortcut, never the only route. |
| - notes := mustGet(t, a, "/p/"+session+"/notes?t="+token, http.StatusOK, cookies).Body.String() |
| - code := codeOn(t, notes) |
| + code := sessionCode(t, a, session) |
| pair := mustGet(t, a, "/r/"+code, http.StatusOK, nil).Body.String() |
| if !strings.Contains(pair, "<form") { |
| t.Errorf("the pair page has no form:\n%s", pair) |
diff --git a/internal/slidestest/presenter_window_browser_test.go b/internal/slidestest/presenter_window_browser_test.go| new file mode 100644 |
| index 0000000..d0a44eb |
| --- /dev/null |
| +++ b/internal/slidestest/presenter_window_browser_test.go |
| @@ -0,0 +1,124 @@ |
| +//go:build browser |
| + |
| +// The presenter window, measured (Task 9). It never scrolls: the |
| +// document is exactly the viewport at every size from 2560×1440 to |
| +// 320×568, at every step of a slide with four presses and 400 words of |
| +// notes, and every panel lies inside it. Only the notes scroll, inside |
| +// their own panel. |
| +package slidestest |
| + |
| +import ( |
| + "fmt" |
| + "net/url" |
| + "strconv" |
| + "strings" |
| + "testing" |
| + |
| + "github.com/chromedp/cdproto/emulation" |
| + "github.com/chromedp/chromedp" |
| +) |
| + |
| +// presenterSizes are the ten windows the presenter is measured in. |
| +var presenterSizes = []struct{ w, h int64 }{ |
| + {2560, 1440}, {1920, 1080}, {1680, 1050}, {1440, 900}, {1280, 720}, |
| + {1024, 768}, {800, 600}, {768, 1024}, {390, 844}, {320, 568}, |
| +} |
| + |
| +// longNotes is 400 words in five parts, one for each step of "steps". |
| +func longNotes() string { |
| + var parts []string |
| + for p := range 5 { |
| + var words []string |
| + for w := range 80 { |
| + words = append(words, "word"+strconv.Itoa(p*80+w)) |
| + } |
| + parts = append(parts, strings.Join(words, " ")+".") |
| + } |
| + return strings.Join(parts, "\n\n(Press.)\n\n") |
| +} |
| + |
| +type presenterBox struct { |
| + Name string `json:"name"` |
| + L float64 `json:"l"` |
| + T float64 `json:"t"` |
| + R float64 `json:"r"` |
| + B float64 `json:"b"` |
| +} |
| + |
| +type presenterGeometry struct { |
| + VW, VH float64 |
| + SH, SW float64 |
| + BSH, BSW float64 |
| + ScrollY float64 |
| + Boxes []presenterBox |
| +} |
| + |
| +const presenterGeometryJS = `(() => { |
| + window.scrollTo(0, 1); |
| + const de = document.documentElement, b = document.body; |
| + const boxes = [...document.querySelectorAll('[presenter-head], [presenter-panel], [presenter-frame]')].map(e => { |
| + const r = e.getBoundingClientRect(); |
| + return { name: e.getAttribute('presenter-panel') || (e.hasAttribute('presenter-head') ? 'head' : 'frame'), |
| + l: r.left, t: r.top, r: r.right, b: r.bottom }; |
| + }); |
| + return { VW: innerWidth, VH: innerHeight, SH: de.scrollHeight, SW: de.scrollWidth, |
| + BSH: b.scrollHeight, BSW: b.scrollWidth, ScrollY: window.scrollY, Boxes: boxes }; |
| +})()` |
| + |
| +func TestPresenterNeverScrolls(t *testing.T) { |
| + rig, app := newRigApp(t, nil) |
| + cookies := signedIn(t, app, allowedAddress) |
| + deck := stepsDeck(t, app, cookies) |
| + setNotes(t, app, cookies, deck, map[string]string{"steps": longNotes()}) |
| + session, token := startPresenting(t, app, deck, cookies) |
| + window := rig.Origin + "/p/" + session + "/notes?t=" + url.QueryEscape(token) |
| + // Once, bounded, so a window that is not there fails here and not |
| + // fifty times over. |
| + rig.Run(chromedp.Navigate(window), waitFor(`document.querySelector('[presenter-panel="notes"]')`)) |
| + |
| + for _, size := range presenterSizes { |
| + t.Run(fmt.Sprintf("%dx%d", size.w, size.h), func(t *testing.T) { |
| + rig.Run(emulation.SetDeviceMetricsOverride(size.w, size.h, 1, false)) |
| + // Each step as the session reaches it: with scripts on, a |
| + // page naming a state the talk is not in goes to where it is. |
| + press(t, app, session, token, url.Values{"op": {"goto"}, "slide": {"1"}, "press": {newPressID(t)}}, nil) |
| + for step := range 5 { |
| + if step > 0 { |
| + press(t, app, session, token, op(t, "next"), nil) |
| + } |
| + var g presenterGeometry |
| + rig.Run( |
| + chromedp.Navigate(window), |
| + waitFor(`document.querySelector('[presenter]')?.getAttribute('data-step') === '`+strconv.Itoa(step)+`'`), |
| + chromedp.Evaluate(presenterGeometryJS, &g), |
| + ) |
| + if g.SH != g.VH || g.SW != g.VW || g.BSH > g.VH || g.BSW > g.VW || g.ScrollY != 0 { |
| + t.Errorf("step %d: the document is %.0f×%.0f (body %.0f×%.0f, scrolled %.0f) in a %.0f×%.0f window", |
| + step, g.SW, g.SH, g.BSW, g.BSH, g.ScrollY, g.VW, g.VH) |
| + } |
| + if len(g.Boxes) < 6 { |
| + t.Fatalf("step %d: %d boxes measured, want the header, three panels and two frames", step, len(g.Boxes)) |
| + } |
| + for _, b := range g.Boxes { |
| + if b.L < 0 || b.T < 0 || b.R > g.VW || b.B > g.VH || b.R <= b.L || b.B <= b.T { |
| + t.Errorf("step %d: %s at (%.0f,%.0f)-(%.0f,%.0f) is not inside the %.0f×%.0f window", |
| + step, b.Name, b.L, b.T, b.R, b.B, g.VW, g.VH) |
| + } |
| + } |
| + } |
| + // The notes are all there, inside their own panel: the last |
| + // word is in it, and the panel scrolls to reach it. |
| + var reach struct { |
| + Last bool |
| + Scrolls bool |
| + Overflow string |
| + } |
| + rig.Run(waitFor(`document.querySelector('[presenter-notes]')`), chromedp.Evaluate(`(() => { const n = document.querySelector('[presenter-notes]'); |
| + return { Last: n.textContent.includes('word399'), Scrolls: n.scrollHeight > n.clientHeight, |
| + Overflow: getComputedStyle(n).overflowY }; })()`, &reach)) |
| + if !reach.Last || (reach.Scrolls && reach.Overflow != "auto") { |
| + t.Errorf("the notes lose text: last word there %v, overflowing %v, overflow-y %s", reach.Last, reach.Scrolls, reach.Overflow) |
| + } |
| + }) |
| + } |
| +} |
diff --git a/internal/slidestest/presenter_window_test.go b/internal/slidestest/presenter_window_test.go| new file mode 100644 |
| index 0000000..1c77345 |
| --- /dev/null |
| +++ b/internal/slidestest/presenter_window_test.go |
| @@ -0,0 +1,379 @@ |
| +package slidestest |
| + |
| +// The presenter window drawn by the server (Task 9): what a Positional |
| +// session's GET /p/{session}/notes serves, read as markup. The browser |
| +// half, which measures the window, is presenter_window_browser_test.go. |
| + |
| +import ( |
| + "net/http" |
| + "net/url" |
| + "regexp" |
| + "strings" |
| + "testing" |
| +) |
| + |
| +// presenterTalk is a session on stepsDeck, with notes on "steps" split |
| +// at the press line and plain notes on "plain". |
| +type presenterTalk struct { |
| + app *testApp |
| + cookies []*http.Cookie |
| + deck string |
| + session, token string |
| +} |
| + |
| +// stepsNotes are the notes on "steps": five parts for four presses. |
| +const stepsNotes = "Arrive on PARTZERO.\n\n(Press.)\n\nThen PARTONE.\n\n(Press.)\n\nThen PARTTWO.\n\n(Press.)\n\nThen PARTTHREE.\n\n(Press.)\n\nAnd PARTFOUR." |
| + |
| +func newPresenterTalk(t *testing.T) *presenterTalk { |
| + t.Helper() |
| + a := newApp(t) |
| + cookies := signedIn(t, a, allowedAddress) |
| + deck := stepsDeck(t, a, cookies) |
| + setNotes(t, a, cookies, deck, map[string]string{ |
| + "steps": stepsNotes, |
| + "plain": "Plain notes with PLAINWORDS in them.", |
| + }) |
| + session, token := startPresenting(t, a, deck, cookies) |
| + return &presenterTalk{app: a, cookies: cookies, deck: deck, session: session, token: token} |
| +} |
| + |
| +// setNotes writes slides' notes over the API. |
| +func setNotes(t *testing.T, a *testApp, cookies []*http.Cookie, deck string, notes map[string]string) { |
| + t.Helper() |
| + token := mintAgent(t, a, cookies, "notes-writer") |
| + var ops []string |
| + for id, md := range notes { |
| + ops = append(ops, `{"op":"set_notes","id":`+quote(id)+`,"markdown":`+quote(md)+`}`) |
| + } |
| + apiJSON(t, a, http.MethodPost, "/api/v1/decks/"+strings.TrimPrefix(deck, "/d/")+"/ops", token, |
| + `{"ops":[`+strings.Join(ops, ",")+`]}`, http.StatusOK) |
| +} |
| + |
| +// window is the presenter window at query (without the leading ?), read |
| +// by the token holder. |
| +func (pt *presenterTalk) window(t *testing.T, query string, cookies ...*http.Cookie) string { |
| + t.Helper() |
| + target := "/p/" + pt.session + "/notes?t=" + url.QueryEscape(pt.token) |
| + if query != "" { |
| + target += "&" + query |
| + } |
| + return mustGet(t, pt.app, target, http.StatusOK, cookies).Body.String() |
| +} |
| + |
| +func (pt *presenterTalk) press(t *testing.T, name string, times int) { |
| + t.Helper() |
| + for range times { |
| + press(t, pt.app, pt.session, pt.token, op(t, name), nil) |
| + } |
| +} |
| + |
| +// region is the markup of the first element carrying attr, up to the |
| +// element that follows it in the page: enough to tell which panel holds |
| +// what, without parsing the page. |
| +func region(t *testing.T, page, attr, until string) string { |
| + t.Helper() |
| + start := strings.Index(page, attr) |
| + if start < 0 { |
| + t.Fatalf("no %s on the page:\n%s", attr, page) |
| + } |
| + rest := page[start:] |
| + if end := strings.Index(rest, until); end > 0 { |
| + return rest[:end] |
| + } |
| + return rest |
| +} |
| + |
| +func TestPresenterStepCountOnlyWithSteps(t *testing.T) { |
| + pt := newPresenterTalk(t) |
| + |
| + page := pt.window(t, "") |
| + if !strings.Contains(page, "presenter-stepcount") || !strings.Contains(page, "step 0 of 4") { |
| + t.Errorf("on a slide with four presses the header has no step count:\n%s", page) |
| + } |
| + pt.press(t, "next", 2) |
| + if page := pt.window(t, ""); !strings.Contains(page, "step 2 of 4") { |
| + t.Errorf("two presses on, the step count does not say step 2 of 4:\n%s", page) |
| + } |
| + // The scriptless address draws its own step too. |
| + if page := pt.window(t, "slide=1&step=3"); !strings.Contains(page, "step 3 of 4") { |
| + t.Errorf("?slide=1&step=3 does not count step 3 of 4:\n%s", page) |
| + } |
| + |
| + pt.press(t, "next", 3) // onto "plain", which has no presses |
| + page = pt.window(t, "") |
| + if !strings.Contains(page, `data-id="plain"`) { |
| + t.Fatalf("five presses on, the window is not on the plain slide:\n%s", page) |
| + } |
| + if strings.Contains(page, "presenter-stepcount") || strings.Contains(page, " of 4") { |
| + t.Errorf("a slide with no steps draws a step count:\n%s", page) |
| + } |
| +} |
| + |
| +func TestNextPanelNamesWhatComesNext(t *testing.T) { |
| + pt := newPresenterTalk(t) |
| + |
| + // At step 1 of four: the same slide, one press on. |
| + page := pt.window(t, "slide=1&step=1") |
| + next := region(t, page, `<div presenter-panel="next"`, `<div presenter-panel="notes"`) |
| + if !strings.Contains(next, "Next step") { |
| + t.Errorf("mid-slide the next panel is not labelled Next step:\n%s", next) |
| + } |
| + if !strings.Contains(next, `data-id="steps"`) || strings.Count(next, "data-waiting") != 2 { |
| + t.Errorf("mid-slide the next panel is not this slide at step 2 (two presses waiting):\n%s", next) |
| + } |
| + |
| + // At the last step: the next slide in the short version, as it |
| + // arrives. "extra" is full only, so the short talk goes plain → last. |
| + page = pt.window(t, "slide=2&step=0") |
| + next = region(t, page, `<div presenter-panel="next"`, `<div presenter-panel="notes"`) |
| + if !strings.Contains(next, "Next slide") || !strings.Contains(next, `data-id="last"`) { |
| + t.Errorf("on plain in the short version the next panel is not Next slide, last:\n%s", next) |
| + } |
| + page = pt.window(t, "slide=1&step=4") |
| + next = region(t, page, `<div presenter-panel="next"`, `<div presenter-panel="notes"`) |
| + if !strings.Contains(next, "Next slide") || !strings.Contains(next, `data-id="plain"`) || strings.Contains(next, "data-waiting") { |
| + t.Errorf("at the last step the next panel is not the next slide as it arrives:\n%s", next) |
| + } |
| + |
| + // The full version's next slide after plain is extra. |
| + pt.press(t, "mode", 1) |
| + page = pt.window(t, "slide=2&step=0") |
| + next = region(t, page, `<div presenter-panel="next"`, `<div presenter-panel="notes"`) |
| + if !strings.Contains(next, `data-id="extra"`) { |
| + t.Errorf("in the full version the slide after plain is not extra:\n%s", next) |
| + } |
| + |
| + // The end of the talk: an empty frame. |
| + page = pt.window(t, "slide=4&step=0") |
| + next = region(t, page, `<div presenter-panel="next"`, `<div presenter-panel="notes"`) |
| + if !strings.Contains(next, "End of the talk") { |
| + t.Errorf("on the last slide the next panel does not say End of the talk:\n%s", next) |
| + } |
| + if strings.Contains(next, "slides-slide") { |
| + t.Errorf("at the end of the talk the next panel draws a slide:\n%s", next) |
| + } |
| +} |
| + |
| +// presenterCookie is the preferences cookie as a browser sends it: the |
| +// value percent-encoded, because a cookie value cannot hold a ";". |
| +func presenterCookie(value string) *http.Cookie { |
| + return &http.Cookie{Name: "slides-presenter", Value: url.QueryEscape(value)} |
| +} |
| + |
| +// arrangement is the window's arrangement as served: each panel's grid |
| +// area, in the order now, next, notes. |
| +var arrangement = regexp.MustCompile(`\[presenter-panel="(now|next|notes)"\]\s*\{\s*grid-area:\s*(\d+) / (\d+) / span (\d+) / span (\d+)`) |
| + |
| +func arranged(page string) string { |
| + var out []string |
| + for _, m := range arrangement.FindAllStringSubmatch(page, -1) { |
| + out = append(out, m[1]+":"+m[2]+","+m[3]+","+m[4]+","+m[5]) |
| + } |
| + return strings.Join(out, " ") |
| +} |
| + |
| +const defaultArrangement = "now:1,1,8,7 next:9,1,4,7 notes:1,8,12,5" |
| + |
| +func TestPresenterFirstPaintIsFinal(t *testing.T) { |
| + pt := newPresenterTalk(t) |
| + if got := arranged(pt.window(t, "")); got != defaultArrangement { |
| + t.Errorf("with no cookie the arrangement is %q, want the default %q", got, defaultArrangement) |
| + } |
| + |
| + page := pt.window(t, "", presenterCookie("scroll.32.0,0,6,6;6,0,6,6;0,6,12,6")) |
| + if got, want := arranged(page), "now:1,1,6,6 next:1,7,6,6 notes:7,1,6,12"; got != want { |
| + t.Errorf("the cookie's arrangement is served as %q, want %q", got, want) |
| + } |
| + if !regexp.MustCompile(`\[presenter-notes\]\s*\{\s*font-size:\s*32px`).MatchString(page) { |
| + t.Errorf("the cookie's notes size of 32 is not in the served page") |
| + } |
| + if !regexp.MustCompile(`presenter-notes-scroll[^>]*aria-pressed="true"`).MatchString(page) || |
| + !regexp.MustCompile(`presenter-notes-fit[^>]*aria-pressed="false"`).MatchString(page) { |
| + t.Errorf("the cookie's choice of Scroll is not pressed in the served page") |
| + } |
| +} |
| + |
| +func TestPresenterPrefsRefuseNonsense(t *testing.T) { |
| + pt := newPresenterTalk(t) |
| + for _, bad := range []string{ |
| + "", |
| + "garbage", |
| + "fit.24", |
| + "fit.24.0,0,7,8;0,8,7,4", // two panels |
| + "fit.24.0,0,7,8;0,8,7,4;7,0,5,12;0,0,2,2", // four |
| + "wide.24.0,0,7,8;0,8,7,4;7,0,5,12", // not fit or scroll |
| + "fit.25.0,0,7,8;0,8,7,4;7,0,5,12", // odd |
| + "fit.14.0,0,7,8;0,8,7,4;7,0,5,12", // under 16 |
| + "fit.50.0,0,7,8;0,8,7,4;7,0,5,12", // over 48 |
| + "fit.x.0,0,7,8;0,8,7,4;7,0,5,12", // not a number |
| + "fit.24.0,0,7,8;0,8,7,4;7,0,6,12", // off the grid |
| + "fit.24.-1,0,7,8;0,8,7,4;7,0,5,12", // off the grid |
| + "fit.24.0,0,7,8;0,8,7,4;7,0,5,13", // off the grid |
| + "fit.24.0,0,7,8;0,8,7,4;7,0,1,12", // under 2 wide |
| + "fit.24.0,0,7,8;0,8,7,1;7,0,5,12", // under 2 tall |
| + "fit.24.0,0,7,8;0,6,7,6;7,0,5,12", // now and next overlap |
| + "fit.24.0,0,8,8;0,8,7,4;7,0,5,12", // now and notes overlap |
| + "fit.24.0,0,7,8;0,8,7,4;7,0,5,12,1", // five numbers |
| + "fit.24.0,0,7,8;0,8,7,4;7,0,5", // three numbers |
| + "fit.24.0,0,7,8;0,8,7,4;7,0,5,12.extra", // a fourth part |
| + "fit.24.0, 0,7,8;0,8,7,4;7,0,5,12", // a space |
| + "fit.024.0,0,7,8;0,8,7,4;7,0,5,12x", // trailing junk |
| + "%%%", |
| + } { |
| + page := pt.window(t, "", presenterCookie(bad)) |
| + if got := arranged(page); got != defaultArrangement { |
| + t.Errorf("cookie %q: arrangement %q, want the default %q", bad, got, defaultArrangement) |
| + } |
| + if !regexp.MustCompile(`\[presenter-notes\]\s*\{\s*font-size:\s*24px`).MatchString(page) || |
| + !regexp.MustCompile(`presenter-notes-fit[^>]*aria-pressed="true"`).MatchString(page) { |
| + t.Errorf("cookie %q: the notes are not the default Fit at 24", bad) |
| + } |
| + } |
| +} |
| + |
| +// notesSections is the notes panel's sections, as "state:text" pairs. |
| +var notesSection = regexp.MustCompile(`(?s)<section presenter-part(?: data-part="(\w+)")?>(.*?)</section>`) |
| + |
| +func sections(t *testing.T, page string) []string { |
| + t.Helper() |
| + notes := region(t, page, "<div presenter-notes", "presenter-tools") |
| + var out []string |
| + for _, m := range notesSection.FindAllStringSubmatch(notes, -1) { |
| + text := regexp.MustCompile(`<[^>]+>`).ReplaceAllString(m[2], "") |
| + out = append(out, m[1]+":"+strings.TrimSpace(text)) |
| + } |
| + return out |
| +} |
| + |
| +func TestPresenterNotesWithoutThePressLineStayPlain(t *testing.T) { |
| + pt := newPresenterTalk(t) |
| + |
| + // Split notes: the part for the step is bright, the rest dimmed, |
| + // and the press lines are not shown. |
| + page := pt.window(t, "slide=1&step=2") |
| + if strings.Contains(page, "(Press.)") { |
| + t.Errorf("the presenter window shows the press lines") |
| + } |
| + got := strings.Join(sections(t, page), " | ") |
| + want := "past:Arrive on PARTZERO. | past:Then PARTONE. | now:Then PARTTWO. | later:Then PARTTHREE. | later:And PARTFOUR." |
| + if got != want { |
| + t.Errorf("notes at step 2:\n got %s\nwant %s", got, want) |
| + } |
| + |
| + // Without the line: one plain section, neither bright nor dimmed. |
| + page = pt.window(t, "slide=2&step=0") |
| + if got := strings.Join(sections(t, page), " | "); got != ":Plain notes with PLAINWORDS in them." { |
| + t.Errorf("notes with no press line are %q, want one plain section", got) |
| + } |
| + |
| + // No notes at all: the catalog's words. |
| + page = pt.window(t, "slide=4&step=0") |
| + if !strings.Contains(region(t, page, "<div presenter-notes", "presenter-tools"), "No notes on this slide.") { |
| + t.Errorf("a slide with no notes does not say so") |
| + } |
| +} |
| + |
| +func TestPresenterIsOnlyForThePresenter(t *testing.T) { |
| + pt := newPresenterTalk(t) |
| + base := "/p/" + pt.session + "/notes" |
| + |
| + // The signed-in presenter, and the token holder. |
| + if page := mustGet(t, pt.app, base, http.StatusOK, pt.cookies).Body.String(); !strings.Contains(page, "presenter-head") { |
| + t.Errorf("the signed-in presenter is not shown the presenter window:\n%s", page) |
| + } |
| + if page := mustGet(t, pt.app, base+"?t="+url.QueryEscape(pt.token), http.StatusOK, nil).Body.String(); !strings.Contains(page, "presenter-head") { |
| + t.Errorf("the token holder is not shown the presenter window:\n%s", page) |
| + } |
| + |
| + // Nobody else: no credential, a wrong token, the picker, a state. |
| + for _, target := range []string{base, base + "?t=wrong", base + "?pick=1", base + "?slide=1&step=1"} { |
| + mustGet(t, pt.app, target, http.StatusNotFound, nil) |
| + } |
| + // Somebody else signed in. |
| + if err := pt.app.db.G.Exec("UPDATE presentations SET actor = ? WHERE sqid = ?", "user:someone-else", pt.session).Error; err != nil { |
| + t.Fatal(err) |
| + } |
| + mustGet(t, pt.app, base, http.StatusNotFound, pt.cookies) |
| + mustGet(t, pt.app, base+"?pick=1", http.StatusNotFound, pt.cookies) |
| + |
| + // A session begun before positions keeps today's presenter view. |
| + if err := pt.app.db.G.Exec(`UPDATE presentations |
| + SET positional = NULL, slide_id = NULL, step = NULL, mode = NULL, seq = NULL, timer_at = NULL |
| + WHERE sqid = ?`, pt.session).Error; err != nil { |
| + t.Fatal(err) |
| + } |
| + page := mustGet(t, pt.app, base+"?t="+url.QueryEscape(pt.token), http.StatusOK, nil).Body.String() |
| + if !strings.Contains(page, "slides-preview") || strings.Contains(page, "presenter-head") { |
| + t.Errorf("a pre-deploy session is not served the old presenter view:\n%s", page) |
| + } |
| +} |
| + |
| +func TestScriptlessPickerMovesTheTalk(t *testing.T) { |
| + pt := newPresenterTalk(t) |
| + window := "/p/" + pt.session + "/notes?t=" + url.QueryEscape(pt.token) |
| + |
| + // The window's position opens the picker. |
| + page := pt.window(t, "") |
| + if !strings.Contains(page, `href="/p/`+pt.session+`/notes?pick=1&t=`) { |
| + t.Errorf("the position does not link to the picker:\n%s", page) |
| + } |
| + |
| + pick := pt.window(t, "pick=1") |
| + if strings.Contains(pick, "PARKED") || strings.Contains(pick, "parked.svg") || strings.Contains(pick, `value="parked"`) { |
| + t.Errorf("the picker lists the parked slide:\n%s", pick) |
| + } |
| + // The slide on screen is a way back to the window, moving nothing; |
| + // every other slide is a form that goes there. |
| + if !strings.Contains(pick, `aria-current="true" href="/p/`+pt.session+`/notes?t=`) || |
| + strings.Contains(pick, `<input type="hidden" name="slide" value="1">`) { |
| + t.Errorf("the slide on screen is not a plain link back to the window:\n%s", pick) |
| + } |
| + for _, n := range []string{"2", "3", "4"} { |
| + if !strings.Contains(pick, `<input type="hidden" name="slide" value="`+n+`">`) { |
| + t.Errorf("the picker has no form for slide %s:\n%s", n, pick) |
| + } |
| + } |
| + if strings.Count(pick, "full version only") != 1 { |
| + t.Errorf("the picker does not mark the one full-only slide:\n%s", pick) |
| + } |
| + if !strings.Contains(pick, "4 slides") { |
| + t.Errorf("the picker does not count the talk's four slides:\n%s", pick) |
| + } |
| + |
| + // Choosing extra, a full-only slide, in the short version: the talk |
| + // goes there in full, and the browser lands on the window, not the |
| + // picker, drawing that state. |
| + rec := command(t, pt.app, pt.session, "goto", pt.token, testOrigin+window+"&pick=1", url.Values{"slide": {"3"}}) |
| + if rec.Code != http.StatusSeeOther { |
| + t.Fatalf("goto from the picker: status %d, want 303\n%s", rec.Code, rec.Body) |
| + } |
| + loc, err := url.Parse(rec.Header().Get("Location")) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if loc.Path != "/p/"+pt.session+"/notes" || loc.Query().Has("pick") || |
| + loc.Query().Get("slide") != "3" || loc.Query().Get("step") != "0" || loc.Query().Get("t") != pt.token { |
| + t.Errorf("goto from the picker lands on %s, want the window at slide 3, step 0", loc) |
| + } |
| + page = mustGet(t, pt.app, loc.RequestURI(), http.StatusOK, nil).Body.String() |
| + now := region(t, page, `<div presenter-panel="now"`, `<div presenter-panel="next"`) |
| + if !strings.Contains(now, `data-id="extra"`) { |
| + t.Errorf("after goto 3 the window does not show extra:\n%s", now) |
| + } |
| + if !regexp.MustCompile(`presenter-mode[^>]*>\s*Full\s*<`).MatchString(page) { |
| + t.Errorf("a goto to a full-only slide did not switch to the full version:\n%s", page) |
| + } |
| + |
| + // And the window's own Next is a form that moves the talk. |
| + next := regexp.MustCompile(`(?s)<form method="post" action="/p/` + pt.session + `/command"[^>]*>\s*<input type="hidden" name="op" value="next">.*?</form>`).FindString(page) |
| + if next == "" { |
| + t.Fatalf("the window has no Next form:\n%s", page) |
| + } |
| + rec = command(t, pt.app, pt.session, "next", pt.token, testOrigin+loc.RequestURI(), nil) |
| + if rec.Code != http.StatusSeeOther { |
| + t.Fatalf("next: status %d", rec.Code) |
| + } |
| + if got := rec.Header().Get("Location"); !strings.Contains(got, "slide=4") { |
| + t.Errorf("next from extra lands on %s, want slide 4", got) |
| + } |
| +} |