Slides shaped like Docs: a deck opens in the editor, Share in the bar, who-can-open on Share, the viewer's rail
Paul, 2026-11-11, on the viewer: "These are all muddled up ... Share
should go where it does on Docs ... Deck settings should be in an
inspector like on docs", "Shouldn't this be in a vertical rail on the
left-hand side?", and "Did we ever get anywhere on being able to
actually edit the Slides?" He had landed on the viewer.
- A deck opens in the editor. The list links to /edit, and the bare
/d/{sqid} redirects signed-in readers there after deckFor, so a
stranger still gets a 404. The viewer is /d/{sqid}?slide=N. Share
links and presenting are unchanged.
- The viewer: the title and Share... are in the estilo bar (Share...
for mayShareDeck only); its actions are Edit, Present and a ... menu
(All notes, Export PDF). From 1100px the filmstrip is a vertical rail
on the left, which keeps its scroll position when the slide changes
in place.
- Who can open the deck (the rung) is a POST form on the Share page
(mayChangeRung; orphan rules held; in the lapse table). Deck settings
is no longer linked; the inspector has title, theme, accent and fonts.
/settings is kept as the scripts-off fallback, and its ways out go to
the viewer.
- The editor's noscript notice sits under the bar.
Reviewed by Claude Fable 5.1 (claude-fable-5-1) on oficina/slides #43:
APPROVED at c8588cb. Its P2 (settings page's ways out) was taken at
72d59a9 and gofmt fixed at 5b4dfef. Hub CI green at 5b4dfef.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Squashed from design/docs-shape into main.
43 files changed,
+749
−241
AGENTS.md+14 −4fixtures/engines/first-reveal.mjs+6 −6fixtures/viewer-nav.mjs+42 −0internal/slides/app.go+11 −3internal/slides/chrome.go+5 −1internal/slides/credits/assets.json+1 −1internal/slides/decks.go+65 −41internal/slides/editor.go+13 −9internal/slides/icons/icons.go+2 −0internal/slides/locales/en.toml+14 −3internal/slides/share.go+85 −5internal/slides/static/editor.css+21 −0internal/slides/static/fontsgate.3753849cb5b94339.js+0 −1internal/slides/static/fontsgate.971e476eab8b8588.js+1 −0internal/slides/team_access_test.go+15 −11internal/slides/team_guard_test.go+5 −2internal/slides/team_review_test.go+29 −6internal/slides/team_survivors_test.go+2 −2internal/slides/templates/deck_settings.html+11 −9internal/slides/templates/editor.html+10 −4internal/slides/templates/share.html+31 −5internal/slides/templates/viewer.html+139 −34internal/slides/viewer.go+45 −35internal/slidestest/browser_assets_test.go+1 −1internal/slidestest/browser_csp_test.go+1 −1internal/slidestest/browser_editor_strip_test.go+1 −1internal/slidestest/browser_phone_test.go+2 −2internal/slidestest/browser_present_test.go+4 −4internal/slidestest/browser_test.go+6 −6internal/slidestest/capabilities_test.go+1 −1internal/slidestest/decks_test.go+4 −4internal/slidestest/editor_test.go+4 −3internal/slidestest/export_test.go+2 −2internal/slidestest/fontgate_test.go+2 −2internal/slidestest/fonts_browser_test.go+6 −6internal/slidestest/fonts_test.go+3 −3internal/slidestest/list_test.go+7 −6internal/slidestest/live_test.go+1 −1internal/slidestest/present_test.go+1 −1internal/slidestest/save_status_browser_test.go+1 −1internal/slidestest/serving_test.go+1 −1internal/slidestest/share_test.go+64 −1internal/slidestest/viewer_test.go+70 −12
CI passed — run details
diff --git a/AGENTS.md b/AGENTS.md| index 84548c1..bb73e69 100644 |
| --- a/AGENTS.md |
| +++ b/AGENTS.md |
| @@ -67,10 +67,20 @@ seeded on first sign-in — and comes back out as a PDF. |
| ruling 16, codex 6). On a team instance Home's roster replaces that |
| recheck (spec §6.4, "Team mode" below). |
| - **Decks**: list, create, settings, delete, three rungs (private, |
| - granted, team) per suite ruling 15. |
| -- **The viewer** (`internal/slides/viewer.go`): one slide per page, |
| - previous and next as ordinary links (changed in place with a script, |
| - `fixtures/viewer-nav.mjs`), notes in a `<details>`. The owner, |
| + granted, team) per suite ruling 15. A deck opens in the editor, as a |
| + document does in Docs: the list links `/d/{sqid}/edit`, and the bare |
| + `/d/{sqid}` is a 303 there (after `deckFor`, so a stranger still gets |
| + the 404). Who can open a deck is chosen on its share page |
| + (`POST /d/{sqid}/share/access`, `mayChangeRung`), as general access |
| + is under Share in Docs; the settings page is the scriptless title and |
| + theme form, linked only from the editor's `<noscript>`. |
| +- **The viewer** (`internal/slides/viewer.go`): `/d/{sqid}?slide=N`, |
| + one slide per page, previous and next as ordinary links (changed in |
| + place with a script, `fixtures/viewer-nav.mjs`), notes in a |
| + `<details>`, the slides as a rail at its side from 1100px. Shaped as |
| + Docs shapes a document: the deck's title is the bar's context and |
| + Share… the bar's action; the page's own row is Edit, Present and an |
| + overflow. The owner, |
| a team member and a stranger holding a share link all get the same page |
| from the same template with `mode` as a field, because the day those |
| three drift is the day one of them leaks the speaker notes. |
diff --git a/fixtures/engines/first-reveal.mjs b/fixtures/engines/first-reveal.mjs| index 41cfea6..d266bba 100644 |
| --- a/fixtures/engines/first-reveal.mjs |
| +++ b/fixtures/engines/first-reveal.mjs |
| @@ -32,10 +32,10 @@ const config = JSON.parse(process.env.SLIDES_ENGINES_CONFIG) |
| const pause = (ms) => new Promise((r) => setTimeout(r, ms)) |
| const scenarios = [ |
| - { name: 'viewer, nothing missing', deck: 'paper', path: (s) => '/d/' + s }, |
| - { name: 'viewer, the serif late', deck: 'paper', path: (s) => '/d/' + s, slowFont: /LiberationSerif-/, fontDelay: 8000, length: 10000 }, |
| - { name: 'viewer, no gate', deck: 'paper', path: (s) => '/d/' + s, block: /\/static\/fontsgate\./, length: 7500 }, |
| - { name: 'viewer, no hold', deck: 'paper', path: (s) => '/d/' + s, block: /\/static\/fontshold\./ }, |
| + { name: 'viewer, nothing missing', deck: 'paper', path: (s) => '/d/' + s + '?slide=1' }, |
| + { name: 'viewer, the serif late', deck: 'paper', path: (s) => '/d/' + s + '?slide=1', slowFont: /LiberationSerif-/, fontDelay: 8000, length: 10000 }, |
| + { name: 'viewer, no gate', deck: 'paper', path: (s) => '/d/' + s + '?slide=1', block: /\/static\/fontsgate\./, length: 7500 }, |
| + { name: 'viewer, no hold', deck: 'paper', path: (s) => '/d/' + s + '?slide=1', block: /\/static\/fontshold\./ }, |
| { name: 'projector, nothing missing', deck: 'projector', path: (s) => s }, |
| { name: 'projector, the code late', deck: 'projector', path: (s) => s, slowFont: /LiberationMono-/, fontDelay: 8000, length: 10000 }, |
| { name: 'editor, nothing missing', deck: 'paper', path: (s) => '/d/' + s + '/edit', editor: true }, |
| @@ -53,9 +53,9 @@ const scenarios = [ |
| // The prefetch has brought the family in: no wait at all. |
| { name: 'add a code block once the prefetch is done', deck: 'plain', path: (s) => '/d/' + s + '/edit', editor: true, length: 3000, action: 'add-code', prefetched: true, busy: false }, |
| // The probe's control: a run in a face that is loading, on purpose. |
| - { name: 'control: text in a face that has not loaded', deck: 'plain', path: (s) => '/d/' + s, length: 2500, probeControl: true }, |
| + { name: 'control: text in a face that has not loaded', deck: 'plain', path: (s) => '/d/' + s + '?slide=1', length: 2500, probeControl: true }, |
| // The control: shown, then hidden for a second. Must be caught. |
| - { name: 'control: hidden for a second after it is shown', deck: 'paper', path: (s) => '/d/' + s, control: true }, |
| + { name: 'control: hidden for a second after it is shown', deck: 'paper', path: (s) => '/d/' + s + '?slide=1', control: true }, |
| ] |
| const only = process.env.SLIDES_ENGINES_ONLY |
diff --git a/fixtures/viewer-nav.mjs b/fixtures/viewer-nav.mjs| index 044618e..9ff3d50 100644 |
| --- a/fixtures/viewer-nav.mjs |
| +++ b/fixtures/viewer-nav.mjs |
| @@ -113,7 +113,9 @@ export function mountViewerNav ({ fonts, doc = document, win = window } = {}) { |
| const active = doc.activeElement |
| const had = active && current.contains(active) ? active : null |
| const fresh = doc.importNode(next, true) |
| + const rail = railScroll(current) |
| current.replaceWith(fresh) |
| + keepRail(fresh, rail) |
| if (title) doc.title = title |
| if (push) win.history.pushState({ slidesViewer: true }, '', href) |
| if (had) refocus(fresh, had) |
| @@ -121,6 +123,44 @@ export function mountViewerNav ({ fonts, doc = document, win = window } = {}) { |
| prefetch() |
| } |
| + // The filmstrip is a rail that scrolls inside itself from 1100px and a |
| + // row that scrolls sideways below that. The swap replaces it with the |
| + // incoming page's, which would start scrolled to the top: so where the |
| + // reader had scrolled it is carried across, and then the new current |
| + // slide is brought into view within the rail — the rail, never the |
| + // page, so nothing else moves. |
| + function railScroll (from) { |
| + const nav = from.querySelector('[slides-film-nav]') |
| + const list = from.querySelector('[slides-film]') |
| + return { nav: nav ? nav.scrollTop : 0, list: list ? list.scrollLeft : 0 } |
| + } |
| + |
| + function keepRail (fresh, was) { |
| + const nav = fresh.querySelector('[slides-film-nav]') |
| + const list = fresh.querySelector('[slides-film]') |
| + if (nav) nav.scrollTop = was.nav |
| + if (list) list.scrollLeft = was.list |
| + revealCurrent(fresh) |
| + } |
| + |
| + function revealCurrent (from) { |
| + const current = from.querySelector('[slides-film] a[aria-current="true"]') |
| + if (!current) return |
| + for (const box of [from.querySelector('[slides-film-nav]'), from.querySelector('[slides-film]')]) { |
| + if (!box || typeof box.getBoundingClientRect !== 'function') continue |
| + const b = box.getBoundingClientRect() |
| + const c = current.getBoundingClientRect() |
| + if (box.scrollHeight > box.clientHeight) { |
| + if (c.top < b.top) box.scrollTop -= b.top - c.top + 8 |
| + else if (c.bottom > b.bottom) box.scrollTop += c.bottom - b.bottom + 8 |
| + } |
| + if (box.scrollWidth > box.clientWidth) { |
| + if (c.left < b.left) box.scrollLeft -= b.left - c.left + 8 |
| + else if (c.right > b.right) box.scrollLeft += c.right - b.right + 8 |
| + } |
| + } |
| + } |
| + |
| // refocus puts focus where a keyboard user expects it after the swap |
| // (Astra, #27): on the same control in the new slide's page — the |
| // link of the same rel, or the filmstrip entry of the same address — |
| @@ -185,6 +225,8 @@ export function mountViewerNav ({ fonts, doc = document, win = window } = {}) { |
| }) |
| // The entry the page was loaded at can be come back to, too. |
| win.history.replaceState({ slidesViewer: true }, '', win.location.href) |
| + // A page opened on slide 20 shows slide 20's place in the rail. |
| + if (root()) revealCurrent(root()) |
| prefetch() |
| return { go } |
| } |
diff --git a/internal/slides/app.go b/internal/slides/app.go| index 3b61cef..7afcabf 100644 |
| --- a/internal/slides/app.go |
| +++ b/internal/slides/app.go |
| @@ -170,7 +170,10 @@ func New(d *db.DB, cfg Config) (*http.ServeMux, *app, error) { |
| r.Get("/decks/new", a.newDeck) |
| r.Post("/decks", a.createDeck) |
| // /d/{sqid} is the deck's own short URL — short because it is |
| - // what a person pastes into a chat window. |
| + // what a person pastes into a chat window. Bare, it opens the |
| + // editor, as a document's address does in Docs; with a query |
| + // (?slide=N, which every link inside it carries) it is the |
| + // viewer (viewer.go's showDeck). |
| r.Get("/d/{sqid}", a.showDeck) |
| // Every slide's notes on one page — the crib sheet somebody |
| // presents from with scripts off (spec §8). |
| @@ -224,12 +227,17 @@ func New(d *db.DB, cfg Config) (*http.ServeMux, *app, error) { |
| // queue like a keystroke. With SLIDES_AI off it answers a |
| // signed-in person the 404 an unknown path does. |
| r.Post("/d/{sqid}/assist", a.assistDeck) |
| - // Sharing is the owner's, all three of these (share.go says |
| + // Sharing is the owner's, all four of these (share.go says |
| // why a team member who can read the deck still cannot mint a |
| - // link to it). |
| + // link to it). Who can open the deck is here too, as general |
| + // access is under Share in Docs. |
| r.Get("/d/{sqid}/share", a.deckShare) |
| r.Post("/d/{sqid}/share", a.mintShareLink) |
| + r.Post("/d/{sqid}/share/access", a.saveDeckAccess) |
| r.Post("/d/{sqid}/share/{id}/revoke", a.revokeShareLink) |
| + // The deck's title and theme as a form: the editor's inspector |
| + // is where they are changed, and this page is that for somebody |
| + // with scripts off (the editor's <noscript> links it). |
| r.Get("/d/{sqid}/settings", a.deckSettings) |
| r.Post("/d/{sqid}/settings", a.saveDeckSettings) |
| // Deleting gets its own URL and its own page, never a modal |
diff --git a/internal/slides/chrome.go b/internal/slides/chrome.go| index 32860e1..abf1149 100644 |
| --- a/internal/slides/chrome.go |
| +++ b/internal/slides/chrome.go |
| @@ -64,8 +64,11 @@ type frame struct { |
| // is the page's h1 (spec §10). |
| parts []string |
| // context is the open deck's title, shown in the bar on the deck's |
| - // sub-pages. |
| + // own pages: the viewer and every sub-page. |
| context string |
| + // actions are the bar's page actions (Docs' Share… on a document): |
| + // buttons at wide widths, rows in the Menu sheet below 800px. |
| + actions []chrome.Action |
| // public is a read-only page a stranger reaches (the share link): |
| // the brand is plain text, and "Sign in" carries no return path, |
| // because the path is a capability and must not be copied into |
| @@ -169,6 +172,7 @@ func (a *app) frameFor(r *http.Request, v viewerState, f frame) Frame { |
| Icon: brand.Path("slides"), |
| }, |
| Context: f.context, |
| + Actions: f.actions, |
| Labels: chrome.BarLabels{Skip: rastrillo.T(r, "slides.chrome.skip"), Menu: rastrillo.T(r, "slides.chrome.menu")}, |
| } |
| switch { |
diff --git a/internal/slides/credits/assets.json b/internal/slides/credits/assets.json| index 9176b82..d132c0c 100644 |
| --- a/internal/slides/credits/assets.json |
| +++ b/internal/slides/credits/assets.json |
| @@ -66,7 +66,7 @@ |
| "internal/slides/static/fonts/LiberationSerif-Italic.woff2": "4a770ae5fceacdacfa2a2aba18d18b73d8fabd946cce1f16cb0758a7f4ce50e0", |
| "internal/slides/static/fonts/LiberationSerif-Regular.ttf": "9caef765d2e891c10dd73658894f01e660fe0c1c83e0bda7d6edf561d8f623d4", |
| "internal/slides/static/fonts/LiberationSerif-Regular.woff2": "922f544d0eabdf45ecd389b3bb35367e670b736e40851d01e53c150352c012f2", |
| - "internal/slides/static/fontsgate.3753849cb5b94339.js": "3753849cb5b94339313dbfa11287ead30728f69ffafbe7704c7f4ec4639da0b8", |
| + "internal/slides/static/fontsgate.971e476eab8b8588.js": "971e476eab8b8588be520ac38eb823ab19beb2567db734555a7edc40d58567b2", |
| "internal/slides/static/fontshold.876f3d8d396da42f.js": "876f3d8d396da42f81954539f30b7200edfcde719d2920504707822f176a36ab", |
| "internal/slides/static/present.js": "046810f3116893a781471a721a7d4992df5e4dc312591501416ff4a2859f829e", |
| "internal/slides/static/rastrillo.js": "b1eac44b25a98ca8144c59dc792ac6c5f66570b40b14f5b428c6838f88e137a3", |
diff --git a/internal/slides/decks.go b/internal/slides/decks.go| index 5ac28ec..75b6bd0 100644 |
| --- a/internal/slides/decks.go |
| +++ b/internal/slides/decks.go |
| @@ -100,8 +100,9 @@ const ( |
| rungTeam = "team" |
| ) |
| -// settableRungs is what the settings screen offers, in the order it |
| -// offers them. Not every rung there is — see the constants above. |
| +// settableRungs is what the share page offers (share.go's access |
| +// form), in the order it offers them. Not every rung there is — see |
| +// the constants above. |
| var settableRungs = []string{rungPrivate, rungTeam} |
| // themeIDs are the six themes a deck can wear, in the order the picker |
| @@ -839,7 +840,8 @@ func splitRecent(cards []deckCard, n int) (recent, rest []deckCard) { |
| func (a *app) deckCardFor(r *http.Request, d Deck, by string, now time.Time) deckCard { |
| slides, first, counted := a.deckGlance(r.Context(), d) |
| card := deckCard{ |
| - Href: "/d/" + d.Sqid, |
| + // A deck opens in the editor, as a document does in Docs. |
| + Href: editorHref(d.Sqid), |
| Title: d.Title, |
| Sub: rowSub(r, slides, counted, by), |
| When: whenAgo(r, d.UpdatedAt, now), |
| @@ -1177,17 +1179,29 @@ func blankOpeningOps(title, theme string) ([]byte, error) { |
| } |
| // --- GET/POST /d/{sqid}/settings --- |
| +// |
| +// The deck's title and theme as a scriptless form. Nothing links it as a |
| +// destination any more: the editor's inspector holds both (with Docs' |
| +// shape, a deck's settings are an inspector, not a page), and who can |
| +// open the deck is on the share page. It stays for somebody with |
| +// scripts off — the editor's <noscript> links it — and the POST still |
| +// takes a rung, for a caller that posts one (the share page's form is |
| +// the screen that does now). |
| type deckSettingsPage struct { |
| shell |
| - Title string |
| - Action string |
| - TitleLabel string |
| - TitleValue string |
| - ThemeLabel string |
| - Themes []selectOption |
| - RungLegend string |
| - Rungs []choiceOption |
| + Title string |
| + Action string |
| + TitleLabel string |
| + TitleValue string |
| + ThemeLabel string |
| + Themes []selectOption |
| + // AccessHref is the share page, where who can open the deck is |
| + // chosen now (share.go's saveDeckAccess); empty for somebody who |
| + // may not share it. |
| + AccessHref string |
| + AccessBody string |
| + AccessLabel string |
| Submit string |
| CancelHref string |
| CancelLabel string |
| @@ -1199,34 +1213,40 @@ type deckSettingsPage struct { |
| Errors map[string]string |
| } |
| -func (a *app) settingsPage(r *http.Request, u User, d Deck, title, theme, rung string, errs map[string]string) deckSettingsPage { |
| +func (a *app) settingsPage(r *http.Request, u User, d Deck, title, theme string, errs map[string]string) deckSettingsPage { |
| base := "/d/" + d.Sqid |
| page := deckSettingsPage{ |
| - shell: a.shellFor(r, u, onDeck(rastrillo.T(r, "slides.deck.settings"), d.Title)), |
| - Title: rastrillo.T(r, "slides.deck.settings"), |
| - Action: base + "/settings", |
| - TitleLabel: rastrillo.T(r, "slides.deck.title.label"), |
| - TitleValue: title, |
| - ThemeLabel: rastrillo.T(r, "slides.deck.theme.label"), |
| - Themes: themeOptions(r, theme), |
| - RungLegend: rastrillo.T(r, "slides.deck.rung.legend"), |
| - Rungs: rungOptions(r, rung), |
| - Submit: rastrillo.T(r, "slides.deck.settings.submit"), |
| - CancelHref: base, |
| + shell: a.shellFor(r, u, onDeck(rastrillo.T(r, "slides.deck.settings"), d.Title)), |
| + Title: rastrillo.T(r, "slides.deck.settings"), |
| + Action: base + "/settings", |
| + TitleLabel: rastrillo.T(r, "slides.deck.title.label"), |
| + TitleValue: title, |
| + ThemeLabel: rastrillo.T(r, "slides.deck.theme.label"), |
| + Themes: themeOptions(r, theme), |
| + Submit: rastrillo.T(r, "slides.deck.settings.submit"), |
| + // The settings page is the scripts-off fallback now (the editor's |
| + // inspector is everyone else's), so its ways out go to the viewer, |
| + // which works without scripts, not to /d/{sqid} — that opens the |
| + // editor and its "needs scripts" notice (Claude Fable, #43). |
| + CancelHref: viewerStart(d.Sqid), |
| CancelLabel: rastrillo.T(r, "slides.cancel"), |
| DeleteHref: base + "/delete", |
| DeleteLabel: rastrillo.T(r, "slides.deck.delete"), |
| DeleteBody: rastrillo.T(r, "slides.deck.delete.lead"), |
| - BackHref: base, |
| + BackHref: viewerStart(d.Sqid), |
| BackLabel: rastrillo.T(r, "slides.deck.back"), |
| Errors: errs, |
| } |
| - // A roster owner on an orphan (team_owner.go) is offered what they |
| - // may change and nothing more: no rung, no delete. Outside team mode |
| - // the owner may do both and the page is as it always was. |
| - if !a.mayChangeRung(r.Context(), u, d) { |
| - page.Rungs = nil |
| + // Who can open the deck is the share page's now (Docs' place for |
| + // general access); this page says where it went. |
| + if a.mayShareDeck(r.Context(), u, d) { |
| + page.AccessHref = base + "/share" |
| + page.AccessBody = rastrillo.T(r, "slides.deck.settings.access") |
| + page.AccessLabel = rastrillo.T(r, "slides.share.action") |
| } |
| + // A roster owner on an orphan (team_owner.go) is offered what they |
| + // may change and nothing more: no delete. Outside team mode the |
| + // owner may and the page is as it always was. |
| if !a.mayDeleteDeck(r.Context(), u, d) { |
| page.DeleteHref = "" |
| } |
| @@ -1242,7 +1262,7 @@ func (a *app) deckSettings(w http.ResponseWriter, r *http.Request) { |
| if !ok { |
| return |
| } |
| - render(w, "deck_settings", a.settingsPage(r, u, d, d.Title, d.Theme, d.Rung, nil)) |
| + render(w, "deck_settings", a.settingsPage(r, u, d, d.Title, d.Theme, nil)) |
| } |
| // saveDeckSettings serves POST /d/{sqid}/settings. |
| @@ -1268,13 +1288,15 @@ func (a *app) saveDeckSettings(w http.ResponseWriter, r *http.Request) { |
| title := p.String("title") |
| theme := r.PostFormValue("theme") |
| rung := r.PostFormValue("rung") |
| + // The form no longer carries the rung (it is the share page's): a |
| + // POST without one leaves it where it is. |
| + if rung == "" { |
| + rung = d.Rung |
| + } |
| if !a.mayChangeRung(r.Context(), u, d) { |
| // Team mode, a roster owner on an orphan (team_owner.go): title |
| - // and theme only. The page offers no rung; one posted anyway |
| - // must be the deck's own, never a narrowing. |
| - if rung == "" { |
| - rung = d.Rung |
| - } |
| + // and theme only. A rung posted anyway must be the deck's own, |
| + // never a narrowing. |
| if rung != d.Rung { |
| a.errorPage(w, r, http.StatusForbidden, kindStatus, "") |
| return |
| @@ -1287,12 +1309,14 @@ func (a *app) saveDeckSettings(w http.ResponseWriter, r *http.Request) { |
| if !validTheme(theme) { |
| errs["Theme"] = rastrillo.T(r, "slides.deck.theme.invalid") |
| } |
| - if !validRung(rung) { |
| + // The deck's own rung passes even when it is one no screen sets |
| + // (granted): leaving it alone is not choosing it. |
| + if rung != d.Rung && !validRung(rung) { |
| errs["Rung"] = rastrillo.T(r, "slides.deck.rung.invalid") |
| } |
| if len(errs) > 0 { |
| w.WriteHeader(http.StatusUnprocessableEntity) |
| - render(w, "deck_settings", a.settingsPage(r, u, d, p.Echo()["title"], theme, rung, errs)) |
| + render(w, "deck_settings", a.settingsPage(r, u, d, p.Echo()["title"], theme, errs)) |
| return |
| } |
| @@ -1309,7 +1333,7 @@ func (a *app) saveDeckSettings(w http.ResponseWriter, r *http.Request) { |
| a.fail(w, r, "write the settings ops", err) |
| return |
| } |
| - http.Redirect(w, r, "/d/"+d.Sqid, http.StatusSeeOther) |
| + http.Redirect(w, r, viewerStart(d.Sqid), http.StatusSeeOther) |
| } |
| // --- GET/POST /d/{sqid}/delete --- |
| @@ -1345,10 +1369,10 @@ func (a *app) confirmDeleteDeck(w http.ResponseWriter, r *http.Request) { |
| Body: rastrillo.T(r, "slides.deck.delete.body"), |
| Action: base + "/delete", |
| Label: rastrillo.T(r, "slides.deck.delete.confirm"), |
| - CancelHref: base + "/settings", |
| + CancelHref: base, |
| CancelLabel: rastrillo.T(r, "slides.cancel"), |
| - BackHref: base + "/settings", |
| - BackLabel: rastrillo.T(r, "slides.deck.settings"), |
| + BackHref: base, |
| + BackLabel: rastrillo.T(r, "slides.deck.back"), |
| }) |
| } |
diff --git a/internal/slides/editor.go b/internal/slides/editor.go| index 6912346..9234df6 100644 |
| --- a/internal/slides/editor.go |
| +++ b/internal/slides/editor.go |
| @@ -55,9 +55,6 @@ type editorPage struct { |
| ClientColour string |
| BundleSrc string |
| - BackHref string |
| - BackLabel string |
| - |
| NewSlideLabel string |
| DuplicateLabel string |
| UndoLabel string |
| @@ -97,6 +94,10 @@ type editorPage struct { |
| LinkCancel string |
| NoScriptBody string |
| NoScriptLink string |
| + // NoScriptSettings names the settings form (decks.go): the title |
| + // and theme without the inspector, for somebody with scripts off. |
| + // Shown with SettingsHref, which is the only link to that page. |
| + NoScriptSettings string |
| // Themes is the deck section's theme picker, the settings screen's |
| // own list with the deck's theme selected. |
| @@ -113,8 +114,12 @@ type editorPage struct { |
| AcceptTypes string |
| // The header (I2, after Docs' editor): the deck's own links, each |
| // empty when this person may not use it, so the File menu lists |
| - // only what works for them. ViewHref is the viewer; NewDeckHref the |
| + // only what works for them. ViewHref is the viewer (its first |
| + // slide: the deck's bare address opens this page); NewDeckHref the |
| // deck list's create page; CreditsHref Help's Open source. |
| + // SettingsHref is the scriptless title-and-theme form, linked from |
| + // the <noscript> alone: with scripts on the inspector's Deck section |
| + // is those settings, and who can open the deck is Share's. |
| ViewHref, SettingsHref, ShareHref, ExportHref, NotesPageHref string |
| DeleteHref, NewDeckHref, CreditsHref string |
| // Keys are the menus' shortcuts, formatted for this request's |
| @@ -213,7 +218,7 @@ var editorStrings = []string{ |
| "status.error", |
| "head.title", "head.menus", "head.history", "head.inspector", "head.share", "head.newslide", "head.layouts", |
| "menu.file", "menu.edit", "menu.insert", "menu.slide", "menu.view", "menu.help", |
| - "file.newdeck", "file.view", "file.notes", "file.export", "file.settings", "file.delete", |
| + "file.newdeck", "file.view", "file.notes", "file.export", "file.delete", |
| "insert.slide", "insert.block", "view.notes", "view.inspector", "help.keys", "help.credits", |
| "keys.title", "keys.close", "keys.newslide", "keys.duplicate", "keys.present", "keys.undo", "keys.redo", |
| "keys.link", "keys.bold", "keys.italic", "keys.reorder", "keys.delete", "keys.code", "keys.highlight", |
| @@ -289,7 +294,7 @@ func (a *app) deckEditor(w http.ResponseWriter, r *http.Request) { |
| } |
| page := editorPage{ |
| shell: sh, |
| - ViewHref: base, |
| + ViewHref: viewerStart(d.Sqid), |
| NotesPageHref: base + "/notes", |
| ExportHref: base + "/export", |
| CreditsHref: "/help/open-source", |
| @@ -302,9 +307,6 @@ func (a *app) deckEditor(w http.ResponseWriter, r *http.Request) { |
| ClientColour: u.Colour, |
| BundleSrc: editorBundlePath(), |
| - BackHref: base, |
| - BackLabel: rastrillo.T(r, "slides.deck.back"), |
| - |
| NewSlideLabel: rastrillo.T(r, "slides.editor.slide.new"), |
| DuplicateLabel: rastrillo.T(r, "slides.editor.slide.duplicate"), |
| UndoLabel: rastrillo.T(r, "slides.editor.undo"), |
| @@ -336,6 +338,8 @@ func (a *app) deckEditor(w http.ResponseWriter, r *http.Request) { |
| NoScriptBody: rastrillo.T(r, "slides.editor.noscript"), |
| NoScriptLink: rastrillo.T(r, "slides.editor.noscript.link"), |
| + NoScriptSettings: rastrillo.T(r, "slides.editor.noscript.settings"), |
| + |
| Themes: themeOptions(r, view.Meta.Theme), |
| HasStore: a.cfg.Blobs != nil, |
| AcceptTypes: acceptTypes(), |
diff --git a/internal/slides/icons/icons.go b/internal/slides/icons/icons.go| index f2d0c16..a1b3254 100644 |
| --- a/internal/slides/icons/icons.go |
| +++ b/internal/slides/icons/icons.go |
| @@ -33,6 +33,8 @@ var icons = map[string]template.HTML{ |
| "info": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>`, |
| "kebab": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><circle cx="12" cy="12" r="1"/><circle cx="12" cy="5" r="1"/><circle cx="12" cy="19" r="1"/></svg>`, |
| "menu": `<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="M4 12h16"/><path d="M4 6h16"/><path d="M4 18h16"/></svg>`, |
| + "pencil": `<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="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"/><path d="m15 5 4 4"/></svg>`, |
| + "ellipsis": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/></svg>`, |
| "panel-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"><rect width="18" height="18" x="3" y="3" rx="2"/><path d="M15 3v18"/></svg>`, |
| "play": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><polygon points="6 3 20 12 6 21 6 3"/></svg>`, |
| "redo-2": `<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 14 5-5-5-5"/><path d="M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13"/></svg>`, |
diff --git a/internal/slides/locales/en.toml b/internal/slides/locales/en.toml| index debd6a7..8d92222 100644 |
| --- a/internal/slides/locales/en.toml |
| +++ b/internal/slides/locales/en.toml |
| @@ -150,6 +150,7 @@ slides.when.yesterday.alone = "Yesterday" |
| # better to call it (viewer.go's slideLabel). |
| slides.deck.settings = "Deck settings" |
| slides.deck.settings.submit = "Save settings" |
| +slides.deck.settings.access = "Who can open this deck, and its share links, are on the Share page." |
| slides.deck.back = "Back to the deck" |
| slides.deck.slide = "Slide {n}" |
| slides.deck.title.label = "Title" |
| @@ -254,7 +255,9 @@ slides.viewer.film = "All slides" |
| slides.viewer.tools = "This deck" |
| slides.viewer.notes = "Speaker notes" |
| slides.viewer.notes.page = "All notes" |
| -slides.viewer.share = "Share" |
| +# The overflow beside Edit and Present: the deck's other reading screens |
| +# (all the notes, the PDF). Its trigger is an icon; this is its name. |
| +slides.viewer.more = "More" |
| slides.viewer.present = "Present" |
| slides.viewer.edit = "Edit" |
| # A link, not a form: the export asks a question first (with the notes |
| @@ -303,6 +306,7 @@ slides.editor.link.remove = "Remove link" |
| slides.editor.link.cancel = "Cancel" |
| slides.editor.noscript = "Editing needs scripts, which are off in this browser. You can still read the deck." |
| slides.editor.noscript.link = "Open the deck" |
| +slides.editor.noscript.settings = "Rename it or change its theme" |
| # The strip's per-slide menu. "Slide actions" names the menu button, |
| # which otherwise shows only an icon; the items repeat the Slide |
| @@ -402,7 +406,6 @@ slides.editor.file.newdeck = "New deck" |
| slides.editor.file.view = "Open in the viewer" |
| slides.editor.file.notes = "All speaker notes" |
| slides.editor.file.export = "Export as PDF…" |
| -slides.editor.file.settings = "Deck settings…" |
| slides.editor.file.delete = "Delete deck…" |
| slides.editor.insert.slide = "New slide" |
| slides.editor.insert.block = "On this slide" |
| @@ -579,7 +582,15 @@ slides.notes.none = "No notes on this slide." |
| # The warning is stated before the button rather than in a help page: a |
| # share link is genuinely useful and genuinely means anyone who has it |
| # can read the deck, and the person deciding should see both. |
| -slides.share.title = "Share links" |
| +slides.share.title = "Share" |
| +# The bar's action on a deck, as on a document in Docs (docs.share.action): |
| +# it opens the page that asks who, so the ellipsis. |
| +slides.share.action = "Share…" |
| +slides.share.links = "Share links" |
| +slides.share.access.submit = "Save who can open it" |
| +# A roster owner on an orphaned deck (team_owner.go) may share it but not |
| +# change who can open it. |
| +slides.share.access.fixed = "Only the deck's owner can change who can open it." |
| slides.share.lead = "A share link opens this deck read-only, with no sign-in. The slides are what it shows — never the speaker notes, and never the settings." |
| slides.share.warning.title = "What a share link does" |
| slides.share.warning = "Anyone who has the link can open this deck, including anyone it gets forwarded to. It shows the deck as it is now, so later edits are visible through it too. Revoke it and the URL stops working." |
diff --git a/internal/slides/share.go b/internal/slides/share.go| index 631ff9d..e4c4126 100644 |
| --- a/internal/slides/share.go |
| +++ b/internal/slides/share.go |
| @@ -85,8 +85,25 @@ type shareRow struct { |
| type sharePage struct { |
| shell |
| - Title string |
| - DeckTitle string |
| + Title string |
| + DeckTitle string |
| + |
| + // Who can open the deck: the rung (spec §5), on this page because |
| + // it is the deck's general access, and Docs puts that under Share. |
| + // Rungs is the form, for somebody who may change it |
| + // (mayChangeRung); a roster owner on an orphan may share it but not |
| + // move it, and reads the rung as text instead (AccessCurrent). |
| + AccessHeading string |
| + AccessLegend string |
| + AccessAction string |
| + AccessSubmit string |
| + AccessError string |
| + Rungs []choiceOption |
| + AccessCurrent string |
| + AccessCurrentDesc string |
| + AccessFixed string |
| + |
| + LinksHeading string |
| Lead string |
| WarningTitle string |
| Warning string |
| @@ -125,10 +142,13 @@ func (a *app) deckShare(w http.ResponseWriter, r *http.Request) { |
| if !ok { |
| return |
| } |
| - a.renderSharePage(w, r, u, d, r.URL.Query().Get("new")) |
| + a.renderSharePage(w, r, u, d, r.URL.Query().Get("new"), d.Rung, "") |
| } |
| -func (a *app) renderSharePage(w http.ResponseWriter, r *http.Request, u User, d Deck, newToken string) { |
| +// renderSharePage draws the share page. rung is the rung the access form |
| +// shows chosen (the deck's own, or what a refused POST asked for), and |
| +// accessErr the sentence under it when the POST was refused. |
| +func (a *app) renderSharePage(w http.ResponseWriter, r *http.Request, u User, d Deck, newToken, rung, accessErr string) { |
| var links []ShareLink |
| if err := a.db.G.WithContext(r.Context()). |
| Where("deck_id = ?", d.ID). |
| @@ -142,6 +162,7 @@ func (a *app) renderSharePage(w http.ResponseWriter, r *http.Request, u User, d |
| shell: a.shellFor(r, u, sharePageFrame(r, d)), |
| Title: rastrillo.T(r, "slides.share.title"), |
| DeckTitle: d.Title, |
| + LinksHeading: rastrillo.T(r, "slides.share.links"), |
| Lead: rastrillo.T(r, "slides.share.lead"), |
| WarningTitle: rastrillo.T(r, "slides.share.warning.title"), |
| Warning: rastrillo.T(r, "slides.share.warning"), |
| @@ -152,6 +173,21 @@ func (a *app) renderSharePage(w http.ResponseWriter, r *http.Request, u User, d |
| EmptyTitle: rastrillo.T(r, "slides.share.empty.title"), |
| EmptyBody: rastrillo.T(r, "slides.share.empty.body"), |
| Links: make([]shareRow, 0, len(links)), |
| + |
| + AccessHeading: rastrillo.T(r, "slides.deck.rung.legend"), |
| + AccessLegend: rastrillo.T(r, "slides.deck.rung.legend"), |
| + AccessError: accessErr, |
| + } |
| + if a.mayChangeRung(r.Context(), u, d) { |
| + page.AccessAction = base + "/share/access" |
| + page.AccessSubmit = rastrillo.T(r, "slides.share.access.submit") |
| + page.Rungs = rungOptions(r, rung) |
| + } else { |
| + page.AccessCurrent = rungLabel(r, d.Rung) |
| + if d.Rung == rungPrivate || d.Rung == rungGranted || d.Rung == rungTeam { |
| + page.AccessCurrentDesc = rastrillo.T(r, "slides.rung."+d.Rung+".desc") |
| + } |
| + page.AccessFixed = rastrillo.T(r, "slides.share.access.fixed") |
| } |
| if newToken != "" { |
| page.NewURL = a.shareURL(newToken) |
| @@ -245,6 +281,50 @@ func (a *app) mintShareLink(w http.ResponseWriter, r *http.Request) { |
| http.Redirect(w, r, "/d/"+d.Sqid+"/share?new="+token, http.StatusSeeOther) |
| } |
| +// --- POST /d/{sqid}/share/access --- |
| + |
| +// saveDeckAccess serves POST /d/{sqid}/share/access: who can open the |
| +// deck, the rung. It used to be one field of the settings form; it is on |
| +// the share page now, beside the links, as general access is in Docs. |
| +// |
| +// The owner's alone (mayChangeRung): a roster owner on an orphan may |
| +// share it but not move its rung, because making it private hides it |
| +// from everybody, them included (team_owner.go). Only the row changes — |
| +// the rung is not part of the document — under the member guard, inside |
| +// the writer transaction, as every owner action is. |
| +func (a *app) saveDeckAccess(w http.ResponseWriter, r *http.Request) { |
| + u, ok := a.viewer(w, r) |
| + if !ok { |
| + return |
| + } |
| + d, ok := a.ownedDeckFor(w, r, u, a.mayChangeRung) |
| + if !ok { |
| + return |
| + } |
| + rung := r.PostFormValue("rung") |
| + if !validRung(rung) { |
| + w.WriteHeader(http.StatusUnprocessableEntity) |
| + a.renderSharePage(w, r, u, d, "", rung, rastrillo.T(r, "slides.deck.rung.invalid")) |
| + return |
| + } |
| + if rung != d.Rung { |
| + err := a.guarded(r.Context(), a.memberGuard(r.Context(), u), func(db *gorm.DB) error { |
| + // UpdateColumn: who can open a deck is not an edit of it, |
| + // so the list's "edited 2 hours ago" does not move. |
| + return db.Model(&Deck{}).Where("id = ? AND owner_id = ?", d.ID, d.OwnerID). |
| + UpdateColumn("rung", rung).Error |
| + }) |
| + if a.guardRefused(w, r, err) { |
| + return |
| + } |
| + if err != nil { |
| + a.fail(w, r, "change a deck's rung", err) |
| + return |
| + } |
| + } |
| + http.Redirect(w, r, "/d/"+d.Sqid+"/share", http.StatusSeeOther) |
| +} |
| + |
| // --- POST /d/{sqid}/share/{id}/revoke --- |
| // revokeShareLink serves POST /d/{sqid}/share/{id}/revoke. |
| @@ -368,7 +448,7 @@ func (a *app) sharedDeck(w http.ResponseWriter, r *http.Request) { |
| // A stranger's page: the brand is plain text and "Sign in" carries |
| // no return path, because this path is the capability. |
| - a.renderViewer(w, r, d, modeLink, "/s/"+token, a.publicShell(r, frame{parts: []string{d.Title}, public: true})) |
| + a.renderViewer(w, r, d, modeLink, "/s/"+token, a.publicShell(r, frame{parts: []string{d.Title}, context: d.Title, public: true})) |
| } |
| // --- GET /s/{token}/stream --- |
diff --git a/internal/slides/static/editor.css b/internal/slides/static/editor.css| index f6b5bae..b3e52de 100644 |
| --- a/internal/slides/static/editor.css |
| +++ b/internal/slides/static/editor.css |
| @@ -44,6 +44,27 @@ |
| grid-template-columns: minmax(0, 1fr); |
| min-block-size: 100dvh; |
| } |
| +/* With scripts off the <noscript> says the editor needs them and links |
| + the viewer. It is first in the root, but a grid places an item with no |
| + area after the named ones: it was under the whole desk, below the |
| + fold, while a deck opened here from the list. Under the bar instead. |
| + Only with scripting off: a page with scripts is untouched (a fourth |
| + row, even empty, would take a share of the root's stretched height |
| + and move the desk). */ |
| +@media (scripting: none) { |
| + [slides-editor] { |
| + grid-template-areas: |
| + "bar" |
| + "notice" |
| + "fonts" |
| + "desk"; |
| + } |
| + [slides-editor] > noscript { |
| + display: block; |
| + grid-area: notice; |
| + padding: var(--rst-sp-3) var(--rst-sp-4) 0; |
| + } |
| +} |
| [slides-editor] > [slides-fonts-status] { |
| padding-inline: var(--rst-sp-4); |
| } |
diff --git a/internal/slides/static/fontsgate.3753849cb5b94339.js b/internal/slides/static/fontsgate.3753849cb5b94339.js| deleted file mode 100644 |
| index f2a7a09..0000000 |
| --- a/internal/slides/static/fontsgate.3753849cb5b94339.js |
| +++ /dev/null |
| @@ -1 +0,0 @@ |
| -var G={sans:"Liberation Sans",serif:"Liberation Serif",mono:"Liberation Mono"},b=["sans","serif","mono"],W=/^[A-Za-z0-9 ,'._-]{1,200}$/;function k(e){if(typeof e!="string")return"";let o=e.trim();return W.test(o)?o:""}function U(e){if(typeof e!="string"||!e)return[];let o=new Set;for(let r of e.split(",")){let l=r.trim().replace(/^["']+|["']+$/g,"").toLowerCase();for(let u of b)l===G[u].toLowerCase()&&o.add(u)}return b.filter(r=>o.has(r))}function J(e,o){let r=o.themes||{},l=e&&typeof e.theme=="string"&&r[e.theme]?e.theme:o.defaultTheme,[u,a]=r[l]||["",""],d=e&&e.fonts;if(d&&typeof d=="object"){let m=k(d.heading),f=k(d.body);m&&(u=m),f&&(a=f)}return[u,a]}function D(e){return Array.isArray(e)?e.some(o=>Array.isArray(o)&&o.some(r=>r&&r.c)):!1}function Z(e){for(let o of e&&e.slides||[])for(let r of o.blocks||[])if(r.type==="code"||D(r.text)||r.type==="table"&&(r.props&&Array.isArray(r.props.cells)?r.props.cells:[]).some(D))return!0;return!1}function R(e,o){if(!e||!Array.isArray(e.slides)||e.slides.length===0)return[];let r=J(e.meta,o);Z(e)&&r.push(o.code);let l=new Set(r.flatMap(U));return b.filter(u=>l.has(u))}function F(e,o,{styleOf:r,hasCodeIn:l}=Q()){if(typeof e!="string"||!e)return[];let u=r(e)||"",a=[];for(let m of u.split(";")){let f=m.indexOf(":");if(f<0)continue;let p=m.slice(0,f).trim();(p==="--slides-font-heading"||p==="--slides-font-body")&&a.push(m.slice(f+1))}l(e)&&a.push(o.code);let d=new Set(a.flatMap(U));return b.filter(m=>d.has(m))}function Q(){let e=o=>{let r=document.createElement("template");return r.innerHTML=o,r.content};return{styleOf:o=>{let r=e(o).querySelector("[slides-slide]");return r?r.getAttribute("style"):""},hasCodeIn:o=>!!e(o).querySelector("pre, code")}}var H=2500,X=3e3,ee=4e3;function L(e,o){return new Promise(r=>o(()=>r("late"),e))}function V({manifest:e,fontSet:o,FontFaceCtor:r,root:l=null,setTimer:u=setTimeout}={}){let a=new Map,d=new Set,m=!1,f=t=>!!(e&&e.families&&e.families[t]),p=t=>{let s=a.get(t);return s||(s={state:"idle",faces:[],promise:null,added:!1},a.set(t,s)),s};function T(){if(!l)return;let t=b.filter(s=>a.has(s)&&a.get(s).state==="committed").join(" ");(l.getAttribute("data-slides-fonts-fallback")||"")!==t&&l.setAttribute("data-slides-fonts-fallback",t)}function y(t){if(!f(t))return Promise.resolve(!1);let s=p(t);if(s.state==="committed")return Promise.resolve(!1);if(s.promise)return s.promise;let n=e.families[t];return s.state="loading",s.promise=Promise.resolve().then(()=>(s.faces=n.faces.map(c=>new r(n.css,`url("${c.url}") format("woff2")`,{weight:String(c.weight),style:c.style,display:"block"})),Promise.all(s.faces.map(c=>c.load().then(()=>!0,()=>!1))))).then(c=>c.every(Boolean),()=>!1).then(c=>(s.state==="loading"&&(s.state=c?"loaded":"failed"),s.state==="loaded")),s.promise}let S=t=>{if(!f(t))return!0;let s=a.has(t)?a.get(t).state:"idle";return s==="loaded"||s==="committed"};function x(t){for(let s of t){if(!f(s))continue;let n=p(s);n.added||n.state==="committed"||(n.state="committed")}T()}function w(t){for(let s of t){if(!f(s))continue;let n=p(s);if(n.state==="loaded"&&!n.added){for(let c of n.faces)o.add(c);n.added=!0}(n.state==="loaded"||n.state==="committed")&&d.add(s)}}let i={web:!0,get manifest(){return e},ready:S,loaded:t=>f(t)&&a.has(t)&&a.get(t).state==="loaded",committed:t=>f(t)&&a.has(t)&&a.get(t).state==="committed",failed:t=>f(t)&&a.has(t)&&a.get(t).state==="failed",state:t=>a.has(t)?a.get(t).state:"idle",get inUse(){return[...d]},get fallback(){return b.filter(t=>a.has(t)&&a.get(t).state==="committed")},use:w,load:y,markShown(){m=!0},get shown(){return m},async gate(t,s){let n=t.filter(f),c=Promise.all(n.map(y));await Promise.race([c,L(s,u)]);let h=n.filter(E=>!i.loaded(E));return x(h),w(n),h},async waitFor(t,s=ee){let n=t.filter(f);if(n.every(S))return!0;let c=Promise.all(n.map(h=>S(h)?!0:y(h)));return await Promise.race([c,L(s,u)]),n.every(S)},async prepare(t,{timeout:s=X}={}){let n=[...new Set(t)].filter(f),c=n.filter(h=>!S(h));c.length&&(await Promise.race([Promise.all(c.map(y)),L(s,u)]),x(c.filter(h=>!i.loaded(h)))),w(n)},commitFallback(t){x(t.filter(s=>!S(s))),w(t)},async prefetch({idle:t=()=>Promise.resolve()}={}){for(let s of b)!f(s)||a.has(s)||(await t(),!a.has(s)&&await y(s))}};return i}function Y(){return{web:!1,manifest:null,ready:()=>!0,loaded:()=>!1,committed:()=>!1,failed:()=>!1,state:()=>"system",inUse:[],fallback:[],use(){},load:async()=>!1,markShown(){},shown:!0,gate:async()=>[],waitFor:async()=>!0,prepare:async()=>{},commitFallback(){},prefetch:async()=>{}}}function $(e,{setTimer:o=setTimeout,clearTimer:r=clearTimeout}={}){if(!e)return{say(){},clear(){},state:""};let l=e.querySelector("[slides-fonts-status-text]"),u=e.querySelector("[slides-fonts-status-dismiss]"),a=null,d=()=>e.getAttribute("data-state")||"";function m(f){f&&d()!==f||(r(a),e.removeAttribute("data-state"),l&&(l.textContent=""))}return u&&u.addEventListener("click",()=>m()),{say(f,p=0){r(a),e.setAttribute("data-state",f),l&&(l.textContent=e.getAttribute("data-"+f)||""),p&&(a=o(()=>m(f),p))},clear:m,get state(){return d()}}}var K="[slides-viewer], [slides-present]";function _({fonts:e,doc:o=document,win:r=window}={}){let l=()=>o.querySelector(K);if(!l()||!r.history||!r.history.pushState||typeof r.fetch!="function"||typeof r.DOMParser!="function")return null;let u=new Map,a=0,d=new AbortController;r.addEventListener("pagehide",()=>d.abort()),r.addEventListener("pageshow",i=>{i.persisted&&(d=new AbortController,w())});function m(i){let t;try{t=new URL(i,r.location.href)}catch{return null}return t.origin!==r.location.origin||t.pathname!==r.location.pathname||t.hash?null:t.href}async function f(i,{cached:t=!1}={}){let s=u.get(i);if(t&&s&&Date.now()-s.at<3e4)return s.html;let n=await r.fetch(i,{credentials:"same-origin",headers:{Accept:"text/html"},signal:d.signal});if(!n.ok)throw new Error(`viewer: ${i}: ${n.status}`);let c=await n.text();return u.set(i,{at:Date.now(),html:c}),u.size>6&&u.delete(u.keys().next().value),c}let p=i=>new r.DOMParser().parseFromString(i,"text/html");function T(i){let t=[...i.querySelectorAll("img[src]")].map(s=>{let n=new r.Image;return n.src=s.getAttribute("src"),n.decode?n.decode().catch(()=>{}):Promise.resolve()});return Promise.race([Promise.all(t),new Promise(s=>setTimeout(s,1500))])}async function y(i,{push:t}){let s=++a,n,c;try{let M=p(await f(i));if(n=M.querySelector(K),c=M.title,!n)throw new Error("viewer: not a viewer page");let N=n.querySelector("[slides-slide]");N&&e&&e.prepareSection&&await e.prepareSection(N.outerHTML),await T(n)}catch{s===a&&!d.signal.aborted&&r.location.assign(i);return}if(s!==a)return;let h=l(),E=o.activeElement,C=E&&h.contains(E)?E:null,v=o.importNode(n,!0);h.replaceWith(v),c&&(o.title=c),t&&r.history.pushState({slidesViewer:!0},"",i),C&&S(v,C),x(v),w()}function S(i,t){let s=null,n=t.getAttribute&&t.getAttribute("rel");n&&(s=i.querySelector(`[slides-pager] a[rel="${n}"]`)),!s&&t.closest&&t.closest("[slides-film]")&&(s=[...i.querySelectorAll("[slides-film] a[href]")].find(c=>c.getAttribute("href")===t.getAttribute("href"))||null),s||(s=i.querySelector("[slides-slide]"),s&&!s.hasAttribute("tabindex")&&s.setAttribute("tabindex","-1")),s&&s.focus({preventScroll:!0})}function x(i){let t=o.querySelector("[slides-announce]"),s=i.getAttribute("data-announce");t&&s&&(t.textContent=s)}function w(){(t=>typeof r.requestIdleCallback=="function"?r.requestIdleCallback(t,{timeout:2e3}):setTimeout(t,300))(async()=>{if(!d.signal.aborted)for(let t of l()?l().querySelectorAll('[slides-pager] a[rel="prev"], [slides-pager] a[rel="next"]'):[]){let s=m(t.href);if(s)try{let n=p(await f(s,{cached:!0})).querySelector("[slides-slide]");n&&e&&e.familiesOfSection&&e.load&&await Promise.all(e.familiesOfSection(n.outerHTML).map(c=>e.load(c)))}catch{}}})}return o.addEventListener("click",i=>{if(i.defaultPrevented||i.button!==0||i.metaKey||i.ctrlKey||i.shiftKey||i.altKey)return;let t=i.target.closest&&i.target.closest("a[href]");if(!t||!l()||!l().contains(t)||t.target||t.hasAttribute("download")||!t.closest("[slides-pager], [slides-film]"))return;let s=m(t.href);s&&(i.preventDefault(),y(s,{push:!0}))}),r.addEventListener("popstate",()=>{y(r.location.href,{push:!1})}),r.history.replaceState({slidesViewer:!0},"",r.location.href),w(),{go:y}}var te=3500,se=1e4,A=document.documentElement,O=A.getAttribute("data-slides-fonts")==="pending";O&&clearTimeout(globalThis.__slidesFontsHold);var g=null;try{let e=document.querySelector('meta[name="slides-fonts"]');g=e?JSON.parse(e.getAttribute("content")||"null"):null}catch{g=null}var z,re=new Promise(e=>{z=e}),P,oe=new Promise(e=>{P=e}),ne=e=>new Promise(o=>setTimeout(o,Math.max(0,e-performance.now())));function B(e){e.markShown(),A.getAttribute("data-slides-fonts")!=="shown"&&A.setAttribute("data-slides-fonts","shown"),e.fallback.length&&$(document.querySelector("[slides-fonts-status]")).say("substitute",se)}var I=!1,q=[];addEventListener("pagehide",()=>{I=!0});addEventListener("pageshow",e=>{if(!e.persisted)return;I=!1;let o=q;q=[];for(let r of o)r()});function ie(e){let o=navigator.connection;if(o&&(o.saveData||/(^|-)2g$/.test(o.effectiveType||"")))return Promise.resolve();let r=()=>new Promise(l=>typeof requestIdleCallback=="function"?requestIdleCallback(()=>l(),{timeout:5e3}):setTimeout(l,200)).then(()=>I?new Promise(l=>q.push(l)):void 0);return e.prefetch({idle:r})}async function ae(e){await e.gate(g.need||[],Math.max(0,H-performance.now())),P();let o=document.querySelector("[slides-editor]");o&&await Promise.race([re,ne(te)]),B(e),o&&(await ie(e),A.setAttribute("data-slides-fonts-prefetch","done"))}function j(e){return Object.assign(e,{fontsReady:oe,settled:()=>z(),familiesOfView:o=>g?R(o,g):[],familiesOfSection:o=>g?F(o,g):[],prepareSection:o=>e.web&&g?e.prepare(F(o,g)):Promise.resolve()})}if(!O||!g||typeof FontFace!="function"||!document.fonts){O&&A.setAttribute("data-slides-fonts","shown");let e=j(Y());P(),globalThis.slidesFonts=e,_({fonts:e})}else{let e=j(V({manifest:g,fontSet:document.fonts,FontFaceCtor:FontFace,root:A}));globalThis.slidesFonts=e,_({fonts:e}),ae(e).catch(o=>{console.error("fonts:",o),P(),B(e)})} |
diff --git a/internal/slides/static/fontsgate.971e476eab8b8588.js b/internal/slides/static/fontsgate.971e476eab8b8588.js| new file mode 100644 |
| index 0000000..86af045 |
| --- /dev/null |
| +++ b/internal/slides/static/fontsgate.971e476eab8b8588.js |
| @@ -0,0 +1 @@ |
| +var Q={sans:"Liberation Sans",serif:"Liberation Serif",mono:"Liberation Mono"},w=["sans","serif","mono"],X=/^[A-Za-z0-9 ,'._-]{1,200}$/;function U(e){if(typeof e!="string")return"";let n=e.trim();return X.test(n)?n:""}function V(e){if(typeof e!="string"||!e)return[];let n=new Set;for(let o of e.split(",")){let f=o.trim().replace(/^["']+|["']+$/g,"").toLowerCase();for(let d of w)f===Q[d].toLowerCase()&&n.add(d)}return w.filter(o=>n.has(o))}function ee(e,n){let o=n.themes||{},f=e&&typeof e.theme=="string"&&o[e.theme]?e.theme:n.defaultTheme,[d,l]=o[f]||["",""],p=e&&e.fonts;if(p&&typeof p=="object"){let h=U(p.heading),u=U(p.body);h&&(d=h),u&&(l=u)}return[d,l]}function H(e){return Array.isArray(e)?e.some(n=>Array.isArray(n)&&n.some(o=>o&&o.c)):!1}function te(e){for(let n of e&&e.slides||[])for(let o of n.blocks||[])if(o.type==="code"||H(o.text)||o.type==="table"&&(o.props&&Array.isArray(o.props.cells)?o.props.cells:[]).some(H))return!0;return!1}function Y(e,n){if(!e||!Array.isArray(e.slides)||e.slides.length===0)return[];let o=ee(e.meta,n);te(e)&&o.push(n.code);let f=new Set(o.flatMap(V));return w.filter(d=>f.has(d))}function _(e,n,{styleOf:o,hasCodeIn:f}=se()){if(typeof e!="string"||!e)return[];let d=o(e)||"",l=[];for(let h of d.split(";")){let u=h.indexOf(":");if(u<0)continue;let g=h.slice(0,u).trim();(g==="--slides-font-heading"||g==="--slides-font-body")&&l.push(h.slice(u+1))}f(e)&&l.push(n.code);let p=new Set(l.flatMap(V));return w.filter(h=>p.has(h))}function se(){let e=n=>{let o=document.createElement("template");return o.innerHTML=n,o.content};return{styleOf:n=>{let o=e(n).querySelector("[slides-slide]");return o?o.getAttribute("style"):""},hasCodeIn:n=>!!e(n).querySelector("pre, code")}}var $=2500,oe=3e3,re=4e3;function O(e,n){return new Promise(o=>n(()=>o("late"),e))}function K({manifest:e,fontSet:n,FontFaceCtor:o,root:f=null,setTimer:d=setTimeout}={}){let l=new Map,p=new Set,h=!1,u=i=>!!(e&&e.families&&e.families[i]),g=i=>{let a=l.get(i);return a||(a={state:"idle",faces:[],promise:null,added:!1},l.set(i,a)),a};function q(){if(!f)return;let i=w.filter(a=>l.has(a)&&l.get(a).state==="committed").join(" ");(f.getAttribute("data-slides-fonts-fallback")||"")!==i&&f.setAttribute("data-slides-fonts-fallback",i)}function S(i){if(!u(i))return Promise.resolve(!1);let a=g(i);if(a.state==="committed")return Promise.resolve(!1);if(a.promise)return a.promise;let t=e.families[i];return a.state="loading",a.promise=Promise.resolve().then(()=>(a.faces=t.faces.map(s=>new o(t.css,`url("${s.url}") format("woff2")`,{weight:String(s.weight),style:s.style,display:"block"})),Promise.all(a.faces.map(s=>s.load().then(()=>!0,()=>!1))))).then(s=>s.every(Boolean),()=>!1).then(s=>(a.state==="loading"&&(a.state=s?"loaded":"failed"),a.state==="loaded")),a.promise}let b=i=>{if(!u(i))return!0;let a=l.has(i)?l.get(i).state:"idle";return a==="loaded"||a==="committed"};function T(i){for(let a of i){if(!u(a))continue;let t=g(a);t.added||t.state==="committed"||(t.state="committed")}q()}function A(i){for(let a of i){if(!u(a))continue;let t=g(a);if(t.state==="loaded"&&!t.added){for(let s of t.faces)n.add(s);t.added=!0}(t.state==="loaded"||t.state==="committed")&&p.add(a)}}let x={web:!0,get manifest(){return e},ready:b,loaded:i=>u(i)&&l.has(i)&&l.get(i).state==="loaded",committed:i=>u(i)&&l.has(i)&&l.get(i).state==="committed",failed:i=>u(i)&&l.has(i)&&l.get(i).state==="failed",state:i=>l.has(i)?l.get(i).state:"idle",get inUse(){return[...p]},get fallback(){return w.filter(i=>l.has(i)&&l.get(i).state==="committed")},use:A,load:S,markShown(){h=!0},get shown(){return h},async gate(i,a){let t=i.filter(u),s=Promise.all(t.map(S));await Promise.race([s,O(a,d)]);let r=t.filter(c=>!x.loaded(c));return T(r),A(t),r},async waitFor(i,a=re){let t=i.filter(u);if(t.every(b))return!0;let s=Promise.all(t.map(r=>b(r)?!0:S(r)));return await Promise.race([s,O(a,d)]),t.every(b)},async prepare(i,{timeout:a=oe}={}){let t=[...new Set(i)].filter(u),s=t.filter(r=>!b(r));s.length&&(await Promise.race([Promise.all(s.map(S)),O(a,d)]),T(s.filter(r=>!x.loaded(r)))),A(t)},commitFallback(i){T(i.filter(a=>!b(a))),A(i)},async prefetch({idle:i=()=>Promise.resolve()}={}){for(let a of w)!u(a)||l.has(a)||(await i(),!l.has(a)&&await S(a))}};return x}function B(){return{web:!1,manifest:null,ready:()=>!0,loaded:()=>!1,committed:()=>!1,failed:()=>!1,state:()=>"system",inUse:[],fallback:[],use(){},load:async()=>!1,markShown(){},shown:!0,gate:async()=>[],waitFor:async()=>!0,prepare:async()=>{},commitFallback(){},prefetch:async()=>{}}}function W(e,{setTimer:n=setTimeout,clearTimer:o=clearTimeout}={}){if(!e)return{say(){},clear(){},state:""};let f=e.querySelector("[slides-fonts-status-text]"),d=e.querySelector("[slides-fonts-status-dismiss]"),l=null,p=()=>e.getAttribute("data-state")||"";function h(u){u&&p()!==u||(o(l),e.removeAttribute("data-state"),f&&(f.textContent=""))}return d&&d.addEventListener("click",()=>h()),{say(u,g=0){o(l),e.setAttribute("data-state",u),f&&(f.textContent=e.getAttribute("data-"+u)||""),g&&(l=n(()=>h(u),g))},clear:h,get state(){return p()}}}var j="[slides-viewer], [slides-present]";function C({fonts:e,doc:n=document,win:o=window}={}){let f=()=>n.querySelector(j);if(!f()||!o.history||!o.history.pushState||typeof o.fetch!="function"||typeof o.DOMParser!="function")return null;let d=new Map,l=0,p=new AbortController;o.addEventListener("pagehide",()=>p.abort()),o.addEventListener("pageshow",t=>{t.persisted&&(p=new AbortController,a())});function h(t){let s;try{s=new URL(t,o.location.href)}catch{return null}return s.origin!==o.location.origin||s.pathname!==o.location.pathname||s.hash?null:s.href}async function u(t,{cached:s=!1}={}){let r=d.get(t);if(s&&r&&Date.now()-r.at<3e4)return r.html;let c=await o.fetch(t,{credentials:"same-origin",headers:{Accept:"text/html"},signal:p.signal});if(!c.ok)throw new Error(`viewer: ${t}: ${c.status}`);let m=await c.text();return d.set(t,{at:Date.now(),html:m}),d.size>6&&d.delete(d.keys().next().value),m}let g=t=>new o.DOMParser().parseFromString(t,"text/html");function q(t){let s=[...t.querySelectorAll("img[src]")].map(r=>{let c=new o.Image;return c.src=r.getAttribute("src"),c.decode?c.decode().catch(()=>{}):Promise.resolve()});return Promise.race([Promise.all(s),new Promise(r=>setTimeout(r,1500))])}async function S(t,{push:s}){let r=++l,c,m;try{let F=g(await u(t));if(c=F.querySelector(j),m=F.title,!c)throw new Error("viewer: not a viewer page");let D=c.querySelector("[slides-slide]");D&&e&&e.prepareSection&&await e.prepareSection(D.outerHTML),await q(c)}catch{r===l&&!p.signal.aborted&&o.location.assign(t);return}if(r!==l)return;let M=f(),L=n.activeElement,N=L&&M.contains(L)?L:null,E=n.importNode(c,!0),Z=b(M);M.replaceWith(E),T(E,Z),m&&(n.title=m),s&&o.history.pushState({slidesViewer:!0},"",t),N&&x(E,N),i(E),a()}function b(t){let s=t.querySelector("[slides-film-nav]"),r=t.querySelector("[slides-film]");return{nav:s?s.scrollTop:0,list:r?r.scrollLeft:0}}function T(t,s){let r=t.querySelector("[slides-film-nav]"),c=t.querySelector("[slides-film]");r&&(r.scrollTop=s.nav),c&&(c.scrollLeft=s.list),A(t)}function A(t){let s=t.querySelector('[slides-film] a[aria-current="true"]');if(s)for(let r of[t.querySelector("[slides-film-nav]"),t.querySelector("[slides-film]")]){if(!r||typeof r.getBoundingClientRect!="function")continue;let c=r.getBoundingClientRect(),m=s.getBoundingClientRect();r.scrollHeight>r.clientHeight&&(m.top<c.top?r.scrollTop-=c.top-m.top+8:m.bottom>c.bottom&&(r.scrollTop+=m.bottom-c.bottom+8)),r.scrollWidth>r.clientWidth&&(m.left<c.left?r.scrollLeft-=c.left-m.left+8:m.right>c.right&&(r.scrollLeft+=m.right-c.right+8))}}function x(t,s){let r=null,c=s.getAttribute&&s.getAttribute("rel");c&&(r=t.querySelector(`[slides-pager] a[rel="${c}"]`)),!r&&s.closest&&s.closest("[slides-film]")&&(r=[...t.querySelectorAll("[slides-film] a[href]")].find(m=>m.getAttribute("href")===s.getAttribute("href"))||null),r||(r=t.querySelector("[slides-slide]"),r&&!r.hasAttribute("tabindex")&&r.setAttribute("tabindex","-1")),r&&r.focus({preventScroll:!0})}function i(t){let s=n.querySelector("[slides-announce]"),r=t.getAttribute("data-announce");s&&r&&(s.textContent=r)}function a(){(s=>typeof o.requestIdleCallback=="function"?o.requestIdleCallback(s,{timeout:2e3}):setTimeout(s,300))(async()=>{if(!p.signal.aborted)for(let s of f()?f().querySelectorAll('[slides-pager] a[rel="prev"], [slides-pager] a[rel="next"]'):[]){let r=h(s.href);if(r)try{let c=g(await u(r,{cached:!0})).querySelector("[slides-slide]");c&&e&&e.familiesOfSection&&e.load&&await Promise.all(e.familiesOfSection(c.outerHTML).map(m=>e.load(m)))}catch{}}})}return n.addEventListener("click",t=>{if(t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey)return;let s=t.target.closest&&t.target.closest("a[href]");if(!s||!f()||!f().contains(s)||s.target||s.hasAttribute("download")||!s.closest("[slides-pager], [slides-film]"))return;let r=h(s.href);r&&(t.preventDefault(),S(r,{push:!0}))}),o.addEventListener("popstate",()=>{S(o.location.href,{push:!1})}),o.history.replaceState({slidesViewer:!0},"",o.location.href),f()&&A(f()),a(),{go:S}}var ne=3500,ie=1e4,v=document.documentElement,I=v.getAttribute("data-slides-fonts")==="pending";I&&clearTimeout(globalThis.__slidesFontsHold);var y=null;try{let e=document.querySelector('meta[name="slides-fonts"]');y=e?JSON.parse(e.getAttribute("content")||"null"):null}catch{y=null}var G,ae=new Promise(e=>{G=e}),P,le=new Promise(e=>{P=e}),ce=e=>new Promise(n=>setTimeout(n,Math.max(0,e-performance.now())));function J(e){e.markShown(),v.getAttribute("data-slides-fonts")!=="shown"&&v.setAttribute("data-slides-fonts","shown"),e.fallback.length&&W(document.querySelector("[slides-fonts-status]")).say("substitute",ie)}var k=!1,R=[];addEventListener("pagehide",()=>{k=!0});addEventListener("pageshow",e=>{if(!e.persisted)return;k=!1;let n=R;R=[];for(let o of n)o()});function fe(e){let n=navigator.connection;if(n&&(n.saveData||/(^|-)2g$/.test(n.effectiveType||"")))return Promise.resolve();let o=()=>new Promise(f=>typeof requestIdleCallback=="function"?requestIdleCallback(()=>f(),{timeout:5e3}):setTimeout(f,200)).then(()=>k?new Promise(f=>R.push(f)):void 0);return e.prefetch({idle:o})}async function ue(e){await e.gate(y.need||[],Math.max(0,$-performance.now())),P();let n=document.querySelector("[slides-editor]");n&&await Promise.race([ae,ce(ne)]),J(e),n&&(await fe(e),v.setAttribute("data-slides-fonts-prefetch","done"))}function z(e){return Object.assign(e,{fontsReady:le,settled:()=>G(),familiesOfView:n=>y?Y(n,y):[],familiesOfSection:n=>y?_(n,y):[],prepareSection:n=>e.web&&y?e.prepare(_(n,y)):Promise.resolve()})}if(!I||!y||typeof FontFace!="function"||!document.fonts){I&&v.setAttribute("data-slides-fonts","shown");let e=z(B());P(),globalThis.slidesFonts=e,C({fonts:e})}else{let e=z(K({manifest:y,fontSet:document.fonts,FontFaceCtor:FontFace,root:v}));globalThis.slidesFonts=e,C({fonts:e}),ue(e).catch(n=>{console.error("fonts:",n),P(),J(e)})} |
diff --git a/internal/slides/team_access_test.go b/internal/slides/team_access_test.go| index 19d5d01..d5f2681 100644 |
| --- a/internal/slides/team_access_test.go |
| +++ b/internal/slides/team_access_test.go |
| @@ -16,6 +16,10 @@ import ( |
| func deckPath(d Deck) string { return "/d/" + d.Sqid } |
| +// viewerPath is the deck's viewer: its bare address opens the editor |
| +// (viewer.go's showDeck). |
| +func viewerPath(d Deck) string { return viewerStart(d.Sqid) } |
| + |
| func countRows(t *testing.T, f *teamFixture, model any) int64 { |
| t.Helper() |
| var n int64 |
| @@ -51,10 +55,10 @@ func TestTeamHomeOnlyMemberSignsInAndReachesTheTeamRung(t *testing.T) { |
| if !strings.Contains(body, `action="/signout"`) || !strings.Contains(body, homeOnlyLabel(teamSubject('a'))) { |
| t.Fatalf("Home-only member's chrome is not signed in as %q", homeOnlyLabel(teamSubject('a'))) |
| } |
| - if got := f.get(deckPath(plan)); got.Code != 200 { |
| + if got := f.get(viewerPath(plan)); got.Code != 200 { |
| t.Fatalf("team deck = %d", got.Code) |
| } |
| - if got := f.get(deckPath(private)); got.Code != 404 { |
| + if got := f.get(viewerPath(private)); got.Code != 404 { |
| t.Fatalf("another member's private deck = %d, want 404", got.Code) |
| } |
| } |
| @@ -131,14 +135,14 @@ func TestTeamRemovalRevokesAHomeOnlyMembersExistingSession(t *testing.T) { |
| u := f.member(teamSubject('a'), "member") |
| own := f.deck(u, "My own", rungPrivate) |
| for _, d := range []Deck{plan, own} { |
| - if got := f.get(deckPath(d)); got.Code != 200 { |
| + if got := f.get(viewerPath(d)); got.Code != 200 { |
| t.Fatalf("before removal %s = %d", d.Title, got.Code) |
| } |
| } |
| f.dir.Set(teamSubject('a'), "") |
| f.refreshed() |
| for _, d := range []Deck{plan, own} { |
| - if got := f.get(deckPath(d)); got.Code != 404 { |
| + if got := f.get(viewerPath(d)); got.Code != 404 { |
| t.Fatalf("after removal %s = %d, want 404", d.Title, got.Code) |
| } |
| } |
| @@ -161,7 +165,7 @@ func TestTeamRemovalRevokesAHomeOnlyMembersExistingSession(t *testing.T) { |
| } |
| // And a grant somebody else gave still reaches. |
| f.grant(plan, u, colleague) |
| - if got := f.get(deckPath(plan)); got.Code != 200 { |
| + if got := f.get(viewerPath(plan)); got.Code != 200 { |
| t.Fatalf("granted deck after removal = %d, want 200", got.Code) |
| } |
| } |
| @@ -176,7 +180,7 @@ func TestTeamStandingIsTheRostersNeverTheAllowlists(t *testing.T) { |
| f.jar = map[string]*http.Cookie{} |
| f.localSession("local@example.com") |
| - if got := f.get(deckPath(plan)); got.Code != 404 { |
| + if got := f.get(viewerPath(plan)); got.Code != 404 { |
| t.Fatalf("unlinked local account on a team deck = %d, want 404", got.Code) |
| } |
| if got := f.get("/decks/new"); got.Code != http.StatusForbidden { |
| @@ -187,7 +191,7 @@ func TestTeamStandingIsTheRostersNeverTheAllowlists(t *testing.T) { |
| if got := f.get(deckPath(plan) + "/settings"); got.Code != 404 { |
| t.Fatalf("a member's settings on a colleague's deck = %d, want 404", got.Code) |
| } |
| - if got := f.get(deckPath(plan)); got.Code != 200 { |
| + if got := f.get(viewerPath(plan)); got.Code != 200 { |
| t.Fatalf("a member's team deck = %d", got.Code) |
| } |
| } |
| @@ -201,11 +205,11 @@ func TestTeamStandingEndsAtTheLeaseUnderAFailingRefresh(t *testing.T) { |
| f.member(teamSubject('a'), "member") |
| f.dir.SetDown(true) |
| f.clock.Step(59 * time.Second) |
| - if got := f.get(deckPath(plan)); got.Code != 200 { |
| + if got := f.get(viewerPath(plan)); got.Code != 200 { |
| t.Fatalf("at 59 s = %d, want 200", got.Code) |
| } |
| f.clock.Step(2 * time.Second) |
| - got := f.get(deckPath(plan)) |
| + got := f.get(viewerPath(plan)) |
| if got.Code != http.StatusServiceUnavailable || got.Header().Get("Retry-After") == "" || got.Header().Get("Cache-Control") != "no-store" { |
| t.Fatalf("at 61 s = %d %v, want a retryable no-store 503", got.Code, got.Header()) |
| } |
| @@ -232,10 +236,10 @@ func TestTeamUnknownListIsPartialAndItemsAreRetryable(t *testing.T) { |
| if list.Code != 200 || !strings.Contains(body, "data-partial") || !strings.Contains(body, "Shared with you") || strings.Contains(body, "Team plan") || strings.Contains(body, sampleDeckTitle) { |
| t.Fatalf("Unknown list = %d, want the grant alone, marked partial:\n%s", list.Code, body) |
| } |
| - if got := f.get(deckPath(shared)); got.Code != 200 { |
| + if got := f.get(viewerPath(shared)); got.Code != 200 { |
| t.Fatalf("granted deck under Unknown = %d", got.Code) |
| } |
| - if got := f.get(deckPath(plan)); got.Code != http.StatusServiceUnavailable { |
| + if got := f.get(viewerPath(plan)); got.Code != http.StatusServiceUnavailable { |
| t.Fatalf("team deck under Unknown = %d, want 503", got.Code) |
| } |
| if got := f.get("/decks/new"); got.Code != http.StatusServiceUnavailable { |
diff --git a/internal/slides/team_guard_test.go b/internal/slides/team_guard_test.go| index ecbb3d6..2c3914b 100644 |
| --- a/internal/slides/team_guard_test.go |
| +++ b/internal/slides/team_guard_test.go |
| @@ -103,7 +103,7 @@ func (f *teamFixture) api(token, method, path, body string) *httptest.ResponseRe |
| type teamSnapshot struct { |
| decks, updates, links, revoked, presentations int64 |
| uploads, uploadsLanded, uploadsSpent, assets int64 |
| - title string |
| + title, rung string |
| seq int64 |
| } |
| @@ -124,7 +124,7 @@ func (f *teamFixture) snapshot(d Deck) teamSnapshot { |
| if err := g.Take(&row, d.ID).Error; err != nil { |
| f.t.Fatalf("deck %d gone: %v", d.ID, err) |
| } |
| - s.title, s.seq = row.Title, row.Seq |
| + s.title, s.rung, s.seq = row.Title, row.Rung, row.Seq |
| return s |
| } |
| @@ -188,6 +188,9 @@ func TestTeamEveryWriteRouteRefusesALapseBeforeCommit(t *testing.T) { |
| {"settings", nil, func() *httptest.ResponseRecorder { |
| return f.post(deckPath(plan)+"/settings", url.Values{"title": {"Renamed"}, "theme": {defaultTheme}, "rung": {rungPrivate}}) |
| }}, |
| + {"share access", nil, func() *httptest.ResponseRecorder { |
| + return f.post(deckPath(plan)+"/share/access", url.Values{"rung": {rungPrivate}}) |
| + }}, |
| {"delete", nil, func() *httptest.ResponseRecorder { return f.post(deckPath(plan)+"/delete", nil) }}, |
| {"share link", nil, func() *httptest.ResponseRecorder { return f.post(deckPath(plan)+"/share", nil) }}, |
| {"share revoke", nil, func() *httptest.ResponseRecorder { |
diff --git a/internal/slides/team_review_test.go b/internal/slides/team_review_test.go| index f630ec9..52f8e72 100644 |
| --- a/internal/slides/team_review_test.go |
| +++ b/internal/slides/team_review_test.go |
| @@ -104,8 +104,18 @@ func TestTeamRosterOwnerSharesAndRetitlesOrphansOnly(t *testing.T) { |
| if page.Code != 200 || strings.Contains(page.Body.String(), `name="rung"`) || strings.Contains(page.Body.String(), deckPath(orphan)+"/delete") { |
| t.Fatalf("roster owner's settings on an orphan = %d (rung or delete offered?)", page.Code) |
| } |
| - if got := f.get(deckPath(orphan)); !strings.Contains(got.Body.String(), deckPath(orphan)+"/settings") || !strings.Contains(got.Body.String(), deckPath(orphan)+"/share") { |
| - t.Fatal("the roster owner's viewer of an orphan offers no settings or share") |
| + // The viewer offers Share… in the bar, and never the settings form |
| + // (the editor's inspector holds those, for everybody). |
| + if got := f.get(viewerPath(orphan)); strings.Contains(got.Body.String(), deckPath(orphan)+"/settings") || !strings.Contains(got.Body.String(), deckPath(orphan)+"/share") { |
| + t.Fatal("the roster owner's viewer of an orphan offers no share, or links the settings form") |
| + } |
| + // The share page shows the rung and offers no way to change it, and |
| + // the access POST is refused like any other owner screen. |
| + if got := f.get(deckPath(orphan) + "/share"); strings.Contains(got.Body.String(), `name="rung"`) || !strings.Contains(got.Body.String(), "<section slides-share-access") { |
| + t.Fatalf("roster owner's share page on an orphan offers the rung:\n%s", got.Body.String()) |
| + } |
| + if got := f.post(deckPath(orphan)+"/share/access", url.Values{"rung": {rungPrivate}}); got.Code != 404 { |
| + t.Fatalf("roster owner making an orphan private from the share page = %d, want 404", got.Code) |
| } |
| if got := f.post(deckPath(orphan)+"/settings", url.Values{"title": {"Rescued"}, "theme": {"ink"}}); got.Code != http.StatusSeeOther { |
| t.Fatalf("roster owner retitling an orphan = %d %s", got.Code, got.Body.String()) |
| @@ -130,7 +140,7 @@ func TestTeamRosterOwnerSharesAndRetitlesOrphansOnly(t *testing.T) { |
| t.Fatalf("a refused narrowing changed the orphan: %q %q", row.Title, row.Rung) |
| } |
| // A departed member's private deck, readable by grant: no owner powers. |
| - if got := f.get(deckPath(private)); got.Code != 200 || strings.Contains(got.Body.String(), deckPath(private)+"/settings") { |
| + if got := f.get(viewerPath(private)); got.Code != 200 || strings.Contains(got.Body.String(), deckPath(private)+"/share") { |
| t.Fatalf("roster owner's granted private orphan = %d (owner mode?)", got.Code) |
| } |
| for _, p := range []string{"/settings", "/share", "/delete"} { |
| @@ -149,6 +159,9 @@ func TestTeamRosterOwnerSharesAndRetitlesOrphansOnly(t *testing.T) { |
| t.Fatalf("a member's %s on an orphan = %d, want 404", p, got.Code) |
| } |
| } |
| + if got := f.post(deckPath(orphan)+"/share/access", url.Values{"rung": {rungPrivate}}); got.Code != 404 { |
| + t.Fatalf("a member's rung change on an orphan = %d, want 404", got.Code) |
| + } |
| // The departed owner re-added: the deck has a live owner again. |
| f.dir.Set(teamSubject('d'), "member") |
| @@ -160,9 +173,19 @@ func TestTeamRosterOwnerSharesAndRetitlesOrphansOnly(t *testing.T) { |
| // And the owner themselves still has every power, delete included. |
| f.freshHomeSignIn(teamSubject('d')) |
| - if got := f.post(deckPath(orphan)+"/settings", url.Values{"title": {"Mine"}, "theme": {"ink"}, "rung": {rungPrivate}}); got.Code != http.StatusSeeOther { |
| + if got := f.get(deckPath(orphan) + "/share"); !strings.Contains(got.Body.String(), `name="rung"`) { |
| + t.Fatalf("the owner's share page offers no rung:\n%s", got.Body.String()) |
| + } |
| + if got := f.post(deckPath(orphan)+"/share/access", url.Values{"rung": {rungPrivate}}); got.Code != http.StatusSeeOther { |
| t.Fatalf("the owner's own rung change = %d", got.Code) |
| } |
| + f.d.G.Take(&row, orphan.ID) |
| + if row.Rung != rungPrivate { |
| + t.Fatalf("the owner's rung change did not land: %q", row.Rung) |
| + } |
| + if got := f.post(deckPath(orphan)+"/settings", url.Values{"title": {"Mine"}, "theme": {"ink"}, "rung": {rungTeam}}); got.Code != http.StatusSeeOther { |
| + t.Fatalf("the owner's own rung change through the settings POST = %d", got.Code) |
| + } |
| if got := f.post(deckPath(orphan)+"/delete", nil); got.Code != http.StatusSeeOther { |
| t.Fatalf("the owner's own delete = %d", got.Code) |
| } |
| @@ -293,13 +316,13 @@ func TestTeamLinkedAccountStandsOnTheRoster(t *testing.T) { |
| if f.userFor(teamSubject('k')).ID != linked.ID { |
| t.Fatal("the linked account signed in as somebody else") |
| } |
| - page := f.get(deckPath(plan)) |
| + page := f.get(viewerPath(plan)) |
| if page.Code != 200 || !strings.Contains(page.Body.String(), "linked@example.com") { |
| t.Fatalf("linked member on a team deck = %d (signed in as the account?)", page.Code) |
| } |
| f.dir.Set(teamSubject('k'), "") |
| f.refreshed() |
| - if got := f.get(deckPath(plan)); got.Code != 404 { |
| + if got := f.get(viewerPath(plan)); got.Code != 404 { |
| t.Fatalf("linked account after removal = %d, want 404", got.Code) |
| } |
| } |
diff --git a/internal/slides/team_survivors_test.go b/internal/slides/team_survivors_test.go| index d4fd998..a789be5 100644 |
| --- a/internal/slides/team_survivors_test.go |
| +++ b/internal/slides/team_survivors_test.go |
| @@ -30,8 +30,8 @@ func TestTeamRemovedOwnerOwnsNothing(t *testing.T) { |
| f.grant(own, u, colleague) |
| f.dir.Set(teamSubject('a'), "") |
| f.refreshed() |
| - page := f.get(deckPath(own)) |
| - if page.Code != 200 || strings.Contains(page.Body.String(), deckPath(own)+"/settings") { |
| + page := f.get(viewerPath(own)) |
| + if page.Code != 200 || strings.Contains(page.Body.String(), deckPath(own)+"/share") { |
| t.Fatalf("removed owner's granted deck = %d (owner mode?)", page.Code) |
| } |
| for _, p := range []string{"/settings", "/share", "/delete"} { |
diff --git a/internal/slides/templates/deck_settings.html b/internal/slides/templates/deck_settings.html| index fad4935..298d747 100644 |
| --- a/internal/slides/templates/deck_settings.html |
| +++ b/internal/slides/templates/deck_settings.html |
| @@ -1,10 +1,10 @@ |
| {{/* deck_settings — GET/POST /d/{sqid}/settings. |
| - The deck's own settings and nothing else: name, theme, and who can |
| - open it. The rung is a choice-field rather than a select, because |
| - the three answers each need a sentence — "Private" on its own does |
| - not say who that leaves out — and because a radio group signals |
| - pick-one where a dropdown hides the alternatives. |
| + The deck's name and theme as a form, for somebody with scripts off: |
| + with them on, both are the editor's inspector (Docs' shape — a |
| + document's settings are an inspector, not a page), and nothing |
| + links here but the editor's <noscript>. Who can open the deck was a |
| + third field; it is the share page's now, and this page says so. |
| Deleting is not a control on this form. It is a link to its own |
| page, which asks the question and carries the only button that |
| @@ -22,14 +22,16 @@ |
| "ID" "theme" "Name" "theme" "Label" .ThemeLabel |
| "Options" .Themes "Required" true |
| "Error" (index .Errors "Theme")}} |
| - {{if .Rungs}}{{template "choice-field" dict |
| - "Legend" .RungLegend "Name" "rung" "Options" .Rungs}} |
| {{template "form-error" (index .Errors "Rung")}} |
| - {{end}}{{template "form-foot" dict |
| + {{template "form-foot" dict |
| "Submit" .Submit "CancelHref" .CancelHref "CancelLabel" .CancelLabel}} |
| </form> |
| </div> |
| -{{if .DeleteHref}}<div rst-box-head><h2>{{.DeleteLabel}}</h2></div> |
| +{{if .AccessHref}}<div rst-box> |
| + <p>{{.AccessBody}}</p> |
| + <p><a rst-btn href="{{.AccessHref}}">{{.AccessLabel}}</a></p> |
| +</div> |
| +{{end}}{{if .DeleteHref}}<div rst-box-head><h2>{{.DeleteLabel}}</h2></div> |
| <div rst-box> |
| <p>{{.DeleteBody}}</p> |
| <p><a rst-btn href="{{.DeleteHref}}">{{.DeleteLabel}}</a></p> |
diff --git a/internal/slides/templates/editor.html b/internal/slides/templates/editor.html| index ff4f3fc..491f532 100644 |
| --- a/internal/slides/templates/editor.html |
| +++ b/internal/slides/templates/editor.html |
| @@ -78,7 +78,11 @@ |
| <div rst-callout rst-tone="warning"> |
| <div rst-callout-body> |
| <p>{{.NoScriptBody}}</p> |
| - <p><a rst-btn href="{{.BackHref}}">{{.NoScriptLink}}</a></p> |
| + {{/* The viewer by its first slide, never the deck's bare address, |
| + which opens this page again (viewer.go's showDeck). And the |
| + title and theme as a form, the one link to it, for somebody |
| + who may change them. */}} |
| + <p><a rst-btn href="{{.ViewHref}}">{{.NoScriptLink}}</a>{{with .SettingsHref}} <a rst-btn href="{{.}}">{{$.NoScriptSettings}}</a>{{end}}</p> |
| </div> |
| </div> |
| </noscript> |
| @@ -106,10 +110,12 @@ |
| <a estilo-menu-item href="{{.ViewHref}}"><span estilo-menu-label>{{.L "file.view"}}</span></a> |
| <a estilo-menu-item href="{{.NotesPageHref}}"><span estilo-menu-label>{{.L "file.notes"}}</span></a> |
| <a estilo-menu-item href="{{.ExportHref}}"><span estilo-menu-label>{{.L "file.export"}}</span></a> |
| - {{- if or .SettingsHref .ShareHref}} |
| + {{- /* Share… alone: the deck's title, theme and fonts are the |
| + inspector's Deck section, and who can open it is Share's, |
| + as general access is in Docs. */}} |
| + {{- with .ShareHref}} |
| <hr> |
| - {{- with .ShareHref}}<a estilo-menu-item href="{{.}}"><span estilo-menu-label>{{$.L "head.share"}}</span></a>{{end}} |
| - {{- with .SettingsHref}}<a estilo-menu-item href="{{.}}"><span estilo-menu-label>{{$.L "file.settings"}}</span></a>{{end}} |
| + <a estilo-menu-item href="{{.}}"><span estilo-menu-label>{{$.L "head.share"}}</span></a> |
| {{- end}} |
| {{- with .DeleteHref}} |
| <hr> |
diff --git a/internal/slides/templates/share.html b/internal/slides/templates/share.html| index 9e7611c..cddde74 100644 |
| --- a/internal/slides/templates/share.html |
| +++ b/internal/slides/templates/share.html |
| @@ -1,8 +1,12 @@ |
| -{{/* share — GET /d/{sqid}/share, a deck's read-only links. |
| +{{/* share — GET /d/{sqid}/share, who can open a deck: the rung, and |
| + its read-only links. |
| - The screen is three things in the order they matter: the link that |
| - was just made (once, and never again), what a link costs to hand |
| - out, and the links that already exist with the one button that |
| + Docs' shape (Paul, 2026-11-11): Share… in the bar opens one page for |
| + everything about who reaches the deck. First the rung — who can open |
| + it — as a real POST form of three cards, so it works with scripts |
| + off; then the links, three things in the order they matter: the link |
| + that was just made (once, and never again), what a link costs to |
| + hand out, and the links that already exist with the one button that |
| turns each of them off. |
| The new link is a callout plus a read-only field rather than a line |
| @@ -11,7 +15,28 @@ |
| you select cleanly with no script at all. */}} |
| {{define "content"}} |
| {{template "back-nav" dict "Href" .BackHref "Label" .BackLabel}} |
| -{{template "page-header" dict "Title" .Title}} |
| +{{template "page-header" dict "Title" .Title "Sub" .DeckTitle}} |
| + |
| +{{/* Who can open the deck. The owner chooses (mayChangeRung); a roster |
| + owner on an orphan, who may share it but not move it, reads it. */}} |
| +<section slides-share-access aria-labelledby="slides-share-access"> |
| +<div rst-box-head><h2 id="slides-share-access">{{.AccessHeading}}</h2></div> |
| +<div rst-box> |
| + {{if .Rungs}} |
| + <form rst-form method="post" action="{{.AccessAction}}"> |
| + {{template "choice-field" dict "Legend" .AccessLegend "LegendHidden" true "Name" "rung" "Options" .Rungs}} |
| + {{template "form-error" .AccessError}} |
| + <div rst-form-foot><button rst-btn="primary" type="submit">{{.AccessSubmit}}</button></div> |
| + </form> |
| + {{else}} |
| + <p><strong>{{.AccessCurrent}}</strong>{{with .AccessCurrentDesc}} — {{.}}{{end}}</p> |
| + <p rst-muted>{{.AccessFixed}}</p> |
| + {{end}} |
| +</div> |
| +</section> |
| + |
| +<section slides-share-links aria-labelledby="slides-share-links"> |
| +<div rst-box-head><h2 id="slides-share-links">{{.LinksHeading}}</h2></div> |
| {{if .NewURL}} |
| <div rst-box> |
| @@ -67,4 +92,5 @@ |
| <form method="post" action="{{.Action}}" rst-form> |
| <button rst-btn="primary lg" type="submit">{{.CreateLabel}}</button> |
| </form> |
| +</section> |
| {{end}} |
diff --git a/internal/slides/templates/viewer.html b/internal/slides/templates/viewer.html| index 77ef5ad..a0ab4a6 100644 |
| --- a/internal/slides/templates/viewer.html |
| +++ b/internal/slides/templates/viewer.html |
| @@ -15,7 +15,15 @@ |
| Present is task 6's surface in its scriptless form: one slide, two |
| links, nothing else on the page. §8's floor, and the thing the |
| fullscreen presenter will be an enhancement OF rather than a |
| - replacement for. */}} |
| + replacement for. |
| + |
| + Shaped as Docs shapes a document (Paul, 2026-11-11: "Share should go |
| + where it does on Docs"): the deck's title is the bar's context and |
| + Share… the bar's action (viewer.go's frame), so the page itself is |
| + the slide, a short row of what a reader reaches for — Edit, Present, |
| + and an overflow for the rest — and the slides as a rail at its side. |
| + The h1 is the deck's title for a screen reader; on screen the bar |
| + says it. */}} |
| {{/* The slide's own stylesheet, on the screens that render a slide and |
| nowhere else: it is a document's look, not the app's chrome, and |
| every other screen would pay for it without using it. */}} |
| @@ -26,40 +34,83 @@ |
| is slides.css; these rules only place the viewer's own parts, each |
| an app attribute (slides-*) so nothing here can collide with the |
| rst-* vocabulary. The look is the editor's (I2, after Docs): the |
| - slide is paper on a desk, the deck's actions one set of pills, and |
| - the filmstrip the slides' own pictures. */ |
| + slide is paper on a desk, the slides a rail of their own pictures |
| + beside it, as the editor's strip is. |
| + |
| + The DOM is the slide's column first and the rail after it, so a |
| + screen reader and the Tab key meet the slide before thirty |
| + thumbnails; the grid puts the rail at the inline start from 1100px |
| + (the editor's own breakpoint) and under the slide below that, where |
| + it is one row that scrolls sideways. */ |
| [slides-viewer] { |
| - margin-inline: auto; |
| - max-inline-size: 72rem; |
| + display: grid; |
| + gap: var(--rst-sp-4); |
| + grid-template-columns: minmax(0, 1fr); |
| } |
| - [slides-viewer] [rst-page-header] { |
| - border: 0; |
| - margin-block-end: var(--rst-sp-3); |
| - padding: 0; |
| + /* The page column is a form's measure (tokens.css's 64rem); a slide |
| + and its rail want the desk's width, as the deck list does. */ |
| + [rst-page]:has(> [slides-viewer]) { |
| + max-width: 88rem; |
| } |
| - [slides-viewer] [rst-page-header] h1 { |
| - font-size: clamp(1.6rem, 1.1rem + 1.6vw, 2.4rem); |
| - letter-spacing: -0.02em; |
| + /* The slide fits the window's height as well as its width, so the |
| + pager is on screen under it on a laptop: never wider than the |
| + height left after the bar, the row and the pager allows. */ |
| + [slides-viewer-main] { |
| + inline-size: 100%; |
| + justify-self: center; |
| + max-inline-size: max(36rem, calc((100dvh - 15rem) * 16 / 9)); |
| + min-inline-size: 0; |
| } |
| [slides-tools] { |
| align-items: center; |
| display: flex; |
| flex-wrap: wrap; |
| gap: var(--rst-sp-2); |
| + justify-content: flex-end; |
| } |
| [slides-tools] form { |
| margin: 0; |
| } |
| [slides-tools] [rst-btn] { |
| border-radius: 999px; |
| + gap: 6px; |
| min-block-size: 36px; |
| padding-inline: 16px; |
| } |
| + [slides-tools] [rst-btn] .icon { |
| + block-size: 16px; |
| + inline-size: 16px; |
| + } |
| [slides-tools] [rst-btn]:not([rst-btn="primary"]) { |
| background: var(--rst-surface); |
| } |
| + /* The overflow: a <details>, so it opens with scripts off, holding |
| + estilo's own menu rows. Its trigger is the same pill, round. */ |
| + [slides-more] { |
| + position: relative; |
| + } |
| + [slides-tools] [slides-more] > summary { |
| + list-style: none; |
| + min-inline-size: 36px; |
| + padding-inline: 0; |
| + justify-content: center; |
| + } |
| + [slides-more] > summary::-webkit-details-marker { |
| + display: none; |
| + } |
| + [slides-more] > summary::marker { |
| + content: ""; |
| + } |
| + [slides-more][open] > summary { |
| + background: var(--rst-accent-soft); |
| + } |
| + [slides-more] > [estilo-menu] { |
| + inset-block-start: calc(100% + 4px); |
| + inset-inline-end: 0; |
| + position: absolute; |
| + } |
| [slides-viewer] [slides-stage] { |
| - margin-block: var(--rst-sp-4) var(--rst-sp-3); |
| + margin-block: var(--rst-sp-3); |
| } |
| [slides-viewer] [slides-stage] > [slides-slide] { |
| border-radius: 6px; |
| @@ -108,20 +159,25 @@ |
| font-weight: 600; |
| min-block-size: 24px; |
| } |
| + /* The slides, as their own pictures. Below 1100px one row that |
| + scrolls sideways under the slide; from 1100px the rail. */ |
| [slides-film-nav] { |
| - margin-block-start: var(--rst-sp-5); |
| + min-inline-size: 0; |
| } |
| [slides-film] { |
| counter-reset: slides-film; |
| - display: grid; |
| + display: flex; |
| gap: var(--rst-sp-3); |
| - grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); |
| list-style: none; |
| margin: 0; |
| - padding: 0; |
| + overflow-x: auto; |
| + padding: 6px 6px var(--rst-sp-2); |
| + scrollbar-width: thin; |
| } |
| [slides-film] > li { |
| counter-increment: slides-film; |
| + flex: none; |
| + inline-size: 9.5rem; |
| } |
| [slides-film] a { |
| color: var(--rst-text-muted); |
| @@ -133,8 +189,14 @@ |
| min-height: 24px; |
| text-decoration: none; |
| } |
| + [slides-film] a > span { |
| + overflow: hidden; |
| + text-overflow: ellipsis; |
| + white-space: nowrap; |
| + } |
| [slides-film] a > span::before { |
| content: counter(slides-film) " "; |
| + font-variant-numeric: tabular-nums; |
| font-weight: 500; |
| white-space: pre; |
| } |
| @@ -169,6 +231,39 @@ |
| outline: 2px solid var(--rst-accent); |
| outline-offset: 3px; |
| } |
| + @media (min-width: 1100px) { |
| + [slides-viewer] { |
| + align-items: start; |
| + column-gap: var(--rst-sp-5); |
| + grid-template-areas: "film main"; |
| + grid-template-columns: 12rem minmax(0, 1fr); |
| + } |
| + [slides-viewer-main] { |
| + grid-area: main; |
| + } |
| + /* The rail stays in view while the slide and its notes scroll, and |
| + scrolls inside itself (the editor's strip does the same). */ |
| + /* Its first picture level with the slide's top edge, under the |
| + row of buttons rather than beside it. */ |
| + [slides-film-nav] { |
| + grid-area: film; |
| + margin-block-start: calc(36px + var(--rst-sp-3) - 6px); |
| + max-block-size: calc(100dvh - 2 * var(--rst-sp-4)); |
| + overflow-y: auto; |
| + position: sticky; |
| + inset-block-start: var(--rst-sp-4); |
| + scrollbar-width: thin; |
| + } |
| + [slides-film] { |
| + flex-direction: column; |
| + gap: var(--rst-sp-4); |
| + overflow-x: visible; |
| + padding: 6px; |
| + } |
| + [slides-film] > li { |
| + inline-size: auto; |
| + } |
| + } |
| </style>{{end}} |
| {{define "content"}} |
| {{/* The slide's announcement when the script changes it in place |
| @@ -190,18 +285,11 @@ |
| </div> |
| {{else}} |
| <div slides-viewer data-vp="{{.VP}}"{{with .Announce}} data-announce="{{.}}"{{end}}> |
| -{{if .BackHref}}{{template "back-nav" dict "Href" .BackHref "Label" .BackLabel}}{{end}} |
| -{{template "page-header" dict "Title" .Title}} |
| -{{if or .EditHref .SettingsHref .ShareHref .NotesHref .ExportHref .PresentHref .PresentAction .FollowHref}} |
| +<h1 class="rst-sr-only">{{.Title}}</h1> |
| +<div slides-viewer-main> |
| +{{if or .EditHref .NotesHref .ExportHref .PresentHref .PresentAction .FollowHref}} |
| <nav slides-tools aria-label="{{.ToolsLabel}}"> |
| - {{if .EditHref}}<a rst-btn="primary" href="{{.EditHref}}">{{.EditLabel}}</a>{{end}} |
| - {{if .SettingsHref}}<a rst-btn href="{{.SettingsHref}}">{{.SettingsLabel}}</a>{{end}} |
| - {{if .ShareHref}}<a rst-btn href="{{.ShareHref}}">{{.ShareLabel}}</a>{{end}} |
| - {{if .NotesHref}}<a rst-btn href="{{.NotesHref}}">{{.NotesPageLabel}}</a>{{end}} |
| - {{/* Export is a LINK to a screen of its own, not a form button: it |
| - asks whether the speaker notes go in the file before it starts |
| - anything (exports.go). */}} |
| - {{if .ExportHref}}<a rst-btn href="{{.ExportHref}}">{{.ExportLabel}}</a>{{end}} |
| + {{if .EditHref}}<a rst-btn href="{{.EditHref}}">{{icon "pencil"}}<span>{{.EditLabel}}</span></a>{{end}} |
| {{/* Present is a FORM on the signed-in screens, because pressing it |
| writes: it opens a session and mints the remote's capability |
| (presentation.go). Over a share link it stays a link to the same |
| @@ -210,12 +298,26 @@ |
| somebody else's deck. */}} |
| {{if .PresentAction}} |
| <form method="post" action="{{.PresentAction}}"> |
| - <button rst-btn="primary" type="submit">{{.PresentLabel}}</button> |
| + <button rst-btn="primary" type="submit">{{icon "play"}}<span>{{.PresentLabel}}</span></button> |
| </form> |
| - {{else if .PresentHref}}<a rst-btn href="{{.PresentHref}}">{{.PresentLabel}}</a>{{end}} |
| + {{else if .PresentHref}}<a rst-btn href="{{.PresentHref}}">{{icon "play"}}<span>{{.PresentLabel}}</span></a>{{end}} |
| {{/* Somebody is presenting this deck right now, and this is the |
| offer to watch along (spec §3.4). Only ever on a share link. */}} |
| {{if .FollowHref}}<a rst-btn="primary" href="{{.FollowHref}}">{{.FollowLabel}}</a>{{end}} |
| + {{/* The rest of what a reader may do with the deck, in one overflow |
| + rather than a row of pills: all the notes on one page, and the PDF. |
| + Export is a LINK to a screen of its own, not a form button: it |
| + asks whether the speaker notes go in the file before it starts |
| + anything (exports.go). */}} |
| + {{if or .NotesHref .ExportHref}} |
| + <details slides-more name="estilo-menus"> |
| + <summary rst-btn title="{{.MoreLabel}}">{{icon "ellipsis"}}<span class="rst-sr-only">{{.MoreLabel}}</span></summary> |
| + <div estilo-menu> |
| + {{if .NotesHref}}<a estilo-menu-item href="{{.NotesHref}}"><span estilo-menu-label>{{.NotesPageLabel}}</span></a>{{end}} |
| + {{if .ExportHref}}<a estilo-menu-item href="{{.ExportHref}}"><span estilo-menu-label>{{.ExportLabel}}</span></a>{{end}} |
| + </div> |
| + </details> |
| + {{end}} |
| </nav> |
| {{end}} |
| @@ -236,7 +338,14 @@ |
| {{.Notes}} |
| </details> |
| {{end}} |
| +{{else}} |
| +<div rst-box> |
| + {{template "empty-state" dict "Title" .EmptyTitle "Body" .EmptyBody "ActionHref" .EditHref "ActionLabel" .EditLabel}} |
| +</div> |
| +{{end}} |
| +</div> |
| +{{if .HasSlides}} |
| <nav slides-film-nav aria-label="{{.FilmLabel}}"> |
| <ol slides-film> |
| {{range .Film}} |
| @@ -244,10 +353,6 @@ |
| {{end}} |
| </ol> |
| </nav> |
| -{{else}} |
| -<div rst-box> |
| - {{template "empty-state" dict "Title" .EmptyTitle "Body" .EmptyBody "ActionHref" .EditHref "ActionLabel" .EditLabel}} |
| -</div> |
| {{end}} |
| </div> |
| {{end}} |
diff --git a/internal/slides/viewer.go b/internal/slides/viewer.go| index 4187cc3..535c78d 100644 |
| --- a/internal/slides/viewer.go |
| +++ b/internal/slides/viewer.go |
| @@ -21,6 +21,8 @@ import ( |
| "strconv" |
| "strings" |
| + "amadan.net/oficina/estilo.git/chrome" |
| + estilomenu "amadan.net/oficina/estilo.git/menu" |
| "amadan.net/rastrillo/rastrillo" |
| "amadan.net/oficina/slides/internal/slides/deck" |
| @@ -100,12 +102,13 @@ type viewerPage struct { |
| // EditHref opens the editor (editor.go). Owner and member alike: |
| // the editor is deckFor's audience, the same people the live-sync |
| // endpoints behind it let write. |
| - EditHref string |
| - EditLabel string |
| - SettingsHref string |
| - SettingsLabel string |
| - ShareHref string |
| - ShareLabel string |
| + EditHref string |
| + EditLabel string |
| + // The overflow (MoreLabel): the deck's other reading screens, kept |
| + // out of the row so the row is what a reader reaches for — Edit and |
| + // Present. Share… is in the bar (Docs' place for it), and the deck's |
| + // settings are the editor's inspector and the share page's. |
| + MoreLabel string |
| NotesHref string |
| NotesPageLabel string |
| // ExportHref opens the export screen (exports.go). Owner and |
| @@ -125,17 +128,26 @@ type viewerPage struct { |
| // the rest of the time, which is nearly always. |
| FollowHref string |
| FollowLabel string |
| - |
| - BackHref string |
| - BackLabel string |
| } |
| // --- GET /d/{sqid} --- |
| -// showDeck serves the signed-in viewer. Which of the two signed-in |
| -// modes it renders is the ownership question and nothing else: a |
| -// member reached this deck through visibleDecks, so they read the |
| -// notes, and only the owner is offered the screens that change it. |
| +// showDeck serves the signed-in viewer, or opens the editor. |
| +// |
| +// A deck's own address opens it to be worked on, as a document's does |
| +// in Docs (Paul, 2026-11-11: he opened a deck and landed on a read-only |
| +// page): everybody deckFor lets in may edit (editor.go), so the bare |
| +// address is a 303 to /edit. The viewer is the same address with a |
| +// query — ?slide=N, which is what every link inside it already is — so |
| +// it stays reachable for somebody with scripts off (the editor's |
| +// <noscript> links it), for the File menu's "Open in the viewer", and |
| +// for the in-place paging that fetches its pages. The redirect comes |
| +// after deckFor, so a stranger still gets the same 404 either way. |
| +// |
| +// Which of the two signed-in modes it renders is the ownership |
| +// question and nothing else: a member reached this deck through |
| +// visibleDecks, so they read the notes, and only the owner is offered |
| +// the screens that change it. |
| func (a *app) showDeck(w http.ResponseWriter, r *http.Request) { |
| u, ok := a.viewer(w, r) |
| if !ok { |
| @@ -145,13 +157,28 @@ func (a *app) showDeck(w http.ResponseWriter, r *http.Request) { |
| if !ok { |
| return |
| } |
| + if r.URL.RawQuery == "" { |
| + http.Redirect(w, r, editorHref(d.Sqid), http.StatusSeeOther) |
| + return |
| + } |
| mode := modeMember |
| + f := frame{parts: []string{d.Title}, context: d.Title} |
| if a.mayShareDeck(r.Context(), u, d) { |
| mode = modeOwner |
| + // Share… in the bar's actions, where Docs puts it on a |
| + // document (Docs' handlers.go, docs.share.action). |
| + f.actions = []chrome.Action{{Item: estilomenu.Item{Href: "/d/" + d.Sqid + "/share", Label: rastrillo.T(r, "slides.share.action")}}} |
| } |
| - a.renderViewer(w, r, d, mode, "/d/"+d.Sqid, a.shellFor(r, u, titled(d.Title))) |
| + a.renderViewer(w, r, d, mode, "/d/"+d.Sqid, a.shellFor(r, u, f)) |
| } |
| +// editorHref is a deck's editor: where a deck opens. |
| +func editorHref(sqid string) string { return "/d/" + sqid + "/edit" } |
| + |
| +// viewerStart is the viewer's first slide: the deck's address with the |
| +// query that keeps it the viewer (showDeck). |
| +func viewerStart(sqid string) string { return viewerHref("/d/"+sqid, 1, "desktop", false) } |
| + |
| // renderViewer is the one viewer, for all three audiences. base is the |
| // URL every link on the page hangs off — "/d/{sqid}" signed in, |
| // "/s/{token}" over a share link — so the page never has to know which |
| @@ -182,37 +209,20 @@ func (a *app) renderViewer(w http.ResponseWriter, r *http.Request, d Deck, mode, |
| VP: vp, |
| Title: view.Meta.Title, |
| } |
| - if mode != modeLink { |
| - page.BackHref = "/" |
| - page.BackLabel = rastrillo.T(r, "slides.decks.title") |
| - } |
| // The buttons, before anything about which slide is being shown: |
| - // they are about the deck, not about the slide, so an owner whose |
| - // document has come back empty still has a way to its settings. |
| + // they are about the deck, not about the slide, so a deck whose |
| + // document has come back empty still has a way into the editor. |
| // modeLink's present link is the exception and waits for the index, |
| // because it is a link to a slide. |
| page.ToolsLabel = rastrillo.T(r, "slides.viewer.tools") |
| switch mode { |
| - case modeOwner: |
| - page.EditHref = base + "/edit" |
| - page.EditLabel = rastrillo.T(r, "slides.viewer.edit") |
| - page.SettingsHref = base + "/settings" |
| - page.SettingsLabel = rastrillo.T(r, "slides.deck.settings") |
| - page.ShareHref = base + "/share" |
| - page.ShareLabel = rastrillo.T(r, "slides.viewer.share") |
| - page.NotesHref = base + "/notes" |
| - page.NotesPageLabel = rastrillo.T(r, "slides.viewer.notes.page") |
| - page.ExportHref = base + "/export" |
| - page.ExportLabel = rastrillo.T(r, "slides.viewer.export") |
| - page.PresentAction = base + "/present" |
| - page.PresentLabel = rastrillo.T(r, "slides.viewer.present") |
| - case modeMember: |
| + case modeOwner, modeMember: |
| page.EditHref = base + "/edit" |
| page.EditLabel = rastrillo.T(r, "slides.viewer.edit") |
| + page.MoreLabel = rastrillo.T(r, "slides.viewer.more") |
| page.NotesHref = base + "/notes" |
| page.NotesPageLabel = rastrillo.T(r, "slides.viewer.notes.page") |
| - // A member exports too, for the same reason. |
| page.ExportHref = base + "/export" |
| page.ExportLabel = rastrillo.T(r, "slides.viewer.export") |
| // A member presents too: reading a deck to a room is reading |
diff --git a/internal/slidestest/browser_assets_test.go b/internal/slidestest/browser_assets_test.go| index e69da21..84c8de0 100644 |
| --- a/internal/slidestest/browser_assets_test.go |
| +++ b/internal/slidestest/browser_assets_test.go |
| @@ -35,7 +35,7 @@ func TestBrowserUploadsAnImage(t *testing.T) { |
| } |
| var deck string |
| - rig.Run(chromedp.Evaluate(`(document.querySelector('a[href^="/d/"]')?.getAttribute('href') ?? '')`, &deck)) |
| + rig.Run(chromedp.Evaluate(`(document.querySelector('a[href^="/d/"]')?.getAttribute('href') ?? '').replace(/\/edit$/, '')`, &deck)) |
| const bound = `document.querySelector('[slides-stage] [data-block="heading"]')?.getAttribute('contenteditable') === 'true'` |
| const saved = `document.querySelector('[estilo-save-status]').dataset.state === 'saved'` |
diff --git a/internal/slidestest/browser_csp_test.go b/internal/slidestest/browser_csp_test.go| index 7a92514..52d8aa9 100644 |
| --- a/internal/slidestest/browser_csp_test.go |
| +++ b/internal/slidestest/browser_csp_test.go |
| @@ -28,7 +28,7 @@ func TestSlideStylesSurviveTheProductionCSP(t *testing.T) { |
| rig, mailer := newRig(t) |
| browserSignIn(t, rig, mailer) |
| var deck string |
| - rig.Run(chromedp.Evaluate(`(document.querySelector('a[href^="/d/"]')?.getAttribute('href') ?? '')`, &deck)) |
| + rig.Run(chromedp.Evaluate(`(document.querySelector('a[href^="/d/"]')?.getAttribute('href') ?? '').replace(/\/edit$/, '')`, &deck)) |
| if deck == "" { |
| t.Fatal("the deck list links no deck") |
| } |
diff --git a/internal/slidestest/browser_editor_strip_test.go b/internal/slidestest/browser_editor_strip_test.go| index dd05d34..305e1fd 100644 |
| --- a/internal/slidestest/browser_editor_strip_test.go |
| +++ b/internal/slidestest/browser_editor_strip_test.go |
| @@ -26,7 +26,7 @@ func openEditor(t *testing.T) (*harness.Rig, *fakeMailer, string) { |
| rig, mailer := newRig(t) |
| browserSignIn(t, rig, mailer) |
| var deck string |
| - rig.Run(chromedp.Evaluate(`(document.querySelector('a[href^="/d/"]')?.getAttribute('href') ?? '')`, &deck)) |
| + rig.Run(chromedp.Evaluate(`(document.querySelector('a[href^="/d/"]')?.getAttribute('href') ?? '').replace(/\/edit$/, '')`, &deck)) |
| if !deckPath.MatchString(deck) { |
| t.Fatalf("the deck list links no deck: %q", deck) |
| } |
diff --git a/internal/slidestest/browser_phone_test.go b/internal/slidestest/browser_phone_test.go| index fcf39fa..4ca66d7 100644 |
| --- a/internal/slidestest/browser_phone_test.go |
| +++ b/internal/slidestest/browser_phone_test.go |
| @@ -77,7 +77,7 @@ func TestBrowserPhoneStacksFlowRegions(t *testing.T) { |
| browserSignIn(t, rig, mailer) |
| var deck string |
| - rig.Run(chromedp.Evaluate(`(document.querySelector('a[href^="/d/"]')?.getAttribute('href') ?? '')`, &deck)) |
| + rig.Run(chromedp.Evaluate(`(document.querySelector('a[href^="/d/"]')?.getAttribute('href') ?? '').replace(/\/edit$/, '')`, &deck)) |
| if !deckPath.MatchString(deck) { |
| t.Fatalf("the deck list links no deck: %q", deck) |
| } |
| @@ -85,7 +85,7 @@ func TestBrowserPhoneStacksFlowRegions(t *testing.T) { |
| var count, flowsSeen int |
| rig.Run( |
| chromedp.EmulateViewport(390, 844, chromedp.EmulateMobile), |
| - chromedp.Navigate(rig.Origin+deck), |
| + chromedp.Navigate(rig.Origin+deck+"?slide=1"), |
| chromedp.WaitVisible(`[slides-slide]`, chromedp.ByQuery), |
| chromedp.Evaluate(`document.querySelectorAll('[slides-film] a').length`, &count), |
| ) |
diff --git a/internal/slidestest/browser_present_test.go b/internal/slidestest/browser_present_test.go| index 6b74425..b9cedfa 100644 |
| --- a/internal/slidestest/browser_present_test.go |
| +++ b/internal/slidestest/browser_present_test.go |
| @@ -30,14 +30,14 @@ func TestBrowserProjectorFitsTheViewport(t *testing.T) { |
| browserSignIn(t, rig, mailer) |
| var deck string |
| - rig.Run(chromedp.Evaluate(`(document.querySelector('a[href^="/d/"]')?.getAttribute('href') ?? '')`, &deck)) |
| + rig.Run(chromedp.Evaluate(`(document.querySelector('a[href^="/d/"]')?.getAttribute('href') ?? '').replace(/\/edit$/, '')`, &deck)) |
| if !deckPath.MatchString(deck) { |
| t.Fatalf("the deck list links no deck: %q", deck) |
| } |
| var path string |
| rig.Run( |
| - chromedp.Navigate(rig.Origin+deck), |
| + chromedp.Navigate(rig.Origin+deck+"?slide=1"), |
| chromedp.Click(`form[action$="/present"] button`, chromedp.ByQuery), |
| waitFor(`location.pathname.endsWith('/notes')`), |
| chromedp.Evaluate(`location.pathname + location.search`, &path), |
| @@ -102,14 +102,14 @@ func TestBrowserPresentingScreensHoldStill(t *testing.T) { |
| }) |
| var deck string |
| - rig.Run(chromedp.Evaluate(`(document.querySelector('a[href^="/d/"]')?.getAttribute('href') ?? '')`, &deck)) |
| + rig.Run(chromedp.Evaluate(`(document.querySelector('a[href^="/d/"]')?.getAttribute('href') ?? '').replace(/\/edit$/, '')`, &deck)) |
| if !deckPath.MatchString(deck) { |
| t.Fatalf("the deck list links no deck: %q", deck) |
| } |
| var path string |
| rig.Run( |
| - chromedp.Navigate(rig.Origin+deck), |
| + chromedp.Navigate(rig.Origin+deck+"?slide=1"), |
| chromedp.Click(`form[action$="/present"] button`, chromedp.ByQuery), |
| waitFor(`location.pathname.endsWith('/notes')`), |
| chromedp.Evaluate(`location.pathname + location.search`, &path), |
diff --git a/internal/slidestest/browser_test.go b/internal/slidestest/browser_test.go| index d6ed0ab..ed97e79 100644 |
| --- a/internal/slidestest/browser_test.go |
| +++ b/internal/slidestest/browser_test.go |
| @@ -186,7 +186,7 @@ func TestBrowserEditsTheTitle(t *testing.T) { |
| browserSignIn(t, rig, mailer) |
| var deck string |
| - rig.Run(chromedp.Evaluate(`(document.querySelector('a[href^="/d/"]')?.getAttribute('href') ?? '')`, &deck)) |
| + rig.Run(chromedp.Evaluate(`(document.querySelector('a[href^="/d/"]')?.getAttribute('href') ?? '').replace(/\/edit$/, '')`, &deck)) |
| if !deckPath.MatchString(deck) { |
| t.Fatalf("the deck list links no deck: %q", deck) |
| } |
| @@ -221,7 +221,7 @@ func TestBrowserEditsTheTitle(t *testing.T) { |
| t.Errorf("the strip's label for the current slide reads %q, want the typed text", stripLabel) |
| } |
| - rig.Run(chromedp.Navigate(rig.Origin + deck)) |
| + rig.Run(chromedp.Navigate(rig.Origin + deck + "?slide=1")) |
| rig.Screen("[slides-viewer]", "viewer") |
| var shown string |
| rig.Run(chromedp.Text(`[slides-stage] [data-block="heading"]`, &shown, chromedp.ByQuery)) |
| @@ -238,7 +238,7 @@ func TestBrowserNewSlideAndUndo(t *testing.T) { |
| rig, mailer := newRig(t) |
| browserSignIn(t, rig, mailer) |
| var deck string |
| - rig.Run(chromedp.Evaluate(`(document.querySelector('a[href^="/d/"]')?.getAttribute('href') ?? '')`, &deck)) |
| + rig.Run(chromedp.Evaluate(`(document.querySelector('a[href^="/d/"]')?.getAttribute('href') ?? '').replace(/\/edit$/, '')`, &deck)) |
| rig.Run( |
| chromedp.Navigate(rig.Origin+deck+"/edit"), |
| @@ -351,7 +351,7 @@ func TestBrowserSeesAnotherWriter(t *testing.T) { |
| rig, mailer := newRig(t) |
| browserSignIn(t, rig, mailer) |
| var deck string |
| - rig.Run(chromedp.Evaluate(`(document.querySelector('a[href^="/d/"]')?.getAttribute('href') ?? '')`, &deck)) |
| + rig.Run(chromedp.Evaluate(`(document.querySelector('a[href^="/d/"]')?.getAttribute('href') ?? '').replace(/\/edit$/, '')`, &deck)) |
| const heading = `[slides-stage] [data-block="heading"]` |
| rig.Run( |
| @@ -421,7 +421,7 @@ func TestBrowserPresenceShowsEachOther(t *testing.T) { |
| rig, mailer := newRig(t) |
| browserSignIn(t, rig, mailer) |
| var deck string |
| - rig.Run(chromedp.Evaluate(`(document.querySelector('a[href^="/d/"]')?.getAttribute('href') ?? '')`, &deck)) |
| + rig.Run(chromedp.Evaluate(`(document.querySelector('a[href^="/d/"]')?.getAttribute('href') ?? '').replace(/\/edit$/, '')`, &deck)) |
| const bound = `document.querySelector('[slides-stage] [data-block="heading"]')?.getAttribute('contenteditable') === 'true'` |
| rig.Run( |
| @@ -530,7 +530,7 @@ func TestBrowserInspectorAndCanvas(t *testing.T) { |
| rig, mailer := newRig(t) |
| browserSignIn(t, rig, mailer) |
| var deck string |
| - rig.Run(chromedp.Evaluate(`(document.querySelector('a[href^="/d/"]')?.getAttribute('href') ?? '')`, &deck)) |
| + rig.Run(chromedp.Evaluate(`(document.querySelector('a[href^="/d/"]')?.getAttribute('href') ?? '').replace(/\/edit$/, '')`, &deck)) |
| const bound = `document.querySelector('[slides-stage] [data-block="heading"]')?.getAttribute('contenteditable') === 'true'` |
| const saved = `document.querySelector('[estilo-save-status]').dataset.state === 'saved'` |
diff --git a/internal/slidestest/capabilities_test.go b/internal/slidestest/capabilities_test.go| index 840b817..380ba6d 100644 |
| --- a/internal/slidestest/capabilities_test.go |
| +++ b/internal/slidestest/capabilities_test.go |
| @@ -325,7 +325,7 @@ func TestRemovingAnAddressEndsItsSessionsAndItsAgents(t *testing.T) { |
| sqid := apiDeck(t, before, token, "Leaving") |
| deck := "/d/" + sqid |
| // Both credentials work while the address is on the list. |
| - mustGet(t, before, deck, http.StatusOK, cookies) |
| + mustGet(t, before, deck+"?slide=1", http.StatusOK, cookies) |
| apiJSON(t, before, http.MethodGet, "/api/v1/decks/"+sqid, token, "", http.StatusOK) |
| // Somebody presenting on the way out, so the lifecycle question the |
diff --git a/internal/slidestest/decks_test.go b/internal/slidestest/decks_test.go| index 88bfa01..d77a614 100644 |
| --- a/internal/slidestest/decks_test.go |
| +++ b/internal/slidestest/decks_test.go |
| @@ -65,7 +65,7 @@ func TestNewDeckAppearsInList(t *testing.T) { |
| path := createDeck(t, a, cookies, "Roadmap") |
| - deckPage := mustGet(t, a, path, http.StatusOK, cookies).Body.String() |
| + deckPage := mustGet(t, a, path+"?slide=1", http.StatusOK, cookies).Body.String() |
| if !strings.Contains(deckPage, "Roadmap") { |
| t.Errorf("GET %s does not name the deck:\n%s", path, deckPage) |
| } |
| @@ -95,7 +95,7 @@ func TestSampleDeckSeededOnFirstSignin(t *testing.T) { |
| if path == "" { |
| t.Fatalf("GET / lists no deck link:\n%s", list) |
| } |
| - page := mustGet(t, a, path, http.StatusOK, cookies).Body.String() |
| + page := mustGet(t, a, path+"?slide=1", http.StatusOK, cookies).Body.String() |
| // Eight slides, every flow template plus two canvas slides, and |
| // notes on each: the sample is what teaches the model, so an empty |
| // one would pass every other assertion here. |
| @@ -160,7 +160,7 @@ func TestTeamDeckVisibleToOthers(t *testing.T) { |
| t.Fatalf("POST %s/settings: status %d, want 303\n%s", path, rec.Code, rec.Body) |
| } |
| - mustGet(t, a, path, http.StatusOK, theirs) |
| + mustGet(t, a, path+"?slide=1", http.StatusOK, theirs) |
| list := mustGet(t, a, "/", http.StatusOK, theirs).Body.String() |
| if !strings.Contains(list, "All hands") { |
| t.Errorf("a team deck is missing from another person's list:\n%s", list) |
| @@ -195,7 +195,7 @@ func TestRenameAndDelete(t *testing.T) { |
| } |
| // The document carries the title too, not only the row: the deck |
| // page renders what the core holds. |
| - page := mustGet(t, a, path, http.StatusOK, mine).Body.String() |
| + page := mustGet(t, a, path+"?slide=1", http.StatusOK, mine).Body.String() |
| if !strings.Contains(page, "Final") { |
| t.Errorf("the rename did not reach the document:\n%s", page) |
| } |
diff --git a/internal/slidestest/editor_test.go b/internal/slidestest/editor_test.go| index 80a219f..ee30f06 100644 |
| --- a/internal/slidestest/editor_test.go |
| +++ b/internal/slidestest/editor_test.go |
| @@ -99,7 +99,8 @@ func TestEditorPageLinksTheCommittedBundle(t *testing.T) { |
| t.Errorf("the editor page lacks %s:\n%s", want, page) |
| } |
| } |
| - if !strings.Contains(page, `href="`+path+`"`) { |
| + // The viewer by its first slide: the bare address opens this page. |
| + if !strings.Contains(page, `href="`+path+`?slide=1"`) { |
| t.Errorf("the noscript fallback does not link the viewer:\n%s", page) |
| } |
| // Every shortcut has a visible menu equivalent. |
| @@ -123,7 +124,7 @@ func TestEditorRequiresMembership(t *testing.T) { |
| mustGet(t, a, path+"/edit", http.StatusNotFound, theirs) |
| mustGet(t, a, path+"/edit", http.StatusOK, mine) |
| - owner := mustGet(t, a, path, http.StatusOK, mine).Body.String() |
| + owner := mustGet(t, a, path+"?slide=1", http.StatusOK, mine).Body.String() |
| if !strings.Contains(owner, `href="`+path+`/edit"`) { |
| t.Errorf("the owner's viewer offers no Edit:\n%s", owner) |
| } |
| @@ -134,7 +135,7 @@ func TestEditorRequiresMembership(t *testing.T) { |
| t.Fatalf("raising the rung: status %d\n%s", rec.Code, rec.Body) |
| } |
| mustGet(t, a, path+"/edit", http.StatusOK, theirs) |
| - member := mustGet(t, a, path, http.StatusOK, theirs).Body.String() |
| + member := mustGet(t, a, path+"?slide=1", http.StatusOK, theirs).Body.String() |
| if !strings.Contains(member, `href="`+path+`/edit"`) { |
| t.Errorf("a member's viewer offers no Edit:\n%s", member) |
| } |
diff --git a/internal/slidestest/export_test.go b/internal/slidestest/export_test.go| index 097073b..2234fd7 100644 |
| --- a/internal/slidestest/export_test.go |
| +++ b/internal/slidestest/export_test.go |
| @@ -66,7 +66,7 @@ func TestExportJobProducesADownload(t *testing.T) { |
| deck := sampleDeck(t, a, cookies) |
| // The viewer offers it, to the person who can read the deck. |
| - page := mustGet(t, a, deck, http.StatusOK, cookies).Body.String() |
| + page := mustGet(t, a, deck+"?slide=1", http.StatusOK, cookies).Body.String() |
| if !strings.Contains(page, `href="`+deck+`/export"`) { |
| t.Errorf("the viewer has no export button:\n%s", page) |
| } |
| @@ -303,7 +303,7 @@ func TestExportPdfIsOwnersOnly(t *testing.T) { |
| if rec.Code != http.StatusSeeOther { |
| t.Fatalf("POST %s/settings: status %d\n%s", deck, rec.Code, rec.Body) |
| } |
| - mustGet(t, a, deck, http.StatusOK, theirs) |
| + mustGet(t, a, deck+"?slide=1", http.StatusOK, theirs) |
| status := startExport(t, a, deck, mine, nil) |
| waitForExport(t, a, status, mine) |
diff --git a/internal/slidestest/fontgate_test.go b/internal/slidestest/fontgate_test.go| index c069e3a..5bd9590 100644 |
| --- a/internal/slidestest/fontgate_test.go |
| +++ b/internal/slidestest/fontgate_test.go |
| @@ -99,7 +99,7 @@ func TestOnlySlideSurfacesCarryTheGateAndPreloadOnlyDeckFaces(t *testing.T) { |
| cookies []*http.Cookie |
| gated bool |
| }{ |
| - {deck, cookies, true}, |
| + {deck + "?slide=1", cookies, true}, |
| {deck + "?slide=2&vp=phone", cookies, true}, |
| {deck + "?present=1", cookies, true}, |
| {deck + "/edit", cookies, true}, |
| @@ -155,7 +155,7 @@ func TestThePreloadsAreEveryStyleOfEveryFamilyTheDeckUses(t *testing.T) { |
| t.Run(c.name, func(t *testing.T) { |
| deck := opsDeck(t, a, token, c.name, c.ops) |
| for _, path := range []string{deck, deck + "/edit"} { |
| - page := mustGet(t, a, path, http.StatusOK, cookies).Body.String() |
| + page := mustGet(t, a, path+"?slide=1", http.StatusOK, cookies).Body.String() |
| preloads, carries := gateOn(t, path, page) |
| if !carries { |
| t.Fatalf("%s carries no gate", path) |
diff --git a/internal/slidestest/fonts_browser_test.go b/internal/slidestest/fonts_browser_test.go| index e9f3a28..7ad5618 100644 |
| --- a/internal/slidestest/fonts_browser_test.go |
| +++ b/internal/slidestest/fonts_browser_test.go |
| @@ -464,7 +464,7 @@ func TestFontSlideTextIsNotPaintedBeforeItsFontsAreReady(t *testing.T) { |
| sqid := fr.deck(t, "Faces", paperDeck) |
| fr.slow.Store(int64(700 * time.Millisecond)) |
| start := time.Now() |
| - fr.rig.Run(fr.navigate("/d/" + sqid)) |
| + fr.rig.Run(fr.navigate("/d/" + sqid + "?slide=1")) |
| fr.shown(t) |
| if waited := time.Since(start); waited < 650*time.Millisecond { |
| t.Fatalf("the slide was shown %v after navigating, before the fonts could have arrived: the slowdown did not apply", waited) |
| @@ -492,7 +492,7 @@ func TestFontALateFamilyCommitsToItsFallbackAndNeverSwaps(t *testing.T) { |
| // arriving before the deadline. |
| fr.match.Store("LiberationSerif-") |
| fr.slow.Store(int64(4 * time.Second)) |
| - fr.rig.Run(fr.navigate("/d/" + sqid)) |
| + fr.rig.Run(fr.navigate("/d/" + sqid + "?slide=1")) |
| fr.shown(t) |
| // Let the late files land, and keep sampling while they do. |
| fr.rig.Run(chromedp.Sleep(4 * time.Second)) |
| @@ -528,7 +528,7 @@ func TestFontTheFirstRevealIsTheFinalLayout(t *testing.T) { |
| editorDelay time.Duration |
| after time.Duration |
| }{ |
| - {name: "viewer", path: func(_ *fontRig, s string) string { return "/d/" + s }}, |
| + {name: "viewer", path: func(_ *fontRig, s string) string { return "/d/" + s + "?slide=1" }}, |
| {name: "viewer at a phone width", path: func(_ *fontRig, s string) string { return "/d/" + s + "?vp=phone" }, width: 390}, |
| {name: "viewer presenting", path: func(_ *fontRig, s string) string { return "/d/" + s + "?present=1&slide=2" }}, |
| {name: "projector", path: func(fr *fontRig, s string) string { |
| @@ -615,7 +615,7 @@ func TestFontWithoutJavaScriptTheSystemFacesAreFinal(t *testing.T) { |
| // rendering), so the first look is once slides.css has arrived. |
| // (A loop of plain evaluations, not chromedp.Poll: its polling is a |
| // promise in the page, and the page runs no script.) |
| - fr.rig.Run(fr.navigate("/d/"+sqid), chromedp.WaitReady(`[slides-slide]`, chromedp.ByQuery)) |
| + fr.rig.Run(fr.navigate("/d/"+sqid+"?slide=1"), chromedp.WaitReady(`[slides-slide]`, chromedp.ByQuery)) |
| for deadline := time.Now().Add(10 * time.Second); ; { |
| var in bool |
| fr.rig.Run(chromedp.Evaluate(`[...document.styleSheets].some((s) => s.href && s.href.includes('/static/slides.') && s.cssRules.length > 0)`, &in)) |
| @@ -663,7 +663,7 @@ func TestFontThePreloadsAreTheFacesTheGateLoads(t *testing.T) { |
| fr := newFontRig(t) |
| sqid := fr.deck(t, "Preloads", inkDeck) |
| fr.slow.Store(int64(300 * time.Millisecond)) |
| - fr.rig.Run(fr.navigate("/d/" + sqid)) |
| + fr.rig.Run(fr.navigate("/d/" + sqid + "?slide=1")) |
| fr.shown(t) |
| fr.rig.Run(chromedp.Sleep(1 * time.Second)) |
| fr.mu.Lock() |
| @@ -1382,7 +1382,7 @@ func (fr *fontRig) randomDecks(t *testing.T, n int, seed string) []string { |
| t.Fatal(err) |
| } |
| } |
| - page := get(t, fr.app, "/d/"+sqids[0], fr.cookies...).Body.String() |
| + page := get(t, fr.app, "/d/"+sqids[0]+"?slide=1", fr.cookies...).Body.String() |
| m := manifestMeta.FindStringSubmatch(page) |
| if m == nil { |
| t.Fatal("no font manifest on the viewer") |
diff --git a/internal/slidestest/fonts_test.go b/internal/slidestest/fonts_test.go| index 438f23d..6582574 100644 |
| --- a/internal/slidestest/fonts_test.go |
| +++ b/internal/slidestest/fonts_test.go |
| @@ -115,7 +115,7 @@ func TestSlidesCSSDeclaresNoFontFace(t *testing.T) { |
| // cannot fetch is the divergence this whole font set exists to close. |
| func TestTheFontManifestDeclaresEveryEmbeddedFace(t *testing.T) { |
| a, deck, cookies := sampleViewer(t) |
| - m, ok := readManifest(t, mustGet(t, a, deck, http.StatusOK, cookies).Body.String()) |
| + m, ok := readManifest(t, mustGet(t, a, deck+"?slide=1", http.StatusOK, cookies).Body.String()) |
| if !ok { |
| t.Fatal("the viewer carries no font manifest") |
| } |
| @@ -158,7 +158,7 @@ func TestTheFontManifestDeclaresEveryEmbeddedFace(t *testing.T) { |
| // paying for files that never change. |
| func TestTheFontManifestURLsCarryTheirContentHash(t *testing.T) { |
| a, deck, cookies := sampleViewer(t) |
| - m, _ := readManifest(t, mustGet(t, a, deck, http.StatusOK, cookies).Body.String()) |
| + m, _ := readManifest(t, mustGet(t, a, deck+"?slide=1", http.StatusOK, cookies).Body.String()) |
| faces := manifestFaces(m) |
| if len(faces) != 12 { |
| t.Fatalf("the manifest has %d faces", len(faces)) |
| @@ -206,7 +206,7 @@ func TestSlidesCSSFallbackStacksAreTheEmbeddedFamilies(t *testing.T) { |
| // manifest names, with the immutable Cache-Control the hash buys. |
| func TestTheAppServesTheDeclaredFontFiles(t *testing.T) { |
| a, deck, cookies := sampleViewer(t) |
| - m, _ := readManifest(t, mustGet(t, a, deck, http.StatusOK, cookies).Body.String()) |
| + m, _ := readManifest(t, mustGet(t, a, deck+"?slide=1", http.StatusOK, cookies).Body.String()) |
| faces := manifestFaces(m) |
| if len(faces) != 12 { |
| t.Fatalf("the viewer's font manifest names %d faces, want twelve", len(faces)) |
diff --git a/internal/slidestest/list_test.go b/internal/slidestest/list_test.go| index f54a754..b0502c6 100644 |
| --- a/internal/slidestest/list_test.go |
| +++ b/internal/slidestest/list_test.go |
| @@ -9,11 +9,12 @@ import ( |
| ) |
| // shelfTile is one cover on the shelf: the tile's link and the picture |
| -// inside it. |
| -var shelfTile = regexp.MustCompile(`<a slides-tile slides-lift href="(/d/[a-z0-9]{10})">\s*<span slides-cover[^>]*>(?:<img src="([^"]+)")?`) |
| +// inside it. A deck opens in the editor, as a document does in Docs, so |
| +// the link is /edit and the captured path is the deck's own. |
| +var shelfTile = regexp.MustCompile(`<a slides-tile slides-lift href="(/d/[a-z0-9]{10})/edit">\s*<span slides-cover[^>]*>(?:<img src="([^"]+)")?`) |
| -// rowLink is one row's title link. |
| -var rowLink = regexp.MustCompile(`<span rst-row-main><a href="(/d/[a-z0-9]{10})">([^<]*)</a>`) |
| +// rowLink is one row's title link, to the editor like a cover's. |
| +var rowLink = regexp.MustCompile(`<span rst-row-main><a href="(/d/[a-z0-9]{10})/edit">([^<]*)</a>`) |
| // TestListShowsTheNewestFiveAsCoversAndTheRestAsRows: the newest five |
| // decks are their first slides, newest first; everything older is a row |
| @@ -81,7 +82,7 @@ func TestAnEmptyDeckGetsABlankCoverInItsTheme(t *testing.T) { |
| `{"ops":[{"op":"remove_slide","id":`+quote(slide)+`}]}`, http.StatusOK) |
| page := mustGet(t, a, "/", http.StatusOK, cookies).Body.String() |
| - m := regexp.MustCompile(`<a slides-tile slides-lift href="/d/` + sqid + `">\s*<span slides-cover[^>]*>(<img)?`).FindStringSubmatch(page) |
| + m := regexp.MustCompile(`<a slides-tile slides-lift href="/d/` + sqid + `/edit">\s*<span slides-cover[^>]*>(<img)?`).FindStringSubmatch(page) |
| if m == nil { |
| t.Fatalf("the empty deck is not on the shelf:\n%s", page) |
| } |
| @@ -159,7 +160,7 @@ func TestNewDeckNeedsNoTitleAndOpensTheEditor(t *testing.T) { |
| t.Fatalf("POST /decks with nothing = %d to %q, want 303 to the editor", rec.Code, loc) |
| } |
| mustGet(t, a, loc, http.StatusOK, cookies) |
| - if page := mustGet(t, a, path, http.StatusOK, cookies).Body.String(); !strings.Contains(page, "Untitled deck") { |
| + if page := mustGet(t, a, path+"?slide=1", http.StatusOK, cookies).Body.String(); !strings.Contains(page, "Untitled deck") { |
| t.Errorf("a deck made with no title is not called Untitled deck") |
| } |
diff --git a/internal/slidestest/live_test.go b/internal/slidestest/live_test.go| index 4243603..08acb25 100644 |
| --- a/internal/slidestest/live_test.go |
| +++ b/internal/slidestest/live_test.go |
| @@ -594,7 +594,7 @@ var poisonSlides = map[string]string{ |
| // one down took them all down, because they share openDeck. |
| func stillRenders(t *testing.T, a *testApp, path, name string, cookies []*http.Cookie) { |
| t.Helper() |
| - mustGet(t, a, path, http.StatusOK, cookies) |
| + mustGet(t, a, path+"?slide=1", http.StatusOK, cookies) |
| mustGet(t, a, path+"/edit", http.StatusOK, cookies) |
| if slide, ok := poisonSlides[name]; ok { |
| mustGet(t, a, path+"/slides/"+slide+".html", http.StatusOK, cookies) |
diff --git a/internal/slidestest/present_test.go b/internal/slidestest/present_test.go| index 1ce2eab..c261f6a 100644 |
| --- a/internal/slidestest/present_test.go |
| +++ b/internal/slidestest/present_test.go |
| @@ -89,7 +89,7 @@ func TestPresentCreatesSessionWithCodeAndRemoteUrl(t *testing.T) { |
| cookies := signedIn(t, a, allowedAddress) |
| path := sampleDeck(t, a, cookies) |
| - viewer := mustGet(t, a, path, http.StatusOK, cookies).Body.String() |
| + viewer := mustGet(t, a, path+"?slide=1", http.StatusOK, cookies).Body.String() |
| if !strings.Contains(viewer, `action="`+path+`/present"`) { |
| t.Errorf("the viewer offers no Present form:\n%s", viewer) |
| } |
diff --git a/internal/slidestest/save_status_browser_test.go b/internal/slidestest/save_status_browser_test.go| index ed5d64a..cb17586 100644 |
| --- a/internal/slidestest/save_status_browser_test.go |
| +++ b/internal/slidestest/save_status_browser_test.go |
| @@ -18,7 +18,7 @@ func TestBrowserDroppedBatchStaysFailed(t *testing.T) { |
| rig, mailer := newRig(t) |
| browserSignIn(t, rig, mailer) |
| var deck string |
| - rig.Run(chromedp.Evaluate(`document.querySelector('a[href^="/d/"]').getAttribute('href')`, &deck)) |
| + rig.Run(chromedp.Evaluate(`document.querySelector('a[href^="/d/"]').getAttribute('href').replace(/\/edit$/, '')`, &deck)) |
| const heading = `[slides-stage] [data-block="heading"]` |
| rig.Run( |
| chromedp.Navigate(rig.Origin+deck+"/edit"), |
diff --git a/internal/slidestest/serving_test.go b/internal/slidestest/serving_test.go| index 36236d1..f1c77f9 100644 |
| --- a/internal/slidestest/serving_test.go |
| +++ b/internal/slidestest/serving_test.go |
| @@ -89,7 +89,7 @@ func TestStandaloneServesInlineStyles(t *testing.T) { |
| cookies := signedIn(t, a, allowedAddress) |
| path := sampleDeck(t, a, cookies) |
| h := productionHandler(t, a) |
| - req := httptest.NewRequest(http.MethodGet, path, nil) |
| + req := httptest.NewRequest(http.MethodGet, path+"?slide=1", nil) |
| for _, c := range cookies { |
| req.AddCookie(c) |
| } |
diff --git a/internal/slidestest/share_test.go b/internal/slidestest/share_test.go| index 311780c..a8fc1bd 100644 |
| --- a/internal/slidestest/share_test.go |
| +++ b/internal/slidestest/share_test.go |
| @@ -225,7 +225,7 @@ func TestShareIsTheOwnersAlone(t *testing.T) { |
| }, mine...); rec.Code != http.StatusSeeOther { |
| t.Fatalf("raising the rung: status %d\n%s", rec.Code, rec.Body) |
| } |
| - mustGet(t, a, path, http.StatusOK, theirs) |
| + mustGet(t, a, path+"?slide=1", http.StatusOK, theirs) |
| mustGet(t, a, path+"/share", http.StatusNotFound, theirs) |
| if rec := post(t, a, path+"/share", nil, theirs...); rec.Code != http.StatusNotFound { |
| @@ -243,3 +243,66 @@ func TestShareIsTheOwnersAlone(t *testing.T) { |
| } |
| mustGet(t, a, "/s/"+token, http.StatusOK, nil) |
| } |
| + |
| +// TestShareChoosesWhoCanOpenTheDeck: who can open a deck is chosen on |
| +// its share page, as general access is in Docs — a real POST form of |
| +// option cards, so it works with scripts off. It used to be a field of |
| +// the settings form, which still takes a rung but no longer shows one. |
| +func TestShareChoosesWhoCanOpenTheDeck(t *testing.T) { |
| + a := newSharedApp(t) |
| + mine := signedIn(t, a, allowedAddress) |
| + theirs := signedIn(t, a, otherAddress) |
| + path := createDeck(t, a, mine, "Offsite") |
| + |
| + page := mustGet(t, a, path+"/share", http.StatusOK, mine).Body.String() |
| + form := regexp.MustCompile(`(?s)<form rst-form method="post" action="` + path + `/share/access">(.*?)</form>`).FindStringSubmatch(page) |
| + if form == nil { |
| + t.Fatalf("the share page has no form for who can open the deck:\n%s", page) |
| + } |
| + for _, want := range []string{`<input type="radio" name="rung" value="private" checked>`, `<input type="radio" name="rung" value="team">`, "Only me", "Everyone here", `type="submit"`} { |
| + if !strings.Contains(form[1], want) { |
| + t.Errorf("the access form lacks %s:\n%s", want, form[1]) |
| + } |
| + } |
| + mustGet(t, a, path+"?slide=1", http.StatusNotFound, theirs) |
| + |
| + if rec := post(t, a, path+"/share/access", url.Values{"rung": {"team"}}, mine...); rec.Code != http.StatusSeeOther || rec.Header().Get("Location") != path+"/share" { |
| + t.Fatalf("POST %s/share/access: status %d to %q, want 303 back to the share page", path, rec.Code, rec.Header().Get("Location")) |
| + } |
| + mustGet(t, a, path+"?slide=1", http.StatusOK, theirs) |
| + if page := mustGet(t, a, path+"/share", http.StatusOK, mine).Body.String(); !strings.Contains(page, `value="team" checked`) { |
| + t.Errorf("the share page does not show the new rung chosen:\n%s", page) |
| + } |
| + |
| + // A rung no screen sets, or none at all, is refused on the page |
| + // with the form, and changes nothing. |
| + for _, rung := range []string{"granted", "", "everyone"} { |
| + rec := post(t, a, path+"/share/access", url.Values{"rung": {rung}}, mine...) |
| + if rec.Code != http.StatusUnprocessableEntity || !strings.Contains(rec.Body.String(), "Pick who can open this deck.") { |
| + t.Errorf("POST rung=%q: status %d, want 422 with the error\n%s", rung, rec.Code, rec.Body) |
| + } |
| + } |
| + mustGet(t, a, path+"?slide=1", http.StatusOK, theirs) |
| + |
| + // A member reads the deck and cannot move it. |
| + if rec := post(t, a, path+"/share/access", url.Values{"rung": {"private"}}, theirs...); rec.Code != http.StatusNotFound { |
| + t.Errorf("a member's rung change: status %d, want 404", rec.Code) |
| + } |
| + mustGet(t, a, path+"?slide=1", http.StatusOK, theirs) |
| + |
| + // The settings form no longer carries the rung, and saving it |
| + // leaves the rung where it is. |
| + settings := mustGet(t, a, path+"/settings", http.StatusOK, mine).Body.String() |
| + if strings.Contains(settings, `name="rung"`) || !strings.Contains(settings, `href="`+path+`/share"`) { |
| + t.Errorf("the settings form still offers the rung, or does not say where it went:\n%s", settings) |
| + } |
| + if rec := post(t, a, path+"/settings", url.Values{"title": {"Offsite 2027"}, "theme": {"ink"}}, mine...); rec.Code != http.StatusSeeOther { |
| + t.Fatalf("POST %s/settings without a rung: status %d\n%s", path, rec.Code, rec.Body) |
| + } |
| + mustGet(t, a, path+"?slide=1", http.StatusOK, theirs) |
| + |
| + if rec := post(t, a, path+"/share/access", url.Values{"rung": {"private"}}, mine...); rec.Code != http.StatusSeeOther { |
| + t.Fatalf("lowering the rung: status %d", rec.Code) |
| + } |
| + mustGet(t, a, path+"?slide=1", http.StatusNotFound, theirs) |
| +} |
diff --git a/internal/slidestest/viewer_test.go b/internal/slidestest/viewer_test.go| index dacc0e8..55762d4 100644 |
| --- a/internal/slidestest/viewer_test.go |
| +++ b/internal/slidestest/viewer_test.go |
| @@ -83,7 +83,7 @@ func TestViewerPagesThroughSlides(t *testing.T) { |
| } |
| // The ends are ends: no link off either edge of the deck. |
| - first := mustGet(t, a, path, http.StatusOK, cookies).Body.String() |
| + first := mustGet(t, a, path+"?vp=desktop", http.StatusOK, cookies).Body.String() |
| if strings.Contains(first, `?slide=0"`) { |
| t.Errorf("the first slide offers a previous link:\n%s", first) |
| } |
| @@ -152,39 +152,97 @@ func TestViewerShowsNotesToItsPeople(t *testing.T) { |
| } |
| } |
| -// TestViewerOwnerButtons: settings and share are the owner's, and a |
| -// team member reading the same deck is offered neither. |
| +// TestViewerOwnerButtons: the viewer is shaped as Docs shapes a |
| +// document. Share… is the owner's, and it is in the bar's actions, not |
| +// a pill on the page; the settings form is nobody's link (the editor's |
| +// inspector holds the deck's settings); and the page's own row is what a |
| +// reader reaches for — Edit, Present — with the rest in one overflow. |
| +// A team member reading the same deck is offered no Share…. |
| func TestViewerOwnerButtons(t *testing.T) { |
| a := newSharedApp(t) |
| mine := signedIn(t, a, allowedAddress) |
| theirs := signedIn(t, a, otherAddress) |
| path := createDeck(t, a, mine, "All hands") |
| - if rec := post(t, a, path+"/settings", url.Values{ |
| - "title": {"All hands"}, "theme": {"ink"}, "rung": {"team"}, |
| - }, mine...); rec.Code != http.StatusSeeOther { |
| + if rec := post(t, a, path+"/share/access", url.Values{"rung": {"team"}}, mine...); rec.Code != http.StatusSeeOther { |
| t.Fatalf("raising the rung: status %d\n%s", rec.Code, rec.Body) |
| } |
| - owner := mustGet(t, a, path, http.StatusOK, mine).Body.String() |
| - if !strings.Contains(owner, path+"/settings") { |
| - t.Errorf("the owner's viewer offers no settings:\n%s", owner) |
| + owner := mustGet(t, a, path+"?slide=1", http.StatusOK, mine).Body.String() |
| + bar := owner[strings.Index(owner, "<header estilo-bar"):strings.Index(owner, "</header>")] |
| + if !strings.Contains(bar, `<span estilo-bar-context dir="auto" title="All hands">All hands</span>`) { |
| + t.Errorf("the deck's title is not the bar's context:\n%s", bar) |
| } |
| - if !strings.Contains(owner, path+"/share") { |
| - t.Errorf("the owner's viewer offers no share page:\n%s", owner) |
| + if !strings.Contains(bar, `<a rst-btn href="`+path+`/share">Share…</a>`) { |
| + t.Errorf("the owner's bar offers no Share…:\n%s", bar) |
| + } |
| + if strings.Contains(owner, path+"/settings") { |
| + t.Errorf("the viewer links the settings form:\n%s", owner) |
| + } |
| + main := owner[strings.Index(owner, "<main"):] |
| + if strings.Contains(main, path+"/share") { |
| + t.Errorf("the page repeats Share… outside the bar:\n%s", main) |
| + } |
| + tools := main[strings.Index(main, "<nav slides-tools"):strings.Index(main, "</nav>")] |
| + for _, want := range []string{`href="` + path + `/edit"`, `action="` + path + `/present"`, "<details slides-more", `href="` + path + `/notes"`, `href="` + path + `/export"`} { |
| + if !strings.Contains(tools, want) { |
| + t.Errorf("the viewer's row lacks %s:\n%s", want, tools) |
| + } |
| + } |
| + if more := tools[strings.Index(tools, "<details slides-more"):]; !strings.Contains(more, `href="`+path+`/notes"`) || !strings.Contains(more, `href="`+path+`/export"`) { |
| + t.Errorf("All notes and Export are not in the overflow:\n%s", tools) |
| } |
| - member := mustGet(t, a, path, http.StatusOK, theirs).Body.String() |
| + member := mustGet(t, a, path+"?slide=1", http.StatusOK, theirs).Body.String() |
| if strings.Contains(member, path+"/settings") { |
| t.Errorf("a member's viewer offers the owner's settings:\n%s", member) |
| } |
| if strings.Contains(member, path+"/share") { |
| t.Errorf("a member's viewer offers the owner's share page:\n%s", member) |
| } |
| + if !strings.Contains(member, `href="`+path+`/edit"`) { |
| + t.Errorf("a member's viewer offers no Edit:\n%s", member) |
| + } |
| // And the screens themselves are the owner's, not just their links. |
| mustGet(t, a, path+"/share", http.StatusNotFound, theirs) |
| } |
| +// TestADeckOpensInTheEditor: a deck's own address opens it to be worked |
| +// on, as a document's does in Docs — for the owner and a member alike, |
| +// since both may edit — and a stranger gets the same 404 as ever, never |
| +// a redirect that says the deck is real. The viewer is the same address |
| +// with a query, and the editor's <noscript> and File menu reach it. |
| +func TestADeckOpensInTheEditor(t *testing.T) { |
| + a := newSharedApp(t) |
| + mine := signedIn(t, a, allowedAddress) |
| + theirs := signedIn(t, a, otherAddress) |
| + path := createDeck(t, a, mine, "Roadmap") |
| + |
| + if rec := mustGet(t, a, path, http.StatusSeeOther, mine); rec.Header().Get("Location") != path+"/edit" { |
| + t.Errorf("GET %s = %s, want a 303 to %s/edit", path, rec.Header().Get("Location"), path) |
| + } |
| + mustGet(t, a, path, http.StatusNotFound, theirs) |
| + if rec := post(t, a, path+"/share/access", url.Values{"rung": {"team"}}, mine...); rec.Code != http.StatusSeeOther { |
| + t.Fatalf("raising the rung: status %d", rec.Code) |
| + } |
| + if rec := mustGet(t, a, path, http.StatusSeeOther, theirs); rec.Header().Get("Location") != path+"/edit" { |
| + t.Errorf("a member's GET %s = %s, want the editor", path, rec.Header().Get("Location")) |
| + } |
| + for _, q := range []string{"?slide=1", "?vp=phone", "?present=1"} { |
| + mustGet(t, a, path+q, http.StatusOK, mine) |
| + } |
| + |
| + // The list opens the editor too. |
| + list := mustGet(t, a, "/", http.StatusOK, mine).Body.String() |
| + if !strings.Contains(list, `href="`+path+`/edit"`) || strings.Contains(list, `href="`+path+`"`) { |
| + t.Errorf("the list does not open the deck in the editor:\n%s", list) |
| + } |
| + editor := mustGet(t, a, path+"/edit", http.StatusOK, mine).Body.String() |
| + if !strings.Contains(editor, `href="`+path+`?slide=1"`) { |
| + t.Errorf("the editor offers no way to the viewer:\n%s", editor) |
| + } |
| +} |
| + |
| // TestPresentSurfaceIsBare: ?present=1 is the scriptless presenting |
| // page — one slide, two links, and none of the chrome. Task 6 replaces |
| // it with the live fullscreen surface; this is the floor it has to keep |