shell.templ RawHistoryFolder
1// SPDX-License-Identifier: AGPL-3.0-or-later
2
3package web
4
5// Shell is the page: head, the header, the work area (content and rail), the
6// footer, the hint badge, the overlays and the key map. The content is the
7// children.
8templ Shell(l Layout, rail templ.Component) {
9 <!DOCTYPE html>
10 <html lang="en">
11 <head>
12 <meta charset="utf-8"/>
13 <meta name="viewport" content="width=device-width, initial-scale=1"/>
14 <meta name="color-scheme" content="light dark"/>
15 <title>{ l.Title }</title>
16 <meta name="theme-color" media="(prefers-color-scheme: light)" content="#ffffff"/>
17 <meta name="theme-color" media="(prefers-color-scheme: dark)" content="#0c0c0c"/>
18 <meta name="apple-mobile-web-app-title" content="ermite"/>
19 <link rel="icon" type="image/svg+xml" href={ templ.SafeURL(l.Assets.Icon) }/>
20 <link rel="apple-touch-icon" href={ templ.SafeURL(l.Assets.AppleIcon) }/>
21 <link rel="manifest" href={ templ.SafeURL(l.Assets.Manifest) }/>
22 <link rel="preload" href={ templ.SafeURL(l.Assets.Font) } as="font" type="font/woff2" crossorigin/>
23 <link rel="stylesheet" href={ templ.SafeURL(l.Assets.CSS) }/>
24 <meta name="htmx-config" content='{"history":false,"includeIndicatorCSS":false,"extensions":"sse, hx-live"}'/>
25 <script src={ l.Assets.HTMX } defer></script>
26 <script src={ l.Assets.Live } defer></script>
27 <script src={ l.Assets.SSE } defer></script>
28 <script src={ l.Assets.App } defer></script>
29 <script src={ l.Assets.Files } defer></script>
30 <script src={ l.Assets.Passkey } defer></script>
31 <script src={ l.Assets.Log } defer></script>
32 if l.MR {
33 <script src={ l.Assets.MR } defer></script>
34 }
35 </head>
36 <body
37 data-ref={ l.RefPath }
38 data-sha={ l.SHA }
39 data-sel=""
40 data-nav=""
41 if l.PathsURL != "" {
42 data-paths={ l.PathsURL }
43 data-blob={ l.BlobBase }
44 }
45 >
46 <a class="skip" href="#main">skip to content</a>
47 @Header(l)
48 <div class={ "work", templ.KV("has-rail", l.HasRail && rail != nil) }>
49 if l.Lede != "" {
50 <section class="work-lede" aria-label="Description"><p class="lede">{ l.Lede }</p></section>
51 }
52 <main id="main" tabindex="-1">
53 { children... }
54 </main>
55 if l.HasRail && rail != nil {
56 <aside class="rail" aria-label="Context">
57 @rail
58 </aside>
59 }
60 </div>
61 @Footer(l)
62 @Hint(l)
63 @OverlayHelp(l.MR)
64 @OverlayRefs(l)
65 @OverlayCmd(l.Cmd)
66 @Keys()
67 </body>
68 </html>
69}
70
71// Header is the page header: the logo (home), the path, the ref switcher,
72// the "go to" palette and the owner; inside a repository, the tabs below.
73templ Header(l Layout) {
74 <header class="hdr">
75 <div class="hdr-top">
76 <a class="brand" href="/" data-g="h" aria-label="home" title="home (g h)">
77 <span class="brand-mark" aria-hidden="true"></span>
78 </a>
79 if len(l.Crumbs) > 0 {
80 <nav class="crumbs" aria-label="Path">
81 <ol>
82 for _, c := range l.Crumbs {
83 <li>
84 if c.Href != "" {
85 <a
86 href={ templ.SafeURL(c.Href) }
87 if c.Current {
88 aria-current="page"
89 }
90 >{ c.Label }</a>
91 } else {
92 <span
93 if c.Current {
94 aria-current="page"
95 }
96 >{ c.Label }</span>
97 }
98 </li>
99 }
100 </ol>
101 </nav>
102 }
103 <div class="hdr-acts">
104 if l.Ref != "" {
105 <a
106 class="btn ref"
107 href={ templ.SafeURL(repoHref(l.Repo, "refs")) }
108 data-fire="refs"
109 aria-keyshortcuts="b"
110 title="switch branch or tag (b)"
111 >
112 <span class="ico i-branch" aria-hidden="true"></span>
113 <span class="ref-name">{ l.Ref }</span>
114 <span class="sha">{ l.Short }</span>
115 </a>
116 }
117 <button
118 type="button"
119 class="btn search"
120 data-js
121 aria-haspopup="dialog"
122 aria-controls="panel-cmd"
123 aria-keyshortcuts="Control+K :"
124 title="go to a section, ref, file or repo (ctrl k or :)"
125 data-fire="cmd"
126 >
127 <span class="ico i-search" aria-hidden="true"></span>
128 <span class="search-label">Go to…</span>
129 <kbd aria-hidden="true">ctrl k</kbd>
130 </button>
131 if SignedIn(ctx) {
132 <form class="owner" method="post" action="/-/logout">
133 <span class="owner-badge" title="signed in as the owner"><span class="ico i-user" aria-hidden="true"></span>{ l.Owner }</span>
134 if l.Passkeys {
135 <a class="btn icon" href="/-/passkeys" aria-label="Passkeys" title="passkeys: add or remove the passkeys that sign you in"><span class="ico i-key" aria-hidden="true"></span></a>
136 }
137 <button type="submit" class="btn icon" aria-label="Sign out" title="sign out of this browser"><span class="ico i-log-out" aria-hidden="true"></span></button>
138 </form>
139 } else if l.Passkeys {
140 <a class="btn icon" href="/-/login" aria-label="Sign in" title="sign in with a passkey"><span class="ico i-log-in" aria-hidden="true"></span></a>
141 }
142 </div>
143 </div>
144 if len(l.Sections) > 0 {
145 <nav class="tabs" aria-label="Sections">
146 <ul>
147 for _, s := range l.Sections {
148 <li>
149 <a
150 href={ templ.SafeURL(s.Href) }
151 data-key={ s.Key }
152 aria-keyshortcuts={ s.Key }
153 if s.Current {
154 aria-current="page"
155 }
156 >
157 { s.Label }
158 if s.Count != "" {
159 <span class="count">{ s.Count }<span class="sr">{ " open" }</span></span>
160 }
161 <kbd aria-hidden="true">{ s.Key }</kbd>
162 </a>
163 </li>
164 }
165 </ul>
166 </nav>
167 }
168 </header>
169}
170
171// Footer is the version and the link to the source of the running version,
172// which the AGPL §13 asks every user of the service to be offered.
173templ Footer(l Layout) {
174 <footer class="foot">
175 <span>ermite { l.Version }</span>
176 <a href={ templ.SafeURL(l.SourceURL) } rel="noopener" title="source of this version (AGPL-3.0-or-later)">source</a>
177 <button type="button" class="foot-keys" data-js data-fire="help" aria-haspopup="dialog" aria-controls="panel-help" aria-keyshortcuts="?"><kbd aria-hidden="true">?</kbd> keyboard shortcuts</button>
178 </footer>
179}
180
181// Hint is the floating badge at the bottom right. It shows only what the
182// keyboard just did or what needs attention: the row position while j/k
183// move, the selected lines of a file, a flash message (permalink copied) and
184// a lost event stream. Empty, it takes no room.
185templ Hint(l Layout) {
186 <div class="hint" role="status" aria-live="polite">
187 <span class="hint-nav" :text="document.body.dataset.nav || ''"></span>
188 <span class="hint-sel" :text="document.body.dataset.sel ? document.body.dataset.sel + ' · y permalink' : ''"></span>
189 <span class="hint-flash" :text="document.body.dataset.flash || ''"></span>
190 @Live(l)
191 </div>
192}