detached 98d36bf

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.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 l.Inbox != nil {
84				<a
85					class="btn inbox-btn"
86					href={ templ.SafeURL(l.Inbox.Href) }
87					title="inbox"
88				>
89					<span class="ico i-mailbox" aria-hidden="true"></span>
90					Inbox
91					if l.Inbox.Count >= 0 {
92						<span class="count">{ itoa(l.Inbox.Count) }</span>
93					}
94				</a>
95			}
96			if len(l.Crumbs) > 0 {
97				<nav class="crumbs" aria-label="Path">
98					<ol>
99						for _, c := range l.Crumbs {
100							<li>
101								if c.Href != "" {
102									<a
103										href={ templ.SafeURL(c.Href) }
104										if c.Current {
105											aria-current="page"
106										}
107									>{ c.Label }</a>
108								} else {
109									<span
110										if c.Current {
111											aria-current="page"
112										}
113									>{ c.Label }</span>
114								}
115							</li>
116						}
117					</ol>
118				</nav>
119			}
120			<div class="hdr-acts">
121				if l.Ref != "" {
122					<a
123						class="btn ref"
124						href={ templ.SafeURL(repoHref(l.Repo, "refs")) }
125						data-fire="refs"
126						aria-keyshortcuts="b"
127						title="switch branch or tag (b)"
128					>
129						<span class="ico i-branch" aria-hidden="true"></span>
130						<span class="ref-name">{ l.Ref }</span>
131						<span class="sha">{ l.Short }</span>
132					</a>
133				}
134				<button
135					type="button"
136					class="btn search"
137					data-js
138					aria-haspopup="dialog"
139					aria-controls="panel-cmd"
140					aria-keyshortcuts="Control+K :"
141					title="go to a section, ref, file or repo (ctrl k or :)"
142					data-fire="cmd"
143				>
144					<span class="ico i-search" aria-hidden="true"></span>
145					<span class="search-label">Go to…</span>
146					<kbd aria-hidden="true">ctrl k</kbd>
147				</button>
148				if SignedIn(ctx) {
149					<form class="owner" method="post" action="/-/logout">
150						<span class="owner-badge" title="signed in as the owner"><span class="ico i-user" aria-hidden="true"></span>{ l.Owner }</span>
151						if l.Passkeys {
152							<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>
153						}
154						<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>
155					</form>
156				} else if l.Passkeys {
157					<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>
158				}
159			</div>
160		</div>
161		if len(l.Sections) > 0 {
162			<nav class="tabs" aria-label="Sections">
163				<ul>
164					for _, s := range l.Sections {
165						<li>
166							<a
167								href={ templ.SafeURL(s.Href) }
168								data-key={ s.Key }
169								aria-keyshortcuts={ s.Key }
170								if s.Current {
171									aria-current="page"
172								}
173							>
174								{ s.Label }
175								if s.Count != "" {
176									<span class="count">{ s.Count }<span class="sr">{ " open" }</span></span>
177								}
178								<kbd aria-hidden="true">{ s.Key }</kbd>
179							</a>
180						</li>
181					}
182				</ul>
183			</nav>
184		}
185	</header>
186}
187
188// Footer is the version and the link to the source of the running version,
189// which the AGPL §13 asks every user of the service to be offered.
190templ Footer(l Layout) {
191	<footer class="foot">
192		<span>ermite { l.Version }</span>
193		<a href={ templ.SafeURL(l.SourceURL) } rel="noopener" title="source of this version (AGPL-3.0-or-later)">source</a>
194		<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>
195	</footer>
196}
197
198// Hint is the floating badge at the bottom right. It shows only what the
199// keyboard just did or what needs attention: the row position while j/k
200// move, the selected lines of a file, a flash message (permalink copied) and
201// a lost event stream. Empty, it takes no room.
202templ Hint(l Layout) {
203	<div class="hint" role="status" aria-live="polite">
204		<span class="hint-nav" :text="document.body.dataset.nav || ''"></span>
205		<span class="hint-sel" :text="document.body.dataset.sel ? document.body.dataset.sel + ' · y permalink' : ''"></span>
206		<span class="hint-flash" :text="document.body.dataset.flash || ''"></span>
207		@Live(l)
208	</div>
209}

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