detached aa7340c

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

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 3

Tags 45

↑↓ moveenter openesc close