v0.23.0 333c710

view.go RawHistoryFolder

1// SPDX-License-Identifier: AGPL-3.0-or-later
2
3package web
4
5import "html/template"
6
7// View models handed to the templ components. Components only loop and
8// branch on these; the handlers build them from the use case results.
9
10// Crumb is one segment of the path in the header.
11type Crumb struct {
12	Label   string
13	Href    string
14	Current bool
15}
16
17// Section is a repository tab under the header, reached by its key.
18type Section struct {
19	Key     string // mnemonic key
20	Label   string
21	Href    string
22	Current bool
23	// Count is shown after the label when it is not empty: the open merge
24	// requests.
25	Count string
26}
27
28// RefItem is a branch or tag in the ref switcher.
29type RefItem struct {
30	Name    string
31	Href    string
32	Current bool
33}
34
35// CmdItem is one target of the ":" command line.
36type CmdItem struct{ Kind, Label, Href string }
37
38// Layout is the input of the page shell.
39type Layout struct {
40	Title string
41	// Owner is the owner's name (ERMITE_OWNER), shown when signed in.
42	Owner     string
43	Version   string
44	SourceURL string
45	Assets    Assets
46	Crumbs    []Crumb
47	Ref       string // ref shown in the header, "" outside a repo view
48	Short     string // short sha shown after the ref
49	Sections  []Section
50	Repo      string
51	SHA       string // full sha of the ref, for the permalink key
52	RefPath   string // the URL segment that `y` rewrites: the ref name
53	Heads     []RefItem
54	Tags      []RefItem
55	Cmd       []CmdItem
56	HasRail   bool
57	// Lede is a line above the content and the rail, so both start level.
58	Lede string
59	// Live connects the page to the event stream (/-/events).
60	Live bool
61	// LiveURL is the stream the page follows, with its query.
62	LiveURL string
63	// PathsURL is the list of the file paths of the commit the page shows
64	// (/{repo}/paths/{sha}) and BlobBase the URL its file links start with;
65	// both are "" when the page has no commit to search.
66	PathsURL, BlobBase string
67	// Passkeys tells that the passkey routes exist: the header then links to
68	// them.
69	Passkeys bool
70	// MR loads the script of the merge request page (mr.js).
71	MR bool
72}
73
74// Link is a plain label + href pair.
75type Link struct{ Label, Href string }
76
77// HomeRow is one repository in the home list.
78type HomeRow struct {
79	ID   string
80	Name string
81	Href string
82	Desc string
83	// Active is when the repository last changed (its last push or merge),
84	// ActiveAt its RFC 3339 form, "" when it never got a commit.
85	Active   string
86	ActiveAt string
87	Cursor   bool
88	// Stats are the figures of the row; nil when they could not be read.
89	Stats *HomeStats
90	// Private marks a private repository; only set for a signed-in visitor.
91	Private bool
92	// Fresh marks a row that a push just updated (live updates only).
93	Fresh bool
94	// Commits are the newest of the default branch. NoCommits says there is
95	// none (never pushed, or an empty branch); a failed read says nothing.
96	Commits   []CommitRow
97	NoCommits bool
98	// CI is the latest run of the default branch, nil when there is none to
99	// show.
100	CI *HomeCI
101}
102
103// HomeStats are the figures of a home row: commits of the default branch,
104// those of the last 30 days, and the latest tag.
105type HomeStats struct {
106	Commits, Recent string
107	// Tag is the latest tag, "" without tags; TagHref links its tree, TagWhen
108	// tells when it was made.
109	Tag, TagHref, TagWhen string
110}
111
112// HomeCI is the state of the latest run of the default branch of a repository.
113type HomeCI struct {
114	Href  string
115	Kind  string // the mark: ok, bad, running, queued, skipped, cancelled
116	Label string // the word next to it
117	Title string
118}
119
120// SortLink is one way to order the home list; it links to that order.
121type SortLink struct {
122	Label string
123	Href  string
124	Mark  string // "▲" or "▼" on the current order, "" otherwise
125	// State says the current direction and what the link does, for screen
126	// readers (the mark is hidden from them); "" off the current order.
127	State string
128}
129
130// HomePage is the repository list.
131type HomePage struct {
132	Sorts []SortLink
133	Rows  []HomeRow
134}
135
136// Fact is one key/value row of the facts block.
137type Fact struct {
138	Key, Val, ID, Time string
139}
140
141// Clone is a block of copyable shell lines, one [copy] button per line.
142type Clone struct {
143	ID    string
144	Lines []string
145}
146
147// Heading is one README outline entry.
148type Heading struct {
149	Level int
150	ID    string
151	Text  string
152}
153
154// Readme is a rendered README. HTML comes from the Markdown renderer (raw
155// HTML dropped, URLs filtered) or is escaped plain text.
156type Readme struct {
157	Name string
158	HTML template.HTML
159	// Note replaces the content when the file is not rendered (too large).
160	Note string
161}
162
163// CommitRow is one commit in the commit table.
164type CommitRow struct {
165	ID       string
166	Short    string
167	Subject  string
168	CHref    string
169	Author   string
170	When     string
171	WhenAt   string
172	Merge    bool
173	Branches []string
174	Tags     []string
175	Cursor   bool
176	// Checks is the combined state of the CI checks of the commit; empty when
177	// it has none.
178	Checks ChecksSummary
179}
180
181// SummaryPage is the repository summary.
182type SummaryPage struct {
183	Facts   []Fact
184	Clone   Clone
185	Recent  []CommitRow
186	Readme  *Readme
187	Outline []Heading
188	AllHref string
189	// Latest is the newest tag, nil when the repository has none.
190	Latest *LatestTag
191	// Actions is the recent runs of the rail, nil when the viewer cannot read
192	// CI (or the server runs none).
193	Actions *RecentActions
194}
195
196// RecentActions is the "Recent actions" block of the summary rail: the newest
197// runs. With no run the block is in the page but hidden, so that the first
198// run reaches it live.
199type RecentActions struct {
200	Runs    []RunRow
201	AllHref string
202}
203
204// LatestTag is the newest tag of a repository, shown in the summary rail.
205// Name is empty when there are too many tags to date them; Count and
206// RefsHref still lead to the full list.
207type LatestTag struct {
208	Name, Href, Subject, When, WhenAt string
209	Count                             int
210	RefsHref                          string
211}
212
213// RefRow is a branch or a tag in the refs table.
214type RefRow struct {
215	Name, Href, Short, CHref, Subject, When, WhenAt string
216	Default, Cursor                                 bool
217	// Checks is the combined state of the CI checks of the commit.
218	Checks ChecksSummary
219}
220
221// RefsPage lists the branches and tags of a repository.
222type RefsPage struct {
223	Branches []RefRow
224	Tags     []RefRow
225	Latest   string
226	Default  string
227	// Note says the lists were cut.
228	Note string
229}
230
231// StatePage is a 404, 500 or empty-repository state.
232type StatePage struct {
233	Code  string // "404", "500", "empty"
234	Title string
235	Lines []string
236	Clone *Clone
237	Back  []Link
238}
239
240// LoginPage is the confirmation of a login link: a form with one button.
241type LoginPage struct {
242	Title  string
243	Lines  []string
244	Action string // where the form posts
245	Button string
246}
247
248// PasskeyLoginPage is the sign-in page: one button the script drives.
249type PasskeyLoginPage struct {
250	Title  string
251	Lines  []string
252	Button string
253	// Begin and Finish are the endpoints the script posts to.
254	Begin, Finish string
255}
256
257// PasskeyRow is one passkey on the passkeys page.
258type PasskeyRow struct {
259	Name string
260	// Created and LastUsed are relative ("3d ago"); the At fields are the
261	// RFC 3339 forms, "" when never.
262	Created, CreatedAt   string
263	LastUsed, LastUsedAt string
264	Synced               bool
265	// Remove is where the remove form posts.
266	Remove string
267}
268
269// PasskeysPage lists the passkeys and adds one.
270type PasskeysPage struct {
271	Rows          []PasskeyRow
272	Begin, Finish string
273	// Full tells that no more passkeys can be added.
274	Full bool
275	Max  int
276}

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