1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
use askama::Template;
#[derive(Template)]
#[template(path = "notice.html")]
pub(crate) struct Notice<'a> {
pub title: &'a str,
pub signed_in: bool,
pub heading: &'a str,
pub message: &'a str,
pub code: Option<String>,
pub link: Option<(&'a str, &'a str)>,
}
#[derive(Template)]
#[template(path = "masthead.html")]
pub(crate) struct Masthead<'a> {
pub owner: &'a str,
pub name: &'a str,
pub home: String,
pub visibility: Option<&'static str>,
pub protected: bool,
pub description: Option<String>,
pub addresses: Vec<(&'static str, String)>,
pub tabs: Vec<Tab>,
}
pub(crate) struct Tab {
pub href: String,
pub current: bool,
pub icon: String,
pub label: &'static str,
pub count: Option<usize>,
}
#[derive(Template)]
#[template(path = "locator.html")]
pub(crate) struct Locator<'a> {
pub branch_icon: String,
pub chevron_icon: String,
pub current: std::borrow::Cow<'a, str>,
pub branches: Vec<MenuItem<'a>>,
pub tags: Vec<MenuItem<'a>>,
pub root: Option<String>,
pub repo_name: &'a str,
pub crumbs: Vec<Crumb<'a>>,
}
pub(crate) struct MenuItem<'a> {
pub href: String,
pub current: bool,
pub name: std::borrow::Cow<'a, str>,
}
pub(crate) struct Crumb<'a> {
pub href: Option<String>,
pub name: std::borrow::Cow<'a, str>,
}
#[derive(Template)]
#[template(path = "sha-link.html")]
pub(crate) struct ShaLink<'a> {
pub href: String,
pub short: &'a str,
}
#[derive(Template)]
#[template(path = "empty.html")]
pub(crate) struct Empty<'a> {
pub title: String,
pub signed_in: bool,
pub masthead: String,
pub host: &'a str,
pub owner: &'a str,
pub name: &'a str,
}
#[derive(Template)]
#[template(path = "code.html")]
pub(crate) struct Code<'a> {
pub lines: usize,
pub selected: Option<(usize, usize)>,
pub code: &'a str,
}
impl Code<'_> {
fn is_selected(&self, n: &usize) -> bool {
self.selected.is_some_and(|(from, to)| (from..=to).contains(n))
}
}
pub(crate) struct Views {
pub preview: String,
pub code: String,
pub as_code: bool,
}
#[derive(Template)]
#[template(path = "blob.html")]
pub(crate) struct Blob<'a> {
pub title: String,
pub signed_in: bool,
pub masthead: String,
pub locator: String,
pub file_icon: String,
pub name: &'a str,
pub facts: &'a str,
pub views: Option<Views>,
pub history: String,
pub permalink: String,
pub raw: String,
pub content: &'a str,
}
pub(crate) struct TagRow<'a> {
pub name: std::borrow::Cow<'a, str>,
pub note: Option<std::borrow::Cow<'a, str>>,
pub sha_link: String,
pub when: String,
pub browse: String,
pub archive: String,
pub compare: Option<(String, String)>,
}
#[derive(Template)]
#[template(path = "tags.html")]
pub(crate) struct Tags<'a> {
pub title: String,
pub signed_in: bool,
pub masthead: String,
pub rows: Vec<TagRow<'a>>,
}
pub(crate) struct DiffFile<'a> {
pub href: String,
pub path: std::borrow::Cow<'a, str>,
pub status: &'static str,
pub diff: Option<&'a super::views::FileDiff>,
}
#[derive(Template)]
#[template(path = "diff.html")]
pub(crate) struct Diff<'a> {
pub file_count: String,
pub totals: Option<(usize, usize)>,
pub too_big: bool,
pub what: &'static str,
pub file_icon: String,
pub files: Vec<DiffFile<'a>>,
}
#[derive(Template)]
#[template(path = "account.html")]
pub(crate) struct Account<'a> {
pub title: &'a str,
pub signed_in: bool,
pub user: &'a str,
pub message: &'a str,
pub ok: bool,
pub csrf: &'a str,
pub min_password: usize,
}
#[derive(Template)]
#[template(path = "login.html")]
pub(super) struct SignIn<'a> {
pub title: &'a str,
pub signed_in: bool,
pub next: &'a str,
pub message: &'a str,
}
pub(super) struct TagLink<'a> {
pub name: std::borrow::Cow<'a, str>,
pub url: String,
}
#[derive(Template)]
#[template(path = "compare.html")]
pub(super) struct Compare<'a> {
pub title: String,
pub signed_in: bool,
pub masthead: String,
pub action: String,
pub from: String,
pub to: String,
pub refs: Vec<String>,
pub message: Option<String>,
pub summary: Option<String>,
pub swap: Option<String>,
pub rows: Vec<CommitRow<'a>>,
pub more: Option<String>,
pub diff: Option<String>,
pub tag_icon: String,
}
pub(super) struct CommitRow<'a> {
pub url: String,
pub subject: String,
pub short_id: String,
pub author: String,
pub when: String,
pub tags: Vec<TagLink<'a>>,
}
#[derive(Template)]
#[template(path = "history.html")]
pub(super) struct History<'a> {
pub title: String,
pub signed_in: bool,
pub masthead: String,
pub locator: String,
pub tag_icon: String,
pub rows: Vec<CommitRow<'a>>,
pub compare: Option<(String, String)>,
pub newer: Option<String>,
pub older: Option<String>,
}
pub(super) struct EntryCommit {
pub url: String,
pub subject: String,
pub message: String,
pub when: String,
pub datetime: String,
pub full_date: String,
}
#[derive(Template)]
#[template(path = "tree-row.html")]
pub(super) struct TreeRow<'a> {
pub name: std::borrow::Cow<'a, str>,
pub class: &'static str,
pub icon: String,
pub href: Option<String>,
pub short_id: &'a str,
pub commit: Option<EntryCommit>,
}
pub(super) struct RepositoryRow {
pub owner: String,
pub name: String,
pub public: bool,
pub description: Option<String>,
pub subject: String,
pub when: String,
}
#[derive(Template)]
#[template(path = "repositories.html")]
pub(super) struct Repositories<'a> {
pub title: &'a str,
pub signed_in: bool,
pub count: String,
pub filter: String,
pub total: usize,
pub rows: Vec<RepositoryRow>,
pub branch: String,
pub host: &'a str,
}
#[derive(Template)]
#[template(path = "commit.html")]
pub(super) struct Commit<'a> {
pub title: &'a str,
pub signed_in: bool,
pub masthead: String,
pub browse: String,
pub message: &'a str,
pub author: &'a str,
pub email: &'a str,
pub date: &'a str,
pub short_id: &'a str,
pub parent_links: String,
pub diff: &'a str,
}
pub(super) struct TreeHead {
pub author: String,
pub subject: String,
pub url: String,
pub sha_link: String,
pub when: String,
pub history: String,
}
#[derive(Template)]
#[template(path = "tree.html")]
pub(super) struct Tree<'a> {
pub title: String,
pub signed_in: bool,
pub masthead: String,
pub locator: String,
pub head: Option<TreeHead>,
pub up: Option<String>,
pub rows: Vec<TreeRow<'a>>,
pub previous: Option<String>,
pub next: Option<String>,
pub readme: Option<(String, String)>,
}