detached 83e495f

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

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 4

Tags 45

↑↓ moveenter openesc close