| 1 | package docs |
| 2 | |
| 3 | import ( |
| 4 | "amadan.net/oficina/estilo.git/googleimport" |
| 5 | "amadan.net/oficina/estilo.git/sky" |
| 6 | "bytes" |
| 7 | "embed" |
| 8 | "fmt" |
| 9 | "html" |
| 10 | "html/template" |
| 11 | "io/fs" |
| 12 | "net/http" |
| 13 | "strings" |
| 14 | "testing/fstest" |
| 15 | |
| 16 | "amadan.net/oficina/estilo.git/base" |
| 17 | "amadan.net/oficina/estilo.git/busy" |
| 18 | "amadan.net/oficina/estilo.git/chrome" |
| 19 | "amadan.net/oficina/estilo.git/colophon" |
| 20 | estilomenu "amadan.net/oficina/estilo.git/menu" |
| 21 | "amadan.net/oficina/estilo.git/savestatus" |
| 22 | "amadan.net/oficina/estilo.git/theme" |
| 23 | "amadan.net/rastrillo/rastrillo" |
| 24 | "amadan.net/rastrillo/rastrillo/ui" |
| 25 | |
| 26 | // The pack for Locales' one language: from rastrillo v0.29.0 a |
| 27 | // language with no pack linked is refused at start. |
| 28 | _ "amadan.net/rastrillo/rastrillo/locales/en" |
| 29 | ) |
| 30 | |
| 31 | // There is no rastrillo shell any more. The topbar shell's bar hard-coded |
| 32 | // an "Account" summary and a tail that wrapped (45px on the public page, |
| 33 | // 51px elsewhere, 96px at 390px), and estilo may not restyle rastrillo's |
| 34 | // markup, so every page now renders views/layout.html with estilo's own |
| 35 | // bar (chrome.go builds its data). That is the change the whole suite |
| 36 | // makes in round 2; Docs is the first to make it. |
| 37 | |
| 38 | // Catalog is CARLOS Docs' own English strings. Every user-visible |
| 39 | // string this app writes is a key here (never a literal in a |
| 40 | // template or a handler), resolved through rastrillo.T at render |
| 41 | // time. cmd/docs/main.go wires it in as rastrillo.Options.BaseCatalog. |
| 42 | var Catalog = rastrillo.Catalog{ |
| 43 | // docs.home.* — connecting a Docs account to the suite account. The |
| 44 | // hub is never named ("Home" leaves user copy, spec §10 and §13 Q3): |
| 45 | // the account is "your Oficina account", and the verb stays Connect. |
| 46 | // The confirm step asks its own question so it cannot read as the |
| 47 | // start page reloaded (Paul, 2026-10-24); the assertion's subject is |
| 48 | // opaque, so only the Docs address can be named. The unknown state |
| 49 | // says what signing in now does: it resumes the link. |
| 50 | "docs.home.start_title": "Connect your Oficina account", |
| 51 | "docs.home.start_body": "Use your Oficina account to sign in to this Docs account. Your documents and sharing settings stay as they are.", |
| 52 | "docs.home.start_action": "Connect", |
| 53 | "docs.home.cancel_action": "Back to Docs", |
| 54 | "docs.home.confirm_title": "Connect these two accounts?", |
| 55 | "docs.home.confirm_body": "Your Oficina account is confirmed. Connect it to the Docs account below, and you can sign in to Docs with Oficina from now on.", |
| 56 | "docs.home.confirm_action": "Connect accounts", |
| 57 | "docs.home.unknown_title": "Oficina account not connected", |
| 58 | "docs.home.unknown_body": "Sign in to your Docs account once to connect it to your Oficina account.", |
| 59 | "docs.home.local_action": "Sign in to Docs", |
| 60 | "docs.home.failed_title": "Could not connect accounts", |
| 61 | "docs.home.failed_body": "Return to Docs and start again.", |
| 62 | "docs.home.success_title": "Accounts connected", |
| 63 | "docs.home.success_body": "You can now use your Oficina account to sign in to this Docs account.", |
| 64 | "docs.home.documents_action": "Back to documents", |
| 65 | "docs.home.menu_action": "Connect your Oficina account", |
| 66 | // The member choice (Home spec 2026-11-14-oficina-id-native.md §8): |
| 67 | // a roster member arriving with no account here yet. |
| 68 | "docs.home.choose_title": "Welcome to the team", |
| 69 | "docs.home.choose_body": "Do you already have an account here that signs in with email? Connect it, and your Oficina ID will open it from now on. If you’re new here, continue with Oficina ID.", |
| 70 | "docs.home.choose_connect_action": "Connect my existing account", |
| 71 | "docs.home.choose_new_action": "I’m new here — continue with Oficina ID", |
| 72 | |
| 73 | // docs.list.* — GET /, spec §6.4. Title is the screen's noun, per |
| 74 | // page-header's own contract ("Posts", not "Home"). The four group |
| 75 | // labels are recency buckets (handlers.go's recencyBucket); a |
| 76 | // document's own title and its row's timestamp are data, not |
| 77 | // authored copy, so neither is a catalog key. |
| 78 | "docs.share.title": "Share", |
| 79 | // docs.share.action is the bar's action on a document (spec §7.3: the |
| 80 | // ellipsis, because it opens a form before anything happens). |
| 81 | "docs.share.action": "Share…", |
| 82 | "docs.share.heading": "Who can open this", |
| 83 | "docs.share.address": "Email address", |
| 84 | "docs.share.role": "They can", |
| 85 | "docs.share.role.reader": "Read it", |
| 86 | "docs.share.role.writer": "Read and edit it", |
| 87 | "docs.share.submit": "Share", |
| 88 | "docs.share.revoke": "Stop sharing", |
| 89 | "docs.share.back": "Back to the document", |
| 90 | "docs.share.empty": "Only you can open this document.", |
| 91 | "docs.share.error.address": "Type the email address of the person you want to share with.", |
| 92 | // docs.share.empty.team replaces docs.share.empty on a team document, |
| 93 | // where "Only you can open this document" would be false. |
| 94 | "docs.share.empty.team": "Nobody has been added by name.", |
| 95 | // docs.share.team.* is the team rung (spec §8.2.1, Paul 2026-11-01: |
| 96 | // "New docs Team, old private"). The body says which side the switch is |
| 97 | // on in words, so the state never rests on a button's label alone, and |
| 98 | // says that the team reads and does not edit. |
| 99 | "docs.share.team.heading": "Your team", |
| 100 | "docs.share.team.body.team": "Everyone on your team can read this document. Only you and people you give edit access can change it.", |
| 101 | "docs.share.team.body.private": "Only you and the people you add above can open this document.", |
| 102 | "docs.share.team.body.private_published": "Only you, the people you add above and anyone with the published link can open this document.", |
| 103 | "docs.share.team.make_private": "Make private", |
| 104 | "docs.share.team.make_team": "Share with your team", |
| 105 | |
| 106 | // docs.share.public.* is the third rung — a read-only link anyone |
| 107 | // can follow, signed in or not (suite doctrine ruling 15). |
| 108 | // |
| 109 | // The body says "anyone with the link", not "the public": the |
| 110 | // distinction is the whole security model of a capability, and an |
| 111 | // owner who reads it as "listed somewhere" or as "safe because it is |
| 112 | // unguessable" is being told the wrong thing either way. It also |
| 113 | // says read, twice over with the heading, because the one question |
| 114 | // an owner has about this switch is whether a stranger can change |
| 115 | // their document. |
| 116 | // |
| 117 | // The off label is "Stop publishing" rather than "Turn off": what it |
| 118 | // does is kill the URL, and a person who has handed that URL to |
| 119 | // somebody deserves a verb that says so. It pairs with |
| 120 | // docs.share.revoke's "Stop sharing" by design — one vocabulary for |
| 121 | // taking access away, whichever rung it was granted on. |
| 122 | "docs.share.public.heading": "Anyone with a link", |
| 123 | "docs.share.public.body": "Publish a link that anyone can open to read this document. They will not be able to change it, and they will not need to sign in.", |
| 124 | "docs.share.public.on": "Publish a link", |
| 125 | "docs.share.public.off": "Stop publishing", |
| 126 | "docs.share.public.hint": "Publishing again makes a new link, and the old one stops working.", |
| 127 | |
| 128 | // docs.share.public.once is the one-time notice, and the copy has to |
| 129 | // carry a real instruction because the app genuinely cannot repeat |
| 130 | // itself: it stores a hash of the token, not the token (suite ruling |
| 131 | // 16). "You will not see it again" is a fact here, not a scare. |
| 132 | // |
| 133 | // docs.share.public.published is what the section says on every later |
| 134 | // visit — published, without the URL, which is the shape of the whole |
| 135 | // ruling in one line of copy. |
| 136 | "docs.share.public.once": "Copy this link now. This is the only time it will be shown.", |
| 137 | "docs.share.public.published": "This document is published. The link was shown once when it was created and cannot be shown again — replace it if you no longer have it.", |
| 138 | "docs.share.public.replace": "Replace the link", |
| 139 | // The one-time link's field and its Copy button (share.html). "Link |
| 140 | // copied." is the suite's wording for the same confirmation (Calls). |
| 141 | "docs.share.public.url": "Published link", |
| 142 | "docs.share.public.copy": "Copy link", |
| 143 | "docs.share.public.copied": "Link copied.", |
| 144 | |
| 145 | // docs.share.panel.* — the editor's Share popover (share_panel.go), |
| 146 | // the share page's state in a panel under the button. Shorter than |
| 147 | // the page's words, which stay for the page itself (no script). |
| 148 | "docs.share.panel.heading": "Share “{title}”", |
| 149 | "docs.share.panel.close": "Close", |
| 150 | "docs.share.panel.failed": "That did not work. Check your connection and try again.", |
| 151 | "docs.share.panel.invite_placeholder": "Add people by email", |
| 152 | "docs.share.panel.invite": "Invite", |
| 153 | "docs.share.panel.access": "Access", |
| 154 | "docs.share.panel.can_read": "Can read", |
| 155 | "docs.share.panel.can_edit": "Can edit", |
| 156 | "docs.share.panel.people": "People with access", |
| 157 | "docs.share.panel.general": "General access", |
| 158 | "docs.share.panel.owner": "Owner", |
| 159 | "docs.share.panel.you": "(you)", |
| 160 | "docs.share.panel.remove": "Stop sharing with {address}", |
| 161 | "docs.share.panel.team_on": "Everyone on your team can read it.", |
| 162 | "docs.share.panel.team_off": "Only you and the people above.", |
| 163 | "docs.share.panel.team_switch": "Share with your team", |
| 164 | "docs.share.panel.link_heading": "Anyone with the link", |
| 165 | "docs.share.panel.link_on": "Published. Anyone with the link can read it, without signing in.", |
| 166 | "docs.share.panel.link_off": "Off. Turn on to make a read-only link.", |
| 167 | "docs.share.panel.link_switch": "Anyone with the link can read it", |
| 168 | "docs.share.panel.once": "Copy it now: the link is shown only this once.", |
| 169 | "docs.share.panel.shown": "The link was shown when it was made.", |
| 170 | "docs.share.panel.new_link": "Make a new link", |
| 171 | |
| 172 | // docs.public.readonly is the standing notice on the published page |
| 173 | // itself (views/public.html). It is there because a person arriving |
| 174 | // from a pasted link has no other way to know they are looking at a |
| 175 | // copy they cannot edit — the page has no editor to try, so without |
| 176 | // this the absence reads as a page that failed to load its own |
| 177 | // controls. |
| 178 | "docs.public.readonly": "You are reading a shared copy of this document.", |
| 179 | |
| 180 | "docs.list.title": "Documents", |
| 181 | "docs.list.group.today": "Today", |
| 182 | "docs.list.group.yesterday": "Yesterday", |
| 183 | "docs.list.group.week": "This week", |
| 184 | "docs.list.group.earlier": "Earlier", |
| 185 | |
| 186 | // docs.list.empty.* — the empty state (Paul's ruling: "An empty |
| 187 | // list is a designed screen, not a blank page"). |
| 188 | "docs.list.empty.title": "No documents yet", |
| 189 | "docs.list.empty.body": "Documents you create will show up here, newest first.", |
| 190 | |
| 191 | // docs.list.create.* — the create control in list.html's page |
| 192 | // header, present whether or not Groups is empty (fix round 1: |
| 193 | // the plan had scoped a create *control* out of every task, so the |
| 194 | // screen this plan exists for could not be driven from a browser |
| 195 | // at all). label is the button's text: it creates an "Untitled |
| 196 | // document" (docs.document.untitled), titled in the document itself. |
| 197 | "docs.list.create.label": "New document", |
| 198 | |
| 199 | // docs.list.search.* — finding a document by its title (spec |
| 200 | // §15.2). The field is a GET form, so a search is a link and works |
| 201 | // with no JavaScript; fixtures/jump-to.mjs adds the keyboard |
| 202 | // shortcut on top of it and takes its own copy from here rather |
| 203 | // than carrying any. |
| 204 | // |
| 205 | // "Search documents" rather than "Search": the field sits beside a |
| 206 | // create field on the same header, and a bare "Search" next to a |
| 207 | // bare "Title" says nothing about which list is being searched. |
| 208 | // The empty state names the query back, because "nothing found" and |
| 209 | // "nothing found FOR THIS" are different amounts of help when you |
| 210 | // have mistyped. |
| 211 | "docs.list.search.label": "Search documents", |
| 212 | "docs.list.search.placeholder": "Search by title", |
| 213 | "docs.list.search.none.title": "No documents match", |
| 214 | "docs.list.search.none.body": "Nothing here has that in its title. Check the spelling, or try a shorter word.", |
| 215 | "docs.list.search.clear": "Clear search", |
| 216 | |
| 217 | // docs.jumpto.* — the keyboard jump-to palette |
| 218 | // (fixtures/jump-to.mjs), opened with Control-K or Command-K from |
| 219 | // the list or from a document. Every string is rendered into the |
| 220 | // page server-side, the same rule the editor's save-status copy |
| 221 | // and the formatting bar follow: the bundle carries no copy of its |
| 222 | // own to keep in sync with this file by hand. |
| 223 | "docs.jumpto.label": "Jump to a document", |
| 224 | "docs.jumpto.placeholder": "Search documents", |
| 225 | "docs.jumpto.hint": "Type to search. Up and down to choose, Enter to open, Escape to close.", |
| 226 | "docs.jumpto.empty": "No documents match", |
| 227 | "docs.team.partial": "We couldn’t check your team access. Only documents shared with you are shown.", |
| 228 | "docs.jumpto.failed": "Search is unavailable right now.", |
| 229 | "docs.jumpto.close": "Close", |
| 230 | |
| 231 | // docs.app.name is the brand in the bar and the last part of every |
| 232 | // <title> (spec §10): the app's name, never "Documents", which is the |
| 233 | // list's heading. |
| 234 | "docs.app.name": "Docs", |
| 235 | |
| 236 | // docs.chrome.* is the estilo bar and account menu (chrome.go). |
| 237 | "docs.chrome.skip": "Skip to content", |
| 238 | "docs.chrome.menu": "Menu", |
| 239 | "docs.chrome.signin": "Sign in", |
| 240 | "docs.chrome.account": "Account: {address}", |
| 241 | "docs.chrome.account.anonymous": "Account", |
| 242 | "docs.chrome.signedinas": "Signed in as", |
| 243 | "docs.chrome.appearance": "Appearance", |
| 244 | "docs.chrome.appearance.light": "Light", |
| 245 | "docs.chrome.appearance.dark": "Dark", |
| 246 | "docs.chrome.appearance.system": "System", |
| 247 | "docs.chrome.help": "Help", |
| 248 | |
| 249 | // docs.help.* — the Help group's rows (chrome.go) and Help → Fonts |
| 250 | // (colophon.go, views/help_fonts.html), in Paul's plain style. Docs |
| 251 | // has no Word export yet (internal/docx), so the page says what it |
| 252 | // will do. The font pairs themselves come from fonts.json. |
| 253 | "docs.help.fonts": "Fonts", |
| 254 | "docs.help.colophon": "Colophon", |
| 255 | "docs.help.fonts.title": "Fonts", |
| 256 | "docs.help.fonts.word": "Some of Docs’ fonts are drawn to the same measurements as fonts Microsoft ships with Office and Windows. Every letter takes the same space, so a document breaks its lines and pages in the same places in both.", |
| 257 | "docs.help.fonts.col.font": "In Docs", |
| 258 | "docs.help.fonts.col.twin": "Same measurements as", |
| 259 | "docs.help.fonts.default": "New documents are in {font}, so they lay out as they would in Word in {twin}.", |
| 260 | "docs.help.fonts.export": "Docs can’t export to Word yet. When it can, it will give each of these fonts the name of the one it matches, so Word sets the text in its own font and the layout holds.", |
| 261 | "docs.help.fonts.more": "Who made each font, and its license, is listed under", |
| 262 | "docs.help.fonts.colophon": "Typefaces in the colophon", |
| 263 | |
| 264 | // docs.colophon.* — Help → Colophon (colophon.go). The entries' own |
| 265 | // words are estilo's catalog's, in English like the licenses beside |
| 266 | // them; these are the page's. |
| 267 | "docs.colophon.title": "Colophon", |
| 268 | "docs.colophon.intro": "Docs is made with a lot of other people’s open-source work. This is all of it: every typeface, library, icon set and tool, what each one is, what Docs uses it for, who made it and the license it is under.", |
| 269 | "docs.colophon.intro.exhaustive": "The list is made from what Docs is actually built from, so nothing is missing from it and nothing in it is out of date.", |
| 270 | "docs.colophon.contents": "On this page", |
| 271 | "docs.colophon.section.typefaces": "Typefaces", |
| 272 | "docs.colophon.section.go": "Go libraries", |
| 273 | "docs.colophon.section.javascript": "JavaScript libraries", |
| 274 | "docs.colophon.section.rust": "Rust libraries", |
| 275 | "docs.colophon.section.swift": "Swift libraries", |
| 276 | "docs.colophon.section.icons": "Icons and artwork", |
| 277 | "docs.colophon.section.data": "Data", |
| 278 | "docs.colophon.section.tools": "Tools", |
| 279 | "docs.colophon.section.services": "Services", |
| 280 | "docs.colophon.by": "By", |
| 281 | "docs.colophon.licence": "License", |
| 282 | "docs.colophon.version": "Version", |
| 283 | "docs.colophon.home": "Home page", |
| 284 | "docs.colophon.source": "Source", |
| 285 | "docs.colophon.homeandsource": "Home page and source", |
| 286 | "docs.colophon.back": "Back to the colophon", |
| 287 | "docs.colophon.licence.title": "{name}: license", |
| 288 | "docs.colophon.missing": "This package is published without a license file, so there is no text to show.", |
| 289 | "docs.colophon.notincluded": "Docs is built or tested with this, but it isn’t part of what Docs ships, so its license text isn’t copied here. It is in the project’s source.", |
| 290 | // The switcher. "All apps" rather than "Oficina": as a menu label, |
| 291 | // the suite's name collides with the brand on the hub's own bar |
| 292 | // (spec §13 Q2, Paul's answer). |
| 293 | "docs.chrome.apps": "Oficina apps", |
| 294 | "docs.chrome.allapps": "All apps", |
| 295 | "docs.chrome.thisapp": "(this app)", |
| 296 | // The editable title in the bar (spec §5.4, §13 Q7). |
| 297 | "docs.chrome.title.label": "Document title", |
| 298 | "docs.chrome.title.rename": "Rename", |
| 299 | |
| 300 | // docs.error.page.* is the error page (errors.go, spec §3.2). Each |
| 301 | // status has a tab title, a heading and one sentence; {app} is the |
| 302 | // app's name. A document that is missing and one not shared with you |
| 303 | // are one page, so neither can be told from the other. |
| 304 | "docs.error.page.404.title": "Page not found", |
| 305 | "docs.error.page.404.heading": "We can’t find that page", |
| 306 | "docs.error.page.404.body": "The link may be out of date, or the page may have moved.", |
| 307 | "docs.error.page.document.title": "Document not available", |
| 308 | "docs.error.page.document.heading": "This document isn’t available", |
| 309 | "docs.error.page.document.body": "It may have been deleted, or it hasn’t been shared with you.", |
| 310 | "docs.error.page.403.title": "No access", |
| 311 | "docs.error.page.403.heading": "You don’t have access to this page", |
| 312 | "docs.error.page.403.body": "Ask whoever runs this team if you think you should.", |
| 313 | "docs.error.page.400.title": "Something went wrong", |
| 314 | "docs.error.page.400.heading": "That didn’t work", |
| 315 | "docs.error.page.400.body": "Go back and try again.", |
| 316 | "docs.error.page.500.title": "Something went wrong", |
| 317 | "docs.error.page.500.heading": "Something went wrong", |
| 318 | "docs.error.page.500.body": "Try again in a moment. If it keeps happening, quote the reference below.", |
| 319 | "docs.error.page.503.title": "{app} is unavailable", |
| 320 | "docs.error.page.503.heading": "{app} is unavailable right now", |
| 321 | "docs.error.page.503.body": "Try again in a few minutes.", |
| 322 | "docs.error.home": "Go to {app}", |
| 323 | "docs.error.retry": "Try again", |
| 324 | "docs.error.back": "Back", |
| 325 | "docs.error.ref": "Reference:", |
| 326 | |
| 327 | // docs.error.generic is the one fallback error string this task |
| 328 | // has: a render failure with nowhere styled to land yet (SKILL.md |
| 329 | // §7's view.Fail/ErrorPage wiring is later work). Still a catalog |
| 330 | // key, never a literal, even though it is plain text today. |
| 331 | "docs.error.generic": "Something went wrong.", |
| 332 | |
| 333 | // docs.error.notfound answers GET /d/{sqid} for an unknown sqid — |
| 334 | // spec §4.2's 404-not-403 contract. Same "nowhere styled to land |
| 335 | // yet" caveat as docs.error.generic above. |
| 336 | "docs.error.notfound": "Not found.", |
| 337 | |
| 338 | // docs.error.badupdate answers POST /d/{sqid}/updates when the |
| 339 | // posted bytes are not a Yjs update the core will accept — a |
| 340 | // client error (400), not a render failure, but still a catalog |
| 341 | // key rather than a literal in the handler (Task 5). |
| 342 | "docs.error.badupdate": "That update could not be applied.", |
| 343 | |
| 344 | // docs.error.updatetoolarge answers POST /d/{sqid}/updates when |
| 345 | // the body exceeds maxUpdateBytes (handlers.go) — refused before |
| 346 | // it is read into memory (http.MaxBytesReader), so this is what a |
| 347 | // browser sees for it (Task 5). |
| 348 | "docs.error.updatetoolarge": "That update is too large.", |
| 349 | |
| 350 | // docs.error.badsince answers GET /d/{sqid}/updates when the |
| 351 | // ?since= cursor is not a non-negative integer (handlers.go's |
| 352 | // parseSince). Only a broken or hand-typed client can produce it — |
| 353 | // the editor's own cursor comes from a Docs-Seq header this app |
| 354 | // wrote — so this is a key nobody should ever see, kept a catalog |
| 355 | // key anyway because "nobody should see it" is exactly the |
| 356 | // reasoning that leaves an untranslated literal in the codebase. |
| 357 | "docs.error.badsince": "That update cursor is not valid.", |
| 358 | |
| 359 | // docs.document.untitled is POST /documents' fallback title when |
| 360 | // the submitted one is empty or all whitespace — boilerplate copy |
| 361 | // this app writes, not the caller's own input, so it is a catalog |
| 362 | // key rather than a hardcoded default. |
| 363 | "docs.document.untitled": "Untitled document", |
| 364 | |
| 365 | // Import (import.go): the page, its refusals, and the report. English |
| 366 | // like the rest of Docs; the Google chooser's own strings are |
| 367 | // estilo's, in twelve locales. |
| 368 | "docs.list.import": "Import…", |
| 369 | "docs.import.title": "Import a Word document", |
| 370 | "docs.import.intro": "Choose a .docx file. Docs makes a new, editable copy; the file itself is not changed or kept.", |
| 371 | "docs.import.fidelity": "An import brings in paragraph text, headings, bold and italic, and the fonts and sizes Docs has. Headings take Docs' own heading look. Lists and tables become plain paragraphs, links keep their text, and spacing, indentation, colors, images, comments, footnotes, headers and footers are left out. Docs lists what it noticed afterwards.", |
| 372 | "docs.import.file": "Word document (.docx)", |
| 373 | "docs.import.submit": "Import", |
| 374 | "docs.import.error.nofile": "Choose a .docx file to import.", |
| 375 | "docs.import.error.notword": "That file is not a Word document Docs can read. Choose a .docx file, or download the document from Google Docs as Microsoft Word (.docx).", |
| 376 | "docs.import.error.damaged": "That Word document looks damaged, so nothing was imported. Try saving it again from the program that made it.", |
| 377 | "docs.import.error.toolarge": "That document is too large to import. The limit is a 10 MB file holding up to 5,000 paragraphs and about 500 KB of text.", |
| 378 | "docs.import.error.empty": "That document has no text Docs can import, so nothing was created.", |
| 379 | "docs.import.error.busy": "Docs is busy importing other documents. Try again in a moment.", |
| 380 | "docs.import.error.failed": "The import did not finish, and nothing was created. Try again.", |
| 381 | "docs.import.error.unsealed": "Importing is not available here yet: this instance has not turned on content sealing, and an import is only ever stored sealed. Ask whoever runs it to run docs docs-seal.", |
| 382 | |
| 383 | "docs.import.report.heading": "Import report", |
| 384 | "docs.import.report.open": "Import report", |
| 385 | "docs.import.report.back": "Back to the document", |
| 386 | "docs.import.report.close": "Close", |
| 387 | "docs.import.report.incomplete": "This report lists what Docs noticed. It may not name everything the original had, so compare the two before relying on the copy.", |
| 388 | "docs.import.report.none": "Docs noticed nothing it could not bring in.", |
| 389 | "docs.import.report.where": "(paragraphs {paragraphs})", |
| 390 | "docs.import.report.where.more": "(paragraphs {paragraphs} and more)", |
| 391 | |
| 392 | "docs.import.report.table_flattened": "Tables became plain paragraphs, cell by cell: {count}.", |
| 393 | "docs.import.report.list_flattened": "List items became plain paragraphs, without bullets or numbers: {count}.", |
| 394 | "docs.import.report.link_text_kept": "Links kept their text but are no longer links: {count}.", |
| 395 | "docs.import.report.insertion_kept": "Suggested insertions were kept as ordinary text: {count}.", |
| 396 | "docs.import.report.deletion_omitted": "Suggested deletions were left out: {count}.", |
| 397 | "docs.import.report.object_omitted": "Images, drawings, equations and other objects were left out: {count}.", |
| 398 | "docs.import.report.notes_omitted": "Footnotes and endnotes were left out: {count}.", |
| 399 | "docs.import.report.comments_omitted": "Comments were left out: {count}.", |
| 400 | "docs.import.report.headers_footers_omitted": "Headers and footers were left out.", |
| 401 | "docs.import.report.title_as_heading": "Titles became first-level headings: {count}.", |
| 402 | "docs.import.report.subtitle_as_paragraph": "Subtitles became ordinary paragraphs: {count}.", |
| 403 | "docs.import.report.font_substituted": "Text in fonts Docs does not have is in the default font instead: {count} runs.", |
| 404 | "docs.import.report.size_dropped": "Text in sizes Docs does not offer is at the default size instead: {count} runs.", |
| 405 | "docs.import.report.formatting_lost": "Underline, strikethrough, color, highlight, superscript, subscript and capitals were left out: {count} runs.", |
| 406 | "docs.import.report.alignment_lost": "Centered and right-aligned paragraphs are left-aligned: {count}.", |
| 407 | "docs.import.report.tab_as_space": "Tabs became spaces: {count}.", |
| 408 | "docs.import.report.line_break_split": "Line breaks became new paragraphs: {count}.", |
| 409 | "docs.import.report.page_break_split": "Page and column breaks became new paragraphs: {count}.", |
| 410 | |
| 411 | // docs.signin.* — the sign-in door (auth.go's signin). The door's own |
| 412 | // words, every outcome rastrillo's handlers redirect back with |
| 413 | // (?sent=1, ?err=rate|address|expired|keymail|1) and the Keymail |
| 414 | // continuation are rastrillo's sign-in screen copy |
| 415 | // (rastrillo.ui.signin_*), and the signed-out page is estilo's |
| 416 | // chrome.English. What stays is what only Docs knows: the refusal |
| 417 | // (Config.Refused, the screen's app-problem slot). |
| 418 | "docs.signin.error.refused": "That email can’t sign in to Docs. Use a different email, or ask whoever runs this team to add it.", |
| 419 | |
| 420 | // docs.signout.label is the sign-out control's text — both its |
| 421 | // button label and its accessible name. It lives in the shell |
| 422 | // bar's account menu, which list.html and show.html each fill with |
| 423 | // an "account" block; it was in their two page headers until the |
| 424 | // chrome moved to the topbar shell (see shellLayout above). |
| 425 | // docs.list.shared marks a row on the list that belongs to somebody |
| 426 | // else. It exists because the list stopped being "your documents" the |
| 427 | // day sharing landed, and a row that looks like yours and is not is |
| 428 | // how a person opens a document expecting to be able to edit it. |
| 429 | "docs.list.shared": "Shared with you", |
| 430 | // docs.list.team marks a row somebody else owns that the reader reaches |
| 431 | // through the team rung rather than a grant of their own. |
| 432 | "docs.list.team": "Shared with your team", |
| 433 | |
| 434 | "docs.signout.label": "Sign out", |
| 435 | |
| 436 | // docs.editor.status.* is the save-status indicator fix round 1's |
| 437 | // F2 added next to [docs-editor] (show.html), driven by |
| 438 | // fixtures/editor-entry.js's save queue and resync controller. |
| 439 | // retrying is the quiet state: a network hiccup or a 500 is being |
| 440 | // retried automatically, nothing is lost yet, so this stays |
| 441 | // understated. failed is the loud one: the core has permanently |
| 442 | // rejected a batch (a 4xx — e.g. a paste over maxUpdateBytes, or |
| 443 | // core.ErrUpdateLogFull once a document's log is full) and that |
| 444 | // batch has been dropped rather than retried forever or left to |
| 445 | // poison later edits (save-queue.mjs's own doc comment). |
| 446 | // |
| 447 | // failed's copy was wrong in fix round 1 ("Copy anything important |
| 448 | // before leaving this page"): by the time a person can read it, |
| 449 | // fixtures/editor-entry.js's resync has already discarded the |
| 450 | // diverged document and rebuilt the view from the server's own |
| 451 | // log (resync-controller.mjs) — the content that message told them |
| 452 | // to copy is no longer on screen to copy, and the advice pointed |
| 453 | // at staying put when a reload is the one thing that actually |
| 454 | // forces recovery sooner than the automatic retry would. Fix |
| 455 | // round 2 rewrote it to say what is true (something was lost, in |
| 456 | // the past tense — not a warning to act before it happens) and |
| 457 | // what helps (reload, the same fallback resync itself uses, |
| 458 | // available to a person immediately rather than waiting out |
| 459 | // resync-controller.mjs's own backoff). |
| 460 | "docs.editor.status.retrying": "Trouble saving. Retrying…", |
| 461 | "docs.editor.status.failed": "Some changes couldn't be saved and were lost. Reload the page if this keeps happening.", |
| 462 | // The two quiet states, said only under the large title on a phone |
| 463 | // (savestatus' "subtitle" placement, design/phone-web): the corner |
| 464 | // toast on a wide screen stays silent for both, as it always has. |
| 465 | // Drafts for copy review (2026-11-28). |
| 466 | "docs.editor.status.saved": "Saved", |
| 467 | "docs.editor.status.saving": "Saving…", |
| 468 | |
| 469 | // docs.editor.more is the phone's ••• button (design/phone-web); |
| 470 | // docs.show.viewonly says, under a reader's large title, that the |
| 471 | // document is theirs to read and not to change; docs.chrome.title.hint |
| 472 | // is said under the large title while it is being renamed. Drafts for |
| 473 | // copy review (2026-11-28). |
| 474 | "docs.editor.more": "More", |
| 475 | "docs.show.viewonly": "View only", |
| 476 | "docs.chrome.title.hint": "Return renames · Esc puts it back", |
| 477 | // docs.chrome.title.cancel is the large title's Cancel while it is |
| 478 | // being renamed on a touch screen, where there is no Esc. Draft for |
| 479 | // copy review (2026-11-28). |
| 480 | "docs.chrome.title.cancel": "Cancel", |
| 481 | // docs.chrome.title.failed is said under the large title's field when a |
| 482 | // rename was refused or could not reach the server; the field stays |
| 483 | // open with what was typed. Draft for copy review (2026-11-28). |
| 484 | "docs.chrome.title.failed": "Couldn't rename. Try again.", |
| 485 | |
| 486 | // docs.editor.toolbar.* — the formatting bar (show.html's |
| 487 | // [docs-toolbar], driven by fixtures/toolbar.mjs). Every one of |
| 488 | // these is both a control's visible tooltip and its accessible |
| 489 | // name: the buttons' content is a glyph or an icon, which |
| 490 | // announces as nothing useful on its own. |
| 491 | // |
| 492 | // The names describe what a person gets, not what the schema calls |
| 493 | // it — "Body text" rather than "Paragraph", because the control |
| 494 | // sits next to three headings and the question it answers is |
| 495 | // "which of these is this line", and "Numbered list" rather than |
| 496 | // "Ordered list" for the same reason. |
| 497 | "docs.editor.toolbar.label": "Formatting", |
| 498 | "docs.editor.toolbar.undo": "Undo", |
| 499 | // The inspector (spec I2): the undo/redo pair's name, the four |
| 500 | // sections' visible labels (each the name of its role="group"), the |
| 501 | // panel's own name, and the bar's Format toggle that shows and hides |
| 502 | // it. |
| 503 | "docs.editor.toolbar.history": "History", |
| 504 | "docs.editor.toolbar.group.style": "Style", |
| 505 | "docs.editor.toolbar.group.text": "Text", |
| 506 | "docs.editor.toolbar.group.align": "Alignment", |
| 507 | "docs.editor.toolbar.group.lists": "Lists", |
| 508 | "docs.editor.inspector.label": "Format", |
| 509 | "docs.editor.inspector.toggle": "Format", |
| 510 | // The phone's Format sheet and quick format bar (design/phone-web, |
| 511 | // P2): the sheet's close button, the size stepper's two steps, the |
| 512 | // sheet's last group, and the quick bar's hide-keyboard button. |
| 513 | // Drafts for copy review (2026-11-28). |
| 514 | "docs.editor.inspector.close": "Close", |
| 515 | "docs.editor.toolbar.size.down": "Smaller", |
| 516 | "docs.editor.toolbar.size.up": "Larger", |
| 517 | "docs.editor.toolbar.group.more": "More", |
| 518 | "docs.editor.quickbar.hide": "Hide keyboard", |
| 519 | "docs.editor.toolbar.redo": "Redo", |
| 520 | "docs.editor.toolbar.bold": "Bold", |
| 521 | "docs.editor.toolbar.italic": "Italic", |
| 522 | "docs.editor.toolbar.code": "Code", |
| 523 | "docs.editor.toolbar.bulletlist": "Bulleted list", |
| 524 | "docs.editor.toolbar.orderedlist": "Numbered list", |
| 525 | "docs.editor.toolbar.quote": "Quote", |
| 526 | "docs.editor.toolbar.block": "Style", |
| 527 | "docs.editor.toolbar.block.paragraph": "Body text", |
| 528 | "docs.editor.toolbar.block.heading1": "Heading 1", |
| 529 | "docs.editor.toolbar.block.heading2": "Heading 2", |
| 530 | "docs.editor.toolbar.block.heading3": "Heading 3", |
| 531 | "docs.editor.toolbar.font": "Font", |
| 532 | "docs.editor.fonts.substitute": "Some fonts are shown as substitutes. Reload to try again.", |
| 533 | "docs.editor.fonts.unavailable": "That font could not be loaded.", |
| 534 | "docs.editor.fonts.loading": "Loading a font…", |
| 535 | "docs.editor.fonts.refused": "A font is still loading.", |
| 536 | "docs.editor.fonts.dismiss": "Dismiss", |
| 537 | "docs.editor.toolbar.size": "Size", |
| 538 | "docs.editor.toolbar.size.small": "Small", |
| 539 | "docs.editor.toolbar.size.normal": "Normal", |
| 540 | "docs.editor.toolbar.size.large": "Large", |
| 541 | "docs.editor.toolbar.size.extralarge": "Extra large", |
| 542 | // Alignment. Three buttons rather than a select, because unlike |
| 543 | // Style/Font/Size these are a small closed set a person switches |
| 544 | // between constantly, and because the current one is worth showing |
| 545 | // at a glance (aria-pressed) rather than only on opening a list. |
| 546 | // |
| 547 | // "Align left" and not "Left": the name is read on its own by a |
| 548 | // screen reader, out of any row, and "Left" answers no question. |
| 549 | "docs.editor.toolbar.align.left": "Align left", |
| 550 | "docs.editor.toolbar.align.center": "Align center", |
| 551 | "docs.editor.toolbar.align.right": "Align right", |
| 552 | |
| 553 | // docs.editor.menu.* — the menu bar (show.html's [estilo-menubar], |
| 554 | // built by menu.go, given its keyboard behaviour by |
| 555 | // fixtures/menu.mjs). |
| 556 | // |
| 557 | // The six titles are the ones every word processor uses, and that |
| 558 | // is the whole argument for them: a menu bar is the one part of an |
| 559 | // editor where being unsurprising beats being expressive, because |
| 560 | // people arrive already knowing where Export lives. Nothing here |
| 561 | // tries to be a better word for File. |
| 562 | // |
| 563 | // Item labels name what a person gets, matching the rule the |
| 564 | // toolbar keys above already follow. Where a label exists in the |
| 565 | // toolbar catalog it is reused rather than restated — Bold, Undo, |
| 566 | // the alignments, the two exports — so the two surfaces cannot |
| 567 | // drift into calling the same command different things. |
| 568 | "docs.editor.menu.label": "Menus", |
| 569 | "docs.editor.menu.file": "File", |
| 570 | "docs.editor.menu.edit": "Edit", |
| 571 | "docs.editor.menu.view": "View", |
| 572 | "docs.editor.menu.format": "Format", |
| 573 | "docs.editor.menu.tools": "Tools", |
| 574 | "docs.editor.menu.help": "Help", |
| 575 | |
| 576 | // docs.delete.* — File → Delete… and its confirmation page |
| 577 | // (delete.go). Only the owner sees either. |
| 578 | "docs.editor.menu.file.delete": "Delete…", |
| 579 | "docs.delete.title": "Delete", |
| 580 | "docs.delete.heading": "Delete “{title}”?", |
| 581 | "docs.delete.body": "It leaves your documents, and everyone you shared it with loses it too.", |
| 582 | "docs.delete.confirm": "Delete document", |
| 583 | "docs.delete.cancel": "Cancel", |
| 584 | |
| 585 | "docs.editor.menu.file.new": "New document", |
| 586 | // The ellipsis (U+2026) marks an item that needs more before anything |
| 587 | // happens: a palette, a dialog (spec §7.3). An item that simply does |
| 588 | // its thing, or navigates, has none. |
| 589 | "docs.editor.menu.file.open": "Open a document…", |
| 590 | "docs.editor.menu.file.print": "Print…", |
| 591 | |
| 592 | "docs.editor.menu.edit.selectall": "Select all", |
| 593 | |
| 594 | "docs.editor.menu.view.paged": "Paged", |
| 595 | "docs.editor.menu.view.infinite": "Infinite", |
| 596 | |
| 597 | "docs.editor.menu.format.indent": "Increase indent", |
| 598 | "docs.editor.menu.format.outdent": "Decrease indent", |
| 599 | // "Clear formatting" and not "Remove formatting": it is what every |
| 600 | // editor calls it, and the verb people search for. |
| 601 | "docs.editor.menu.format.clear": "Clear formatting", |
| 602 | |
| 603 | "docs.editor.menu.tools.wordcount": "Word count…", |
| 604 | "docs.editor.menu.tools.shortcuts": "Keyboard shortcuts…", |
| 605 | |
| 606 | // The number on a page break in paged mode. {n} is substituted by |
| 607 | // fixtures/pages.mjs. |
| 608 | // |
| 609 | // "Page 2" rather than a bare "2", because it sits alone on the |
| 610 | // desk between two sheets with nothing around it to say what the |
| 611 | // number counts. |
| 612 | "docs.editor.page.number": "Page {n}", |
| 613 | |
| 614 | // docs.editor.wordcount.* — Tools → Word count, a native <dialog>. |
| 615 | // |
| 616 | // Four numbers, each labelled with what it counts rather than with a |
| 617 | // bare noun: "Characters" alone leaves a reader working out whether |
| 618 | // spaces are in it, which is the one thing anybody actually wants to |
| 619 | // know about a character count. |
| 620 | "docs.editor.wordcount.title": "Word count", |
| 621 | "docs.editor.wordcount.words": "Words", |
| 622 | "docs.editor.wordcount.characters": "Characters", |
| 623 | "docs.editor.wordcount.charactersnospaces": "Characters excluding spaces", |
| 624 | "docs.editor.wordcount.paragraphs": "Paragraphs", |
| 625 | "docs.editor.wordcount.selection": "Words in the selection", |
| 626 | "docs.editor.wordcount.close": "Close", |
| 627 | |
| 628 | // docs.editor.shortcuts.* — Tools → Keyboard shortcuts. |
| 629 | // |
| 630 | // The rows are read out of the menu bar's own DOM |
| 631 | // (fixtures/shortcuts.mjs), so there are no per-shortcut strings |
| 632 | // here to keep in step. These two are the bindings NO menu item |
| 633 | // carries, and they are the two a person most needs told: Tab is |
| 634 | // repurposed inside the document, and Escape is how you leave it. |
| 635 | "docs.editor.shortcuts.title": "Keyboard shortcuts", |
| 636 | "docs.editor.shortcuts.close": "Close", |
| 637 | "docs.editor.shortcuts.editing": "Writing", |
| 638 | "docs.editor.shortcuts.indent": "Indent, or nest a list item", |
| 639 | "docs.editor.shortcuts.outdent": "Outdent, or lift a list item", |
| 640 | "docs.editor.shortcuts.undoformat": "Undo an autoformat, keeping what you typed", |
| 641 | "docs.editor.shortcuts.linebreak": "Break a line without starting a paragraph", |
| 642 | // The one a person cannot guess and most needs. Tab indents inside |
| 643 | // the document rather than moving focus, so this is the way out — |
| 644 | // WCAG 2.1.2 permits the repurposed key precisely because there is |
| 645 | // an exit the person has been told about, and this row is the |
| 646 | // telling. |
| 647 | "docs.editor.shortcuts.leave": "Leave the document for the toolbar", |
| 648 | |
| 649 | // docs.export.* — the two download links, now items in the File |
| 650 | // menu (menu.go) rather than buttons pinned to the formatting bar. |
| 651 | // The long forms are what the items say AND their accessible names; |
| 652 | // the short forms are kept because [docs-doc-actions] is gone but |
| 653 | // the strings are still what a compact surface would want, and |
| 654 | // deleting a catalog key is not free. |
| 655 | "docs.export.pdf.short": "PDF", |
| 656 | "docs.export.pdf.label": "Download as PDF", |
| 657 | "docs.export.markdown.short": "Markdown", |
| 658 | "docs.export.markdown.label": "Download as Markdown", |
| 659 | } |
| 660 | |
| 661 | // Locales and DefaultLocale declare this app's locale set for |
| 662 | // cmd/docs/main.go's rastrillo.Options — one locale today. Without |
| 663 | // Options.Locales set, rastrillo installs no locale middleware and |
| 664 | // rastrillo.T falls back to returning its key verbatim (documented, |
| 665 | // harmless — it's what a direct App.Handler() call in a test sees, |
| 666 | // never having gone through that middleware); main.go wiring these in |
| 667 | // is what makes Catalog's strings actually resolve on the real page. |
| 668 | var Locales = []string{"en"} |
| 669 | |
| 670 | const DefaultLocale = "en" |
| 671 | |
| 672 | // viewsFS embeds this app's own page templates — SKILL.md's "one |
| 673 | // *template.Template per page (layout + page)" pattern, the page half |
| 674 | // as a real file per Task 3's file list rather than an inline Go |
| 675 | // string (as Task 1's home page was): a page with a group loop and a |
| 676 | // style block reads better as markup than as a quoted constant. |
| 677 | // |
| 678 | //go:embed views/*.html views/partials/*.html |
| 679 | var viewsFS embed.FS |
| 680 | |
| 681 | // headTemplate is the app-wide "head" definition newRenderer parses |
| 682 | // into the base template — the shell's own app slot in <head>, which |
| 683 | // today carries the tab icon. Deliberately outside pageTemplates |
| 684 | // below: it defines "head", never "content", so it is not a page and |
| 685 | // must not be cloned per page. |
| 686 | const headTemplate = "views/head.html" |
| 687 | |
| 688 | // layoutTemplate defines "layout", the document every page renders into. |
| 689 | const layoutTemplate = "views/layout.html" |
| 690 | |
| 691 | // pageTemplates maps a page name to its file under views/. |
| 692 | var pageTemplates = map[string]string{ |
| 693 | "colophon": "views/colophon.html", |
| 694 | "colophon-licence": "views/colophon_licence.html", |
| 695 | "delete": "views/delete.html", |
| 696 | "help-fonts": "views/help_fonts.html", |
| 697 | "import": "views/import.html", |
| 698 | "import-report": "views/import_report.html", |
| 699 | "error": "views/error.html", |
| 700 | "home-link": "views/home_link.html", |
| 701 | "list": "views/list.html", |
| 702 | "public": "views/public.html", |
| 703 | "share": "views/share.html", |
| 704 | "show": "views/show.html", |
| 705 | "signin": "views/signin.html", |
| 706 | } |
| 707 | |
| 708 | // renderer owns the app's parsed templates and its fingerprinted |
| 709 | // static-asset registry. |
| 710 | type renderer struct { |
| 711 | pages map[string]*template.Template |
| 712 | assets *rastrillo.Assets |
| 713 | // frame builds a page's chrome for the pages the renderer draws on |
| 714 | // its own (home_render.go); app.go sets it to handlers.frame. |
| 715 | frame func(*http.Request, frameOptions) Frame |
| 716 | } |
| 717 | |
| 718 | // newRenderer builds the renderer: the vendored design-system CSS/JS |
| 719 | // as an in-memory static tree, rastrillo's shell partials and layout, |
| 720 | // and this app's own pages, each cloned from the same base so every |
| 721 | // page shares helpers and the shell without sharing a "content" |
| 722 | // definition. |
| 723 | func newRenderer() (*renderer, error) { |
| 724 | staticFS, err := vendoredStaticFS() |
| 725 | if err != nil { |
| 726 | return nil, err |
| 727 | } |
| 728 | assets := rastrillo.NewAssets(staticFS) |
| 729 | |
| 730 | base := template.New("").Funcs(ui.Funcs()).Funcs(template.FuncMap{ |
| 731 | "asset": assets.Path, |
| 732 | // moreRowIn pairs a ••• row with whether its panel draws the |
| 733 | // check column (views/partials/editor_bar.html's docs-more-row). |
| 734 | "moreRowIn": func(row moreRow, checks bool) moreRowView { return moreRowView{Row: row, Checks: checks} }, |
| 735 | }) |
| 736 | base, err = base.ParseFS(ui.Templates(), "*.html") |
| 737 | if err != nil { |
| 738 | return nil, fmt.Errorf("docs: parse rastrillo ui partials: %w", err) |
| 739 | } |
| 740 | |
| 741 | // estilo's menu and chrome templates (the bar, account menu, |
| 742 | // switcher, error body and sign-in pages), then this app's layout |
| 743 | // and "head", all into the base every page is cloned from. |
| 744 | if base, err = base.ParseFS(estilomenu.Templates(), "templates/*.html"); err != nil { |
| 745 | return nil, fmt.Errorf("docs: parse estilo menu templates: %w", err) |
| 746 | } |
| 747 | if base, err = base.ParseFS(chrome.Templates(), "templates/*.html"); err != nil { |
| 748 | return nil, fmt.Errorf("docs: parse estilo chrome templates: %w", err) |
| 749 | } |
| 750 | if base, err = base.ParseFS(colophon.Templates(), "templates/*.html"); err != nil { |
| 751 | return nil, fmt.Errorf("docs: parse estilo colophon templates: %w", err) |
| 752 | } |
| 753 | if base, err = base.ParseFS(googleimport.Templates(), "templates/*.html"); err != nil { |
| 754 | return nil, fmt.Errorf("docs: parse estilo google import template: %w", err) |
| 755 | } |
| 756 | if base, err = base.ParseFS(viewsFS, layoutTemplate, headTemplate); err != nil { |
| 757 | return nil, fmt.Errorf("docs: parse layout: %w", err) |
| 758 | } |
| 759 | |
| 760 | base, err = base.Parse(savestatus.Template()) |
| 761 | if err != nil { |
| 762 | return nil, err |
| 763 | } |
| 764 | |
| 765 | pages := make(map[string]*template.Template, len(pageTemplates)) |
| 766 | for name, path := range pageTemplates { |
| 767 | page, err := base.Clone() |
| 768 | if err != nil { |
| 769 | return nil, fmt.Errorf("docs: clone base template for %q: %w", name, err) |
| 770 | } |
| 771 | // This app's own shared partials (views/partials/*.html — |
| 772 | // today, the jump-to palette, which every signed-in page |
| 773 | // carries) are parsed into every page alongside it, the same |
| 774 | // way rastrillo's own partials are parsed into the base |
| 775 | // above. Per page rather than once into the base because the |
| 776 | // base is cloned, and a clone made before the partials were |
| 777 | // parsed would not have them. |
| 778 | if page, err = page.ParseFS(viewsFS, "views/partials/*.html"); err != nil { |
| 779 | return nil, fmt.Errorf("docs: parse shared partials for %q: %w", name, err) |
| 780 | } |
| 781 | if page, err = page.ParseFS(viewsFS, path); err != nil { |
| 782 | return nil, fmt.Errorf("docs: parse page %q: %w", name, err) |
| 783 | } |
| 784 | pages[name] = page |
| 785 | } |
| 786 | |
| 787 | return &renderer{pages: pages, assets: assets}, nil |
| 788 | } |
| 789 | |
| 790 | // page renders the named page's "layout" template — its own content |
| 791 | // inside views/layout.html and the estilo bar — into w. |
| 792 | func (rd *renderer) page(w http.ResponseWriter, r *http.Request, name string, data any) error { |
| 793 | return rd.pageStatus(w, r, name, data, 0) |
| 794 | } |
| 795 | |
| 796 | func (rd *renderer) pageStatus(w http.ResponseWriter, r *http.Request, name string, data any, status int) error { |
| 797 | tmpl, ok := rd.pages[name] |
| 798 | if !ok { |
| 799 | return fmt.Errorf("docs: unknown page %q", name) |
| 800 | } |
| 801 | // Render into a buffer first: a mid-template error must not leave |
| 802 | // a half-written 200 on the wire. |
| 803 | var buf bytes.Buffer |
| 804 | if err := tmpl.ExecuteTemplate(&buf, "layout", data); err != nil { |
| 805 | return fmt.Errorf("docs: render page %q: %w", name, err) |
| 806 | } |
| 807 | w.Header().Set("Content-Type", "text/html; charset=utf-8") |
| 808 | pageHeaders(w) |
| 809 | return writeGuardedBody(w, r, status, buf.Bytes()) |
| 810 | } |
| 811 | |
| 812 | // signinTitle is the sign-in door's <title>: estilo's |
| 813 | // estilo-signin-screen-title, which is rastrillo's signin-title for the |
| 814 | // same state, so the tab and the heading always say the same thing. The |
| 815 | // template writes escaped text, and the layout escapes the title again, |
| 816 | // so it is unescaped here. |
| 817 | func (rd *renderer) signinTitle(screen chrome.SignInScreen) (string, error) { |
| 818 | title, err := rd.fragment("signin", "estilo-signin-screen-title", screen) |
| 819 | if err != nil { |
| 820 | return "", err |
| 821 | } |
| 822 | return strings.TrimSpace(html.UnescapeString(string(title))), nil |
| 823 | } |
| 824 | |
| 825 | // fragment renders one named template of a page's set into markup the |
| 826 | // page's data carries on: the editor's menu bar and undo/redo pair go into |
| 827 | // estilo's bar slots (chrome.Bar.Menubar and Lead), which take trusted |
| 828 | // template.HTML. Rendered here, from views/partials, so they are this |
| 829 | // app's own template output and nothing a person typed. |
| 830 | func (rd *renderer) fragment(page, name string, data any) (template.HTML, error) { |
| 831 | tmpl, ok := rd.pages[page] |
| 832 | if !ok { |
| 833 | return "", fmt.Errorf("docs: unknown page %q", page) |
| 834 | } |
| 835 | var buf bytes.Buffer |
| 836 | if err := tmpl.ExecuteTemplate(&buf, name, data); err != nil { |
| 837 | return "", fmt.Errorf("docs: render %q: %w", name, err) |
| 838 | } |
| 839 | return template.HTML(buf.String()), nil // #nosec: our own template's output |
| 840 | } |
| 841 | |
| 842 | // vendoredStaticFS builds the static/ tree rastrillo.Assets serves — |
| 843 | // estilo's theme for Docs (Calma, with Docs' accent; estilo AGENTS.md, |
| 844 | // decisions table, row 8), plus tokens.css and the three scripts |
| 845 | // the shell's <head> links unconditionally (the shim and busy rule from |
| 846 | // estilo's busy; ui.SelectJS/DatetimeJS) |
| 847 | // taken straight from the selected rastrillo module. Nothing here is copied to |
| 848 | // static/ by hand: rastrillo new would normally vendor these to disk |
| 849 | // once at scaffold time (ui.VendoredAssets's own doc comment), but |
| 850 | // this app was hand-built rather than scaffolded, so it takes the |
| 851 | // same bytes at process start instead, from an in-memory fs.FS. |
| 852 | // testing/fstest.MapFS is the standard library's only in-memory |
| 853 | // fs.FS — used here as a data structure, not as a test helper. |
| 854 | func vendoredStaticFS() (fs.FS, error) { |
| 855 | docsTheme, ok := theme.ForApp("docs") |
| 856 | if !ok { |
| 857 | return nil, fmt.Errorf("docs: estilo's theme ring has no docs") |
| 858 | } |
| 859 | files := fstest.MapFS{ |
| 860 | "static/estilo-save-status.css": {Data: savestatus.CSS()}, |
| 861 | "static/estilo-save-status.mjs": {Data: savestatus.JS()}, |
| 862 | "static/tokens.css": {Data: ui.TokensCSS()}, |
| 863 | "static/theme.css": {Data: docsTheme}, |
| 864 | // rastrillo's busy rule (Paul, 2026-09-29): a submit button's |
| 865 | // label gives way to a spinner for at least 650ms, the button |
| 866 | // disables, and Back resets it. estilo carries rastrillo's shim |
| 867 | // without the old busy rule, busy.js and the spinner-in-place CSS. |
| 868 | "static/rastrillo.js": {Data: busy.ShimJS()}, |
| 869 | "static/estilo/busy.js": {Data: busy.JS()}, |
| 870 | "static/estilo/busy.css": {Data: busy.CSS()}, |
| 871 | "static/select.js": {Data: ui.SelectJS()}, |
| 872 | "static/datetime.js": {Data: ui.DatetimeJS()}, |
| 873 | // rastrillo's light: the pointer's sheen on its buttons and a |
| 874 | // list card's rim brightening near the pointer (brand/light.css |
| 875 | // gives Docs the values; brand/pointer.js does Docs' own |
| 876 | // controls the same way). |
| 877 | "static/light.js": {Data: ui.LightJS()}, |
| 878 | // estilo's shared chrome, fingerprinted like the theme. |
| 879 | "static/estilo/base.css": {Data: base.CSS()}, |
| 880 | "static/estilo/menu.css": {Data: estilomenu.CSS()}, |
| 881 | "static/estilo/chrome.css": {Data: chrome.CSS()}, |
| 882 | // Help → Colophon and Help → Fonts. |
| 883 | "static/estilo/colophon.css": {Data: colophon.CSS()}, |
| 884 | // The sky behind the sign-in door; images from sky.Handler. |
| 885 | "static/estilo/sky.css": {Data: sky.CSS()}, |
| 886 | "static/estilo/chrome.js": {Data: chrome.JS()}, |
| 887 | // The Google Drive chooser, linked only from a configured |
| 888 | // import page (import.go). |
| 889 | "static/estilo/" + googleimport.JSName(): {Data: googleimport.JS()}, |
| 890 | } |
| 891 | for _, name := range []string{"icon-32.png", "apple-touch-icon.png", "brand.css", "LICENSE.lucide", "light.css", "pointer.js", "list.js", "share-pop.js", "share-pop.css", "inspector.js", "phone.js"} { |
| 892 | body, err := brandFS.ReadFile("brand/" + name) |
| 893 | if err != nil { |
| 894 | return nil, err |
| 895 | } |
| 896 | files["static/brand/"+name] = &fstest.MapFile{Data: body} |
| 897 | } |
| 898 | return files, nil |
| 899 | } |
| 900 | |