oficina / home Public

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

Plain git — no account needed to clone.

Download

Download this file

1package home
2
3import (
4 "amadan.net/oficina/estilo.git/busy"
5 _ "embed"
6
7 "amadan.net/oficina/estilo.git/chrome"
8 "amadan.net/oficina/estilo.git/sky"
9 "amadan.net/oficina/estilo.git/theme"
10 "github.com/go-chi/chi/v5"
11)
12
13// Calma is the suite's look (estilo AGENTS.md, decisions table, row 8).
14// Home is where the suite meets you — the front page, the sign-in, your
15// home — so it is where the sky goes; the apps themselves never carry it.
16
17//go:embed static/calma.css
18var calmaCSS []byte
19
20// The hand-off pages' reveal rule and its script-off override
21// (handoff.css says why they are files).
22//
23//go:embed static/handoff.css
24var handoffCSS []byte
25
26//go:embed static/handoff-noscript.css
27var handoffNoscriptCSS []byte
28
29// homeFuncs are the template helpers Home's layout calls. suiteSky is the
30// sky for pages that belong to no one team: all of Home's, today, since
31// the directory lists apps rather than one team's.
32var homeFuncs = map[string]any{
33 // v links a stylesheet or picture by its content version (assetversion.go).
34 "v": versioned,
35 "suiteSky": func() sky.View { return sky.For(sky.SuiteSeed) },
36 // The door's words and tab titles are estilo's (chrome.English), the
37 // one copy set every app's door speaks, so the hub's door cannot
38 // drift from theirs. The sign-in door itself is rastrillo's partial in
39 // estilo's door (door.go); these are the pages around it.
40 "signedOutDoor": func() chrome.SignInNotice {
41 return chrome.SignInNotice{App: suiteName}.SignedOut("/auth/start")
42 },
43 // forgetLabel is estilo's "Forget me on this device" (SignInNotice.
44 // Forgetting's label), on id.*'s own signed-out page.
45 "forgetLabel": func() string { return chrome.English.Forget },
46 "linkLifetime": func() int { return int(chrome.LinkLifetime.Minutes()) },
47 // doorView is estilo-door-open's data: the suite's sky behind one
48 // card, the Oficina mark and the page's brand at its head (page.Brand:
49 // "Oficina ID" on id.*, as on its sign-in door; "Oficina" on the
50 // directory).
51 "doorView": func(brand any) doorView {
52 return doorView{Sky: sky.For(sky.SuiteSeed), Icon: versioned("/static/brand/icon.svg"), App: brandOr(brand)}
53 },
54 // hopDoor is the door a hop page keeps: the same card and brand, on
55 // the sky's inline placeholder alone, a data: URI, so the moment
56 // between two skies is not a blank page and still fetches nothing it
57 // will not show (r3 C2). The card itself stays hidden unless the hop
58 // stalls (handoff.css).
59 "hopDoor": func(brand any) doorView {
60 var v sky.View
61 for _, l := range sky.For(sky.SuiteSeed).Layers {
62 if l.Inline != "" {
63 v.Layers = append(v.Layers, l)
64 }
65 }
66 return doorView{Sky: v, Icon: versioned("/static/brand/icon.svg"), App: brandOr(brand)}
67 },
68}
69
70// brandOr is the brand a door card names: the page's, else the suite's.
71// It takes any because a page drawn with bare data in a test has no
72// Brand at all.
73func brandOr(brand any) string {
74 if s, ok := brand.(string); ok && s != "" {
75 return s
76 }
77 return suiteName
78}
79
80// doorView is estilo-door-open's data (chrome/templates/signin.html).
81type doorView struct {
82 Sky sky.View
83 Icon, App string
84}
85
86// suiteName is what the hub calls itself to people: the suite, never
87// "Home" (Paul, 2026-09-23).
88const suiteName = "Oficina"
89
90// doorPages are the pages at the door — signing in, and everything on the
91// way in or out, and id.*'s account pages. The layout draws them as
92// estilo's door: one card on the sky with the Oficina mark, under the bar.
93// The sky goes only where Calma puts it — the door, the team home's header
94// and the front page's hero — so the team chooser, Open source and the
95// error pages are plain pages under the bar.
96// Not assertion.html or docs_continue.html: they are hops (hopPages). Not
97// door.html either: estilo-signin-screen draws the door itself.
98//
99// Every page id.* draws is the door or a hop (Paul, 2026-11-20: every id.*
100// page in the door's card), the error page included: on id.* it is
101// id_error.html, the same words in the card (chrome.go, errorPage). The
102// one exception is Open source (credits.html), a long list that is the
103// same page on both origins.
104var doorPages = map[string]bool{
105 "id_error.html": true,
106 "id_replace.html": true,
107 "id_replaced.html": true,
108 "id_signed_out.html": true,
109 "id_signout_all.html": true,
110 "id_forget.html": true,
111 "signin_confirm.html": true,
112 "signin_failed.html": true,
113 "passkey_confirm.html": true,
114 "passkey_enrol.html": true,
115 "recovery_codes.html": true,
116 "handoff_failed.html": true,
117 "signout_confirm.html": true,
118 "directory_signed_out.html": true,
119 "operator_confirm_id.html": true,
120 "resolve.html": true,
121 "directory_signout_all_failed.html": true,
122}
123
124// hopPages move on by themselves (an auto-submit, a 0 s refresh). They
125// keep the bar and the sky's inline placeholder, so the moment between the
126// door and the directory is not a blank page (r3 C2), but load no script,
127// no sky layer and no card: the card shows only if the hop stalls.
128var hopPages = map[string]bool{
129 "assertion.html": true,
130 "docs_continue.html": true,
131 "resolve_handoff.html": true,
132 "id_signout_all_hop.html": true,
133}
134
135// mountCalma serves the Calma pieces Home's pages link: the sky's layers
136// and stylesheet, and Home's own few rules for placing it. Public on both
137// origins; every handler here serves a closed set. It also keeps estilo's
138// retired v1 Onest files answering, so a page cached before the chrome
139// moved to the system face (estilo AGENTS.md row 9) still resolves its
140// stylesheet; no page links them.
141func mountCalma(r chi.Router) {
142 r.Handle(theme.FontPrefix+"*", theme.FontHandler())
143 r.Handle(sky.Prefix+"*", sky.Handler())
144 mountCSS(r, "/static/estilo/sky.css", sky.CSS())
145 mountChrome(r)
146 mountCSS(r, "/static/calma.css", calmaCSS)
147 mountCSS(r, "/static/handoff.css", handoffCSS)
148 mountCSS(r, "/static/handoff-noscript.css", handoffNoscriptCSS)
149 // estilo's busy rule: a submit button's label gives way to a spinner
150 // for at least 650ms, the button disables, the form refuses a second
151 // submit, and Back resets it. A progressive enhancement: every form
152 // works without it.
153 mountCSS(r, "/static/busy.css", busy.CSS())
154 versionAsset("/static/busy.js", busy.JS())
155 r.Get("/static/busy.js", serveAsset(busy.JS(), "text/javascript; charset=utf-8"))
156}
157