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 API messages.
9
10// Crumb is one segment of the path in the top bar.
11type Crumb struct {
12 Label string
13 Href string
14 Current bool
15}
16
17// Section is a repository section in the top bar, reached by its key.
18type Section struct {
19 Key string // mnemonic key
20 Post string // rest of the label after the key
21 Href string
22 Current bool
23}
24
25// Status is the content of the bottom bar.
26type Status struct {
27 Mode string // "home", "summary", "refs"…
28 Context string // "3 repos · sort push ▼"
29 Hints string // "j/k move · enter open · ? help"
30 Cursor bool // show the row cursor position n/N
31 Blob bool // show the selected line range
32 Count int // number of rows under the cursor
33}
34
35// RefItem is a branch or tag in the ref switcher.
36type RefItem struct {
37 Name string
38 Href string
39 Current bool
40}
41
42// CmdItem is one target of the ":" command line.
43type CmdItem struct{ Kind, Label, Href string }
44
45// Layout is the input of the page shell.
46type Layout struct {
47 Title string
48 Instance string
49 Version string
50 SourceURL string
51 Assets Assets
52 Crumbs []Crumb
53 Ref string // ref shown in the top bar, "" outside a repo view
54 Short string // short sha shown after the ref
55 Sections []Section
56 Status Status
57 Repo string
58 SHA string // full sha of the ref, for the permalink key
59 RefPath string // the URL segment that `y` rewrites: the ref name
60 Heads []RefItem
61 Tags []RefItem
62 Cmd []CmdItem
63 HasRail bool
64 RailSum string // the rail as one line when it folds above the content (< 1100px)
65 Read bool // prose page: content capped at the reading measure
66 // Live connects the status bar to the event stream (/-/events).
67 Live bool
68 // LiveURL is the stream the page follows, with its query.
69 LiveURL string
70}
71
72// Link is a plain label + href pair.
73type Link struct{ Label, Href string }
74
75// HomeRow is one repository in the home list.
76type HomeRow struct {
77 ID string
78 Name string
79 Href string
80 Desc string
81 Pushed string
82 PushedAt string // RFC 3339, "" when never pushed
83 Branch string
84 Tag string
85 Cursor bool
86 // Fresh marks a row that a push just updated (live updates only).
87 Fresh bool
88}
89
90// SortCol is a column header of the home list; it links to its sort order.
91type SortCol struct {
92 Label string
93 Href string
94 Dir string // "ascending" | "descending" | "none"
95 Mark string
96 Class string
97}
98
99// HomePage is the repository list.
100type HomePage struct {
101 Cols []SortCol
102 Rows []HomeRow
103}
104
105// Fact is one key/value row of the facts block.
106type Fact struct {
107 Key, Val, ID, Time string
108}
109
110// Clone is a block of copyable shell lines, one [copy] button per line.
111type Clone struct {
112 ID string
113 Lines []string
114}
115
116// Heading is one README outline entry.
117type Heading struct {
118 Level int
119 ID string
120 Text string
121}
122
123// Readme is a rendered README. HTML comes from the Markdown renderer (raw
124// HTML dropped, URLs filtered) or is escaped plain text.
125type Readme struct {
126 Name string
127 HTML template.HTML
128 // Note replaces the content when the file is not rendered (too large).
129 Note string
130}
131
132// CommitRow is one commit in the commit table.
133type CommitRow struct {
134 ID string
135 Short string
136 Subject string
137 CHref string
138 Author string
139 When string
140 WhenAt string
141 Merge bool
142 Branches []string
143 Tags []string
144 Cursor bool
145}
146
147// SummaryPage is the repository summary.
148type SummaryPage struct {
149 Desc string
150 Facts []Fact
151 Clone Clone
152 Recent []CommitRow
153 Readme *Readme
154 Outline []Heading
155 AllHref string
156}
157
158// RefRow is a branch or a tag in the refs table.
159type RefRow struct {
160 Name, Href, Short, CHref, Subject, When, WhenAt string
161 Default, Cursor bool
162}
163
164// RefsPage lists the branches and tags of a repository.
165type RefsPage struct {
166 Branches []RefRow
167 Tags []RefRow
168 Latest string
169 Default string
170 // Note says the lists were cut.
171 Note string
172}
173
174// StatePage is a 404, 500 or empty-repository state.
175type StatePage struct {
176 Code string // "404", "500", "empty"
177 Title string
178 Lines []string
179 Clone *Clone
180 Back []Link
181}
182
183// LoginPage is the confirmation of a login link: a form with one button.
184type LoginPage struct {
185 Title string
186 Lines []string
187 Action string // where the form posts
188 Button string
189}