oficina / docs Public

Clone
git clone https://amadan.net/oficina/docs

Plain git — no account needed to clone.

Download

Download this file

1
2{{/* The share screen. Scriptless throughout, per spec §6.2, which lists
3 sharing among the working form posts: two plain <form>s, no token
4 field (csrf.Protect reads Sec-Fetch-Site and falls back to Origin),
5 and a 303 back here afterwards so a reload never re-posts.
6
7 Bare attributes rather than the class vocabulary, per
8 TestOurTemplatesUseTheAttributeGrammar — which greps raw bytes, so
9 even naming that spelling in a comment fails it. This comment used
10 to, and did.
11
12 Each row's revoke is its own <form>, not a link: revoking is a
13 mutation and a GET that changes state is one a prefetcher can fire.
14 That is also why the address rides a hidden field rather than the
15 URL — the row already names it in text, and a URL is copied,
16 logged and pasted in a way a form body is not. */}}
17{{define "content"}}<style>
18 /* The share page on the design system's own vocabulary: fields, option
19 cards, list rows and buttons. It was the audit's worst Docs finding —
20 browser-default buttons, a bare fieldset, a bulleted list of grants,
21 and a one-time link printed as <code> with no way to copy it. */
22 /* The page is Fiesta's stack (rst-stack): it spaces the blocks, the
23 header's, the sections' and the actions' by one table, and nothing
24 here adds margins of its own. */
25 [docs-share] {
26 max-inline-size: 44rem;
27 }
28 /* The callout is the wrapper's only child: the stack spaces the
29 wrapper, so the callout's own margin would add to it. */
30 [docs-share-once] > [rst-callout] {
31 margin-block: 0;
32 }
33 [docs-share-list] [rst-row] {
34 gap: var(--rst-sp-3);
35 }
36 [docs-share-who] {
37 overflow-wrap: anywhere;
38 }
39 [docs-share-role] {
40 flex: none;
41 font-size: var(--rst-fs-sm);
42 }
43 [docs-share-list] form {
44 flex: none;
45 margin: 0;
46 }
47 [docs-share-public] {
48 padding-block-start: var(--rst-sp-5);
49 border-block-start: 1px solid var(--rst-line);
50 }
51 [docs-share-url] {
52 display: flex;
53 flex-wrap: wrap;
54 align-items: center;
55 gap: var(--rst-sp-2);
56 }
57 [docs-share-url-input] {
58 flex: 1 1 16rem;
59 min-inline-size: 0;
60 font-family: "SFMono-Regular", Consolas, monospace;
61 font-size: var(--rst-fs-sm);
62 }
63 /* Read-only, but a tap still focuses it (to select the link), and iOS
64 zooms into anything under 16px: tokens.css's touch rule, restated at
65 this selector's weight (TestNoZoomOnTap). */
66 @media (pointer: coarse) {
67 [docs-share-url-input] {
68 font-size: max(1rem, 1em);
69 }
70 }
71 /* The Copy button ships hidden until share-link.mjs mounts it, and
72 [rst-btn]'s display: inline-flex beats the user agent's [hidden], so
73 without this rule it showed with no script and did nothing. */
74 [docs-share-copy][hidden] {
75 display: none;
76 }
77 [docs-share-copy-status] {
78 margin: 0;
79 color: var(--rst-text-muted);
80 font-size: var(--rst-fs-sm);
81 }
82 [docs-share-actions] form {
83 margin: 0;
84 }
85</style>
86<article rst-stack docs-share>
87 <header rst-page-header>
88 <div rst-page-header-titles>
89 <h1>{{.Heading}}</h1>
90 <p rst-muted>{{.DocTitle}}</p>
91 </div>
92 <a rst-btn="ghost" href="/d/{{.Sqid}}">{{.BackLabel}}</a>
93 </header>
94
95 {{if .Error}}{{template "callout" (dict "Body" .Error "Tone" "negative" "Alert" true)}}{{end}}
96
97 {{/* Who reaches it today. An empty list says so in words rather than
98 rendering an empty table, because a table with no rows reads as a
99 thing that failed to load.
100
101 Each row's revoke is its own <form>, not a link: revoking is a
102 mutation and a GET that changes state is one a prefetcher can fire.
103 That is also why the address rides a hidden field rather than the
104 URL. */}}
105 {{if .Grants}}
106 <div rst-list docs-share-list>
107 {{range .Grants}}
108 <div rst-row>
109 <span rst-row-main><span docs-share-who>{{.Address}}</span></span>
110 <span rst-muted docs-share-role>{{.Role}}</span>
111 <form method="post" action="/d/{{$.Sqid}}/share/revoke">
112 <input type="hidden" name="address" value="{{.Address}}">
113 <button rst-btn="ghost" type="submit">{{$.RevokeButton}}</button>
114 </form>
115 </div>
116 {{end}}
117 </div>
118 {{else}}
119 <p rst-muted>{{.EmptyBody}}</p>
120 {{end}}
121
122 {{/* Adding somebody. The role is a pair of option cards rather than a
123 select so both are visible without opening anything. Reader is
124 checked by default: the safer of the two is the one a person gets
125 by not choosing. Scriptless, per spec §6.2: a plain POST, and a 303
126 back here afterwards so a reload never re-posts. */}}
127 <form rst-form rst-section method="post" action="/d/{{.Sqid}}/share" docs-share-form>
128 {{template "field" (dict "ID" "share-address" "Name" "address" "Type" "email" "Label" .AddressLabel "Autocomplete" "email" "Required" true)}}
129 {{template "choice-field" (dict "Legend" .RoleLabel "Name" "role" "Options" .RoleChoices)}}
130 <div rst-form-foot><button rst-btn="primary" type="submit">{{.ShareButton}}</button></div>
131 </form>
132
133 {{/* The team rung (spec §8.2.1; Paul, 2026-11-01: "New docs Team, old
134 private"). The body names the state in words, so it never rests on
135 the button's label alone, and says the team reads and does not edit.
136 One <form> whichever way the switch points, the direction in a hidden
137 field, like the public link below: a page left open in a tab cannot
138 flip it the wrong way from a stale label. Scriptless; a 303 back. */}}
139 <section rst-stack rst-section docs-share-public docs-share-team>
140 <h2>{{.TeamHeading}}</h2>
141 <p rst-muted docs-share-team-state>{{.TeamBody}}</p>
142 <div rst-actions docs-share-actions>
143 <form method="post" action="/d/{{.Sqid}}/share/team">
144 <input type="hidden" name="visibility" value="{{.TeamDestination}}">
145 {{if .Team}}<button rst-btn type="submit">{{.TeamButton}}</button>{{else}}<button rst-btn="primary" type="submit">{{.TeamButton}}</button>{{end}}
146 </form>
147 </div>
148 </section>
149
150 {{/* The third rung: a read-only link anyone can follow, signed in or
151 not. One <form> whichever way the switch currently points, with the
152 direction in a hidden field — so a page left open in a tab cannot
153 turn publishing back on from a button that still says "off".
154
155 The link appears only in the render that follows the publish that
156 minted it — the database holds a SHA-256 and cannot produce a URL
157 (suite ruling 16). It is a read-only field rather than a link: it
158 is meant to be copied into a message, not followed from here. The
159 Copy button is fixtures/share-link.mjs's, hidden until that script
160 runs; without it the field selects on focus for a manual copy. */}}
161 <section rst-stack rst-section docs-share-public>
162 <h2>{{.PublicHeading}}</h2>
163 <p rst-muted>{{.PublicBody}}</p>
164 {{if .Published}}
165 {{if .PublicURL}}
166 <div docs-share-once role="status">{{template "callout" (dict "Body" .OnceWarning "Tone" "warning")}}</div>
167 <div docs-share-url>
168 <input rst-input docs-share-url-input type="text" readonly value="{{.PublicURL}}" aria-label="{{.URLLabel}}">
169 <button rst-btn="primary" type="button" docs-share-copy data-copied="{{.CopiedLabel}}" hidden>{{.CopyButton}}</button>
170 </div>
171 <p docs-share-copy-status role="status"></p>
172 {{else}}
173 <p rst-muted docs-share-state>{{.PublishedBody}}</p>
174 {{end}}
175 <p rst-muted>{{.CopyHint}}</p>
176 <div rst-actions docs-share-actions>
177 <form method="post" action="/d/{{.Sqid}}/share/link">
178 <input type="hidden" name="on" value="1">
179 <button rst-btn type="submit">{{.ReplaceButton}}</button>
180 </form>
181 <form method="post" action="/d/{{.Sqid}}/share/link">
182 <input type="hidden" name="on" value="0">
183 <button rst-btn="ghost" type="submit">{{.UnpublishBtn}}</button>
184 </form>
185 </div>
186 {{else}}
187 <div rst-actions docs-share-actions>
188 <form method="post" action="/d/{{.Sqid}}/share/link">
189 <input type="hidden" name="on" value="1">
190 <button rst-btn="primary" type="submit">{{.PublishButton}}</button>
191 </form>
192 </div>
193 {{end}}
194 </section>
195</article>
196<script type="module" defer src="{{.ShareScript}}"></script>
197{{end}}
198
199{{/* docs-share-panel: the editor's Share popover (share_panel.go). The
200 page's state as a panel, every control a real form posting to the
201 share routes with panel=1, so their 303 comes back here; the script
202 (brand/share-pop.js) sends each with fetch and draws the answer. No
203 <style>: the panel's look is brand/share-pop.css, on the editor page.
204
205 The switches are rastrillo's: a checkbox in a label with its track,
206 so they click, drag (rastrillo.js) and take Space. Each sits in the
207 form that moves its rung, the direction in a hidden field as on the
208 page, and the script submits that form when it changes. */}}
209{{define "docs-share-panel"}}<div docs-share-panel data-failed="{{.Panel.Failed}}">
210 <header docs-share-head>
211 <h2 id="docs-share-heading" dir="auto">{{.Panel.Heading}}</h2>
212 <button type="button" docs-share-close aria-label="{{.Panel.Close}}"><svg viewBox="0 0 20 20" width="18" height="18" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"><path d="M5 5l10 10M15 5 5 15"/></svg></button>
213 </header>
214 {{if .Error}}<p docs-share-error role="alert">{{.Error}}</p>{{end}}
215 <form docs-share-invite method="post" data-busy="false" action="/d/{{.Sqid}}/share">
216 <input type="hidden" name="panel" value="1">
217 <input type="email" name="address" required autocomplete="email" placeholder="{{.Panel.InvitePlaceholder}}" aria-label="{{.AddressLabel}}">
218 <select name="role" aria-label="{{.Panel.Access}}"><option value="reader">{{.Panel.CanRead}}</option><option value="writer">{{.Panel.CanEdit}}</option></select>
219 <button type="submit" docs-share-submit>{{.Panel.Invite}}</button>
220 </form>
221 <h3>{{.Panel.People}}</h3>
222 <ul docs-share-people>
223 <li><span docs-share-avatar data-me aria-hidden="true">{{.MeInitial}}</span><span docs-share-name dir="auto">{{.Me}} <em>{{.Panel.You}}</em></span><span docs-share-access>{{.Panel.Owner}}</span></li>
224 {{- range .PanelGrants}}
225 <li><span docs-share-avatar aria-hidden="true">{{.Initial}}</span><span docs-share-name dir="auto">{{.Address}}</span><span docs-share-access>{{.Access}}</span>
226 <form method="post" action="/d/{{$.Sqid}}/share/revoke" data-busy="false"><input type="hidden" name="panel" value="1"><input type="hidden" name="address" value="{{.Address}}"><button type="submit" docs-share-remove aria-label="{{.Remove}}" title="{{.Remove}}"><svg viewBox="0 0 20 20" width="16" height="16" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"><path d="M6.5 6.5l7 7M13.5 6.5l-7 7"/></svg></button></form></li>
227 {{- end}}
228 </ul>
229 <h3>{{.Panel.General}}</h3>
230 <div docs-share-general>
231 <form docs-share-rung method="post" data-busy="false" action="/d/{{.Sqid}}/share/team">
232 <input type="hidden" name="panel" value="1">
233 <input type="hidden" name="visibility" value="{{.TeamDestination}}">
234 <span docs-share-icon aria-hidden="true"><svg viewBox="0 0 20 20" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><circle cx="7.5" cy="7" r="2.6"/><path d="M2.8 16c.6-2.6 2.4-4 4.7-4s4.1 1.4 4.7 4"/><circle cx="14" cy="7.6" r="2"/><path d="M13.6 11.6c1.9 0 3.2 1.1 3.7 3.4"/></svg></span>
235 <span docs-share-rung-text><strong>{{.TeamHeading}}</strong><small>{{if .Team}}{{.Panel.TeamOn}}{{else}}{{.Panel.TeamOff}}{{end}}</small></span>
236 <label rst-switch docs-share-switch><input type="checkbox" name="on"{{if .Team}} checked{{end}}><span rst-switch-track aria-hidden="true"></span><span docs-sr>{{.Panel.TeamSwitch}}</span></label>
237 </form>
238 <form docs-share-rung method="post" data-busy="false" action="/d/{{.Sqid}}/share/link">
239 <input type="hidden" name="panel" value="1">
240 <input type="hidden" name="on" value="{{if .Published}}0{{else}}1{{end}}">
241 <span docs-share-icon aria-hidden="true"><svg viewBox="0 0 20 20" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M8.6 11.4a3 3 0 0 0 4.3 0l2.4-2.4a3 3 0 0 0-4.3-4.3l-.9.9"/><path d="M11.4 8.6a3 3 0 0 0-4.3 0L4.7 11a3 3 0 0 0 4.3 4.3l.9-.9"/></svg></span>
242 <span docs-share-rung-text><strong>{{.Panel.LinkHeading}}</strong><small>{{if .Published}}{{.Panel.LinkOn}}{{else}}{{.Panel.LinkOff}}{{end}}</small></span>
243 <label rst-switch docs-share-switch><input type="checkbox" name="state"{{if .Published}} checked{{end}}><span rst-switch-track aria-hidden="true"></span><span docs-sr>{{.Panel.LinkSwitch}}</span></label>
244 </form>
245 {{if .PublicURL}}
246 <div docs-share-link><input readonly value="{{.PublicURL}}" aria-label="{{.URLLabel}}"><button type="button" docs-share-copy data-copied="{{.CopiedLabel}}">{{.CopyButton}}</button></div>
247 <p docs-share-once role="status">{{.Panel.Once}}</p>
248 {{else if .Published}}
249 <form docs-share-once method="post" data-busy="false" action="/d/{{.Sqid}}/share/link"><input type="hidden" name="panel" value="1"><input type="hidden" name="on" value="1">{{.Panel.Shown}} <button type="submit" docs-share-replace>{{.Panel.NewLink}}</button></form>
250 {{end}}
251 </div>
252</div>{{end}}
253