v0.35.2 80d5067

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	// Lazy loads the loader of the collapsed and lazy files of a diff
71	// (lazy.js): the commit, compare and merge request pages.
72	Lazy bool
73	// MR loads the script of the merge request page (mr.js).
74	MR bool
75	// IssueForm loads the script of the public issue form (issue-form.js).
76	IssueForm bool
77	// Inbox is the button to the owner's inbox, next to the logo; set on the
78	// home page only, for the signed-in owner.
79	Inbox *InboxButton
80}
81
82// Link is a plain label + href pair.
83type Link struct{ Label, Href string }
84
85// HomeRow is one repository in the home list.
86type HomeRow struct {
87	Release *LatestRelease
88	License *LicenseBadge
89	ID      string
90	Name    string
91	Href    string
92	Desc    string
93	// Topics classify the repository, as on GitHub.
94	Topics []string
95	// Active is when the repository last changed (its last push or merge),
96	// ActiveAt its RFC 3339 form, "" when it never got a commit.
97	Active   string
98	ActiveAt string
99	Cursor   bool
100	// Stats are the figures of the row; nil when they could not be read.
101	Stats *HomeStats
102	// Private marks a private repository; only set for a signed-in visitor.
103	Private bool
104	// Fresh marks a row that activity just updated (live updates only).
105	Fresh bool
106	// Commits are the newest of the default branch. NoCommits says there is
107	// none (never pushed, or an empty branch); a failed read says nothing.
108	Commits   []CommitRow
109	NoCommits bool
110	// CI is the latest run of the default branch, nil when there is none to
111	// show.
112	CI *HomeCI
113}
114
115// HomeStats are the figures of a home row: commits of the default branch,
116// those of the last 30 days, and the latest tag.
117type HomeStats struct {
118	Commits, Recent string
119	// Tag is the latest tag, "" without tags; TagHref links its tree, TagWhen
120	// tells when it was made.
121	Tag, TagHref, TagWhen string
122	// Pulse is the activity curve; nil when it could not be drawn.
123	Pulse *Heartbeat
124}
125
126// HomeCI is the state of the latest run of the default branch of a repository.
127type HomeCI struct {
128	Href  string
129	Kind  string // the mark: ok, bad, running, queued, skipped, cancelled
130	Label string // the word next to it
131	Title string
132}
133
134// SortLink is one way to order the home list; it links to that order.
135type SortLink struct {
136	Label string
137	Href  string
138	Mark  string // "▲" or "▼" on the current order, "" otherwise
139	// State says the current direction and what the link does, for screen
140	// readers (the mark is hidden from them); "" off the current order.
141	State string
142}
143
144// HomePage is the repository list.
145type HomePage struct {
146	Sort  string
147	Desc  bool
148	Sorts []SortLink
149	Rows  []HomeRow
150}
151
152// InboxButton is the link to the inbox with the number of open items; Count is
153// negative when it could not be read.
154type InboxButton struct {
155	Href  string
156	Count int
157}
158
159// Fact is one key/value row of the facts block.
160type Fact struct {
161	Key, Val, ID, Time string
162}
163
164// Clone is a block of copyable shell lines, one [copy] button per line.
165type Clone struct {
166	ID    string
167	Lines []string
168}
169
170// Heading is one README outline entry.
171type Heading struct {
172	Level int
173	ID    string
174	Text  string
175}
176
177// Readme is a rendered README. HTML comes from the Markdown renderer (raw
178// HTML dropped, URLs filtered) or is escaped plain text.
179type Readme struct {
180	Name string
181	HTML template.HTML
182	// Note replaces the content when the file is not rendered (too large).
183	Note string
184}
185
186// CommitRow is one commit in the commit table.
187type CommitRow struct {
188	ID       string
189	Short    string
190	Subject  string
191	CHref    string
192	Author   string
193	When     string
194	WhenAt   string
195	Merge    bool
196	Branches []string
197	Tags     []string
198	Cursor   bool
199	// Checks is the combined state of the CI checks of the commit; empty when
200	// it has none.
201	Checks ChecksSummary
202	// Sig is the signature badge, nil for an unchecked or unsigned commit.
203	Sig *SignatureBadge
204}
205
206// DocTab links to a root document on the summary.
207type DocTab struct {
208	Name, Href string
209	Current    bool
210}
211
212// SummaryPage is the repository summary.
213type SummaryPage struct {
214	Docs    []DocTab
215	License *LicenseBadge
216	Mirror  *MirrorBadge
217	Facts   []Fact
218	Clone   Clone
219	Recent  []CommitRow
220	Readme  *Readme
221	Outline []Heading
222	AllHref string
223	// Latest is the newest tag, nil when the repository has none.
224	Latest  *LatestTag
225	Release *LatestRelease
226	// Actions is the recent runs of the rail, nil when the viewer cannot read
227	// CI (or the server runs none).
228	Actions *RecentActions
229}
230
231// LatestRelease is the published release selected as Latest by the release service.
232type LatestRelease struct {
233	Tag, Href, When, WhenAt, AllHref string
234}
235
236// RecentActions is the "Recent actions" block of the summary rail: the newest
237// runs. With no run the block is in the page but hidden, so that the first
238// run reaches it live.
239type RecentActions struct {
240	Runs    []RunRow
241	AllHref string
242}
243
244// LatestTag is the newest tag of a repository, shown in the summary rail.
245// Name is empty when there are too many tags to date them; Count and
246// RefsHref still lead to the full list.
247type LatestTag struct {
248	Name, Href, Subject, When, WhenAt string
249	Count                             int
250	RefsHref                          string
251}
252
253// RefRow is a branch or a tag in the refs table.
254type RefRow struct {
255	Name, Href, Short, CHref, Subject, When, WhenAt string
256	Default, Cursor                                 bool
257	// Checks is the combined state of the CI checks of the commit.
258	Checks ChecksSummary
259}
260
261// RefsPage lists the branches and tags of a repository.
262type RefsPage struct {
263	Branches []RefRow
264	Tags     []RefRow
265	Latest   string
266	Default  string
267	// Note says the lists were cut.
268	Note string
269}
270
271// StatePage is a 404, 500 or empty-repository state.
272type StatePage struct {
273	Code  string // "404", "500", "empty"
274	Title string
275	Lines []string
276	Clone *Clone
277	Back  []Link
278}
279
280// LoginPage is the confirmation of a login link: a form with one button.
281type LoginPage struct {
282	Title  string
283	Lines  []string
284	Action string // where the form posts
285	Button string
286}
287
288// PasskeyLoginPage is the sign-in page: one button the script drives.
289type PasskeyLoginPage struct {
290	Title  string
291	Lines  []string
292	Button string
293	// Begin and Finish are the endpoints the script posts to.
294	Begin, Finish string
295}
296
297// PasskeyRow is one passkey on the passkeys page.
298type PasskeyRow struct {
299	Name string
300	// Created and LastUsed are relative ("3d ago"); the At fields are the
301	// RFC 3339 forms, "" when never.
302	Created, CreatedAt   string
303	LastUsed, LastUsedAt string
304	Synced               bool
305	// Remove is where the remove form posts.
306	Remove string
307}
308
309// PasskeysPage lists the passkeys and adds one.
310type PasskeysPage struct {
311	Rows          []PasskeyRow
312	Begin, Finish string
313	// Full tells that no more passkeys can be added.
314	Full bool
315	Max  int
316}

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