v0.17.0 ab8e178

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}
24
25// RefItem is a branch or tag in the ref switcher.
26type RefItem struct {
27	Name    string
28	Href    string
29	Current bool
30}
31
32// CmdItem is one target of the ":" command line.
33type CmdItem struct{ Kind, Label, Href string }
34
35// Layout is the input of the page shell.
36type Layout struct {
37	Title string
38	// Owner is the owner's name (ERMITE_OWNER), shown when signed in.
39	Owner     string
40	Version   string
41	SourceURL string
42	Assets    Assets
43	Crumbs    []Crumb
44	Ref       string // ref shown in the header, "" outside a repo view
45	Short     string // short sha shown after the ref
46	Sections  []Section
47	Repo      string
48	SHA       string // full sha of the ref, for the permalink key
49	RefPath   string // the URL segment that `y` rewrites: the ref name
50	Heads     []RefItem
51	Tags      []RefItem
52	Cmd       []CmdItem
53	HasRail   bool
54	// Lede is a line above the content and the rail, so both start level.
55	Lede string
56	// Live connects the page to the event stream (/-/events).
57	Live bool
58	// LiveURL is the stream the page follows, with its query.
59	LiveURL string
60	// PathsURL is the list of the file paths of the commit the page shows
61	// (/{repo}/paths/{sha}) and BlobBase the URL its file links start with;
62	// both are "" when the page has no commit to search.
63	PathsURL, BlobBase string
64	// Passkeys tells that the passkey routes exist: the header then links to
65	// them.
66	Passkeys bool
67}
68
69// Link is a plain label + href pair.
70type Link struct{ Label, Href string }
71
72// HomeRow is one repository in the home list.
73type HomeRow struct {
74	ID       string
75	Name     string
76	Href     string
77	Desc     string
78	Pushed   string
79	PushedAt string // RFC 3339, "" when never pushed
80	Branch   string
81	Tag      string
82	Cursor   bool
83	// Fresh marks a row that a push just updated (live updates only).
84	Fresh bool
85}
86
87// SortCol is a column header of the home list; it links to its sort order.
88type SortCol struct {
89	Label string
90	Href  string
91	Dir   string // "ascending" | "descending" | "none"
92	Mark  string
93	Class string
94}
95
96// HomePage is the repository list.
97type HomePage struct {
98	Cols []SortCol
99	Rows []HomeRow
100}
101
102// Fact is one key/value row of the facts block.
103type Fact struct {
104	Key, Val, ID, Time string
105}
106
107// Clone is a block of copyable shell lines, one [copy] button per line.
108type Clone struct {
109	ID    string
110	Lines []string
111}
112
113// Heading is one README outline entry.
114type Heading struct {
115	Level int
116	ID    string
117	Text  string
118}
119
120// Readme is a rendered README. HTML comes from the Markdown renderer (raw
121// HTML dropped, URLs filtered) or is escaped plain text.
122type Readme struct {
123	Name string
124	HTML template.HTML
125	// Note replaces the content when the file is not rendered (too large).
126	Note string
127}
128
129// CommitRow is one commit in the commit table.
130type CommitRow struct {
131	ID       string
132	Short    string
133	Subject  string
134	CHref    string
135	Author   string
136	When     string
137	WhenAt   string
138	Merge    bool
139	Branches []string
140	Tags     []string
141	Cursor   bool
142	// Checks is the combined state of the CI checks of the commit; empty when
143	// it has none.
144	Checks ChecksSummary
145}
146
147// SummaryPage is the repository summary.
148type SummaryPage struct {
149	Facts   []Fact
150	Clone   Clone
151	Recent  []CommitRow
152	Readme  *Readme
153	Outline []Heading
154	AllHref string
155	// Latest is the newest tag, nil when the repository has none.
156	Latest *LatestTag
157	// Actions is the recent runs of the rail, nil when the viewer cannot read
158	// CI (or the server runs none).
159	Actions *RecentActions
160}
161
162// RecentActions is the "Recent actions" block of the summary rail: the newest
163// runs. With no run the block is in the page but hidden, so that the first
164// run reaches it live.
165type RecentActions struct {
166	Runs    []RunRow
167	AllHref string
168}
169
170// LatestTag is the newest tag of a repository, shown in the summary rail.
171// Name is empty when there are too many tags to date them; Count and
172// RefsHref still lead to the full list.
173type LatestTag struct {
174	Name, Href, Subject, When, WhenAt string
175	Count                             int
176	RefsHref                          string
177}
178
179// RefRow is a branch or a tag in the refs table.
180type RefRow struct {
181	Name, Href, Short, CHref, Subject, When, WhenAt string
182	Default, Cursor                                 bool
183	// Checks is the combined state of the CI checks of the commit.
184	Checks ChecksSummary
185}
186
187// RefsPage lists the branches and tags of a repository.
188type RefsPage struct {
189	Branches []RefRow
190	Tags     []RefRow
191	Latest   string
192	Default  string
193	// Note says the lists were cut.
194	Note string
195}
196
197// StatePage is a 404, 500 or empty-repository state.
198type StatePage struct {
199	Code  string // "404", "500", "empty"
200	Title string
201	Lines []string
202	Clone *Clone
203	Back  []Link
204}
205
206// LoginPage is the confirmation of a login link: a form with one button.
207type LoginPage struct {
208	Title  string
209	Lines  []string
210	Action string // where the form posts
211	Button string
212}
213
214// PasskeyLoginPage is the sign-in page: one button the script drives.
215type PasskeyLoginPage struct {
216	Title  string
217	Lines  []string
218	Button string
219	// Begin and Finish are the endpoints the script posts to.
220	Begin, Finish string
221}
222
223// PasskeyRow is one passkey on the passkeys page.
224type PasskeyRow struct {
225	Name string
226	// Created and LastUsed are relative ("3d ago"); the At fields are the
227	// RFC 3339 forms, "" when never.
228	Created, CreatedAt   string
229	LastUsed, LastUsedAt string
230	Synced               bool
231	// Remove is where the remove form posts.
232	Remove string
233}
234
235// PasskeysPage lists the passkeys and adds one.
236type PasskeysPage struct {
237	Rows          []PasskeyRow
238	Begin, Finish string
239	// Full tells that no more passkeys can be added.
240	Full bool
241	Max  int
242}

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