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.Store } defer></script>
29 <script src={ l.Assets.App } defer></script>
30 <script src={ l.Assets.Files } defer></script>
31 <script src={ l.Assets.Passkey } defer></script>
32 <script src={ l.Assets.Log } defer></script>
33 if l.MR {
34 <script src={ l.Assets.MR } defer></script>
35 }
36 </head>
37 <body
38 data-ref={ l.RefPath }
39 data-sha={ l.SHA }
40 data-sel=""
41 data-nav=""
42 if l.PathsURL != "" {
43 data-paths={ l.PathsURL }
44 data-blob={ l.BlobBase }
45 }
46 >
47 <a class="skip" href="#main">skip to content</a>
48 @Header(l)
49 <div class={ "work", templ.KV("has-rail", l.HasRail && rail != nil) }>
50 if l.Lede != "" {
51 <section class="work-lede" aria-label="Description"><p class="lede">{ l.Lede }</p></section>
52 }
53 <main id="main" tabindex="-1">
54 { children... }
55 </main>
56 if l.HasRail && rail != nil {
57 <aside class="rail" aria-label="Context">
58 @rail
59 </aside>
60 }
61 </div>
62 @Footer(l)
63 @Hint(l)
64 @OverlayHelp(l.MR)
65 @OverlayRefs(l)
66 @OverlayCmd(l.Cmd)
67 @Keys()
68 </body>
69 </html>
70}
71
72// Header is the page header: the logo (home), the path, the ref switcher,
73// the "go to" palette and the owner; inside a repository, the tabs below.
74templ Header(l Layout) {
75 <header class="hdr">
76 <div class="hdr-top">
77 <a class="brand" href="/" data-g="h" aria-label="home" title="home (g h)">
78 <span class="brand-mark" aria-hidden="true"></span>
79 </a>
80 if len(l.Crumbs) > 0 {
81 <nav class="crumbs" aria-label="Path">
82 <ol>
83 for _, c := range l.Crumbs {
84 <li>
85 if c.Href != "" {
86 <a
87 href={ templ.SafeURL(c.Href) }
88 if c.Current {
89 aria-current="page"
90 }
91 >{ c.Label }</a>
92 } else {
93 <span
94 if c.Current {
95 aria-current="page"
96 }
97 >{ c.Label }</span>
98 }
99 </li>
100 }
101 </ol>
102 </nav>
103 }
104 <div class="hdr-acts">
105 if l.Ref != "" {
106 <a
107 class="btn ref"
108 href={ templ.SafeURL(repoHref(l.Repo, "refs")) }
109 data-fire="refs"
110 aria-keyshortcuts="b"
111 title="switch branch or tag (b)"
112 >
113 <span class="ico i-branch" aria-hidden="true"></span>
114 <span class="ref-name">{ l.Ref }</span>
115 <span class="sha">{ l.Short }</span>
116 </a>
117 }
118 <button
119 type="button"
120 class="btn search"
121 data-js
122 aria-haspopup="dialog"
123 aria-controls="panel-cmd"
124 aria-keyshortcuts="Control+K :"
125 title="go to a section, ref, file or repo (ctrl k or :)"
126 data-fire="cmd"
127 >
128 <span class="ico i-search" aria-hidden="true"></span>
129 <span class="search-label">Go to…</span>
130 <kbd aria-hidden="true">ctrl k</kbd>
131 </button>
132 if SignedIn(ctx) {
133 <form class="owner" method="post" action="/-/logout">
134 <span class="owner-badge" title="signed in as the owner"><span class="ico i-user" aria-hidden="true"></span>{ l.Owner }</span>
135 if l.Passkeys {
136 <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>
137 }
138 <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>
139 </form>
140 } else if l.Passkeys {
141 <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>
142 }
143 </div>
144 </div>
145 if len(l.Sections) > 0 {
146 <nav class="tabs" aria-label="Sections">
147 <ul>
148 for _, s := range l.Sections {
149 <li>
150 <a
151 href={ templ.SafeURL(s.Href) }
152 data-key={ s.Key }
153 aria-keyshortcuts={ s.Key }
154 if s.Current {
155 aria-current="page"
156 }
157 >
158 { s.Label }
159 if s.Count != "" {
160 <span class="count">{ s.Count }<span class="sr">{ " open" }</span></span>
161 }
162 <kbd aria-hidden="true">{ s.Key }</kbd>
163 </a>
164 </li>
165 }
166 </ul>
167 </nav>
168 }
169 </header>
170}
171
172// Footer is the version and the link to the source of the running version,
173// which the AGPL §13 asks every user of the service to be offered.
174templ Footer(l Layout) {
175 <footer class="foot">
176 <span>ermite { l.Version }</span>
177 <a href={ templ.SafeURL(l.SourceURL) } rel="noopener" title="source of this version (AGPL-3.0-or-later)">source</a>
178 <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>
179 </footer>
180}
181
182// Hint is the floating badge at the bottom right. It shows only what the
183// keyboard just did or what needs attention: the row position while j/k
184// move, the selected lines of a file, a flash message (permalink copied) and
185// a lost event stream. Empty, it takes no room.
186templ Hint(l Layout) {
187 <div class="hint" role="status" aria-live="polite">
188 <span class="hint-nav" :text="document.body.dataset.nav || ''"></span>
189 <span class="hint-sel" :text="document.body.dataset.sel ? document.body.dataset.sel + ' · y permalink' : ''"></span>
190 <span class="hint-flash" :text="document.body.dataset.flash || ''"></span>
191 @Live(l)
192 </div>
193}