v0.11.0 0633e44

tree.templ RawHistoryFolder

1// SPDX-License-Identifier: AGPL-3.0-or-later
2
3package web
4
5// Tree is a directory: the file finder, the entries with their last commit, the
6// notes on what is left out, and the README of the directory below.
7templ Tree(l Layout, p TreePage) {
8	@Shell(l, nil) {
9		<div class="filter">
10			<label for="finder-q" class="sr">find a file</label>
11			<input
12				id="finder-q"
13				type="search"
14				data-filter
15				role="combobox"
16				aria-autocomplete="list"
17				aria-controls="finder-list"
18				aria-expanded="false"
19				placeholder="Find a file…"
20				autocomplete="off"
21				spellcheck="false"
22				hx-on:focus="ermiteFinder.load()"
23				hx-on:input="ermiteFinder.input(this)"
24				hx-on:keydown="ermiteFinder.key(this, event)"
25			/>
26		</div>
27		<div id="finder" hidden>
28			<p id="finder-status" class="dim" aria-live="polite"></p>
29			<ul id="finder-list" class="cmd-list" role="listbox" aria-label="Files"></ul>
30		</div>
31		<div id="tree-view">
32			<table class="list tree" aria-label="Entries">
33				<thead>
34					<tr><th class="cur"></th><th class="c-kind"></th><th class="c-name">name</th><th class="c-size">size</th><th class="c-sub">last commit</th><th class="c-who">author</th><th class="c-when">date</th></tr>
35				</thead>
36				<tbody id="tree-rows" data-rows hx-on:click="ermiteTree.click(event)">
37					@TreeRows(p)
38				</tbody>
39			</table>
40			if len(p.Rows) == 0 {
41				<p class="lede dim">this directory is empty.</p>
42			}
43			for _, n := range p.Notes {
44				<p class="note">{ n }</p>
45			}
46			if p.Readme != nil {
47				@ReadmeCard(*p.Readme)
48			}
49		</div>
50	}
51}
52
53// TreeRows is the rows of a directory alone: what files.js inserts under a
54// directory it opens in place. When the directory has more entries than are
55// listed, the last row links to its page.
56templ TreeRows(p TreePage) {
57	for _, r := range p.Rows {
58		@TreeRowView(r)
59	}
60	if p.More != "" {
61		<tr class="tree-more"><td colspan="7"><a href={ templ.SafeURL(p.More) }>more entries: open the directory</a></td></tr>
62	}
63}
64
65// TreeRowView is one entry of a directory. Glyph: ▸ directory (▾ once opened
66// in place), @ symbolic link, + submodule, · file. A directory link carries
67// data-expand, the URL of its rows.
68templ TreeRowView(r TreeRow) {
69	<tr data-cursor?={ r.Cursor }>
70		<td class="cur" aria-hidden="true"></td>
71		<td class="c-kind" aria-hidden="true">{ r.Glyph }</td>
72		<td class="c-name">
73			if r.Href != "" {
74				<a
75					href={ templ.SafeURL(r.Href) }
76					if r.Expand != "" {
77						data-expand={ r.Expand }
78						aria-expanded="false"
79					}
80				>{ r.Name }</a>
81			} else {
82				{ r.Name }
83			}
84		</td>
85		<td class="c-size num dim">{ r.Size }</td>
86		<td class="c-sub dim">
87			if r.CHref != "" {
88				<a href={ templ.SafeURL(r.CHref) }>{ r.Subject }</a>
89			}
90		</td>
91		<td class="c-who dim">{ r.Author }</td>
92		<td class="c-when nowrap dim">
93			if r.WhenAt != "" {
94				<time datetime={ r.WhenAt } title={ r.WhenAt }>{ r.When }</time>
95			}
96		</td>
97	</tr>
98}

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