v0.31.0 d5e0505

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

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