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

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 2

Tags 45

↑↓ moveenter openesc close