[OCaml] Mobile-friendly clone of cgit.
Add git icon to page header on every page
Display the git logo alongside the page title, similar to cgit. Uses a flex layout with the SVG icon at 2.5em beside the h1/h2.
Changed files
lib/static/styles.css
@@ -9,6 +9,24 @@
9
9
color: white;
10
10
}
11
11
12
Added:
#page-header {
13
Added:
display: flex;
14
Added:
align-items: center;
15
Added:
gap: 1em;
16
Added:
padding: 0.5em 0;
17
Added:
}
18
Added:
19
Added:
#page-header .site-logo {
20
Added:
width: 2.5em;
21
Added:
height: 2.5em;
22
Added:
}
23
Added:
24
Added:
#page-header h1,
25
Added:
#page-header h2 {
26
Added:
margin: 0;
27
Added:
padding: 0;
28
Added:
}
29
Added:
12
30
nav#top {
13
31
background-color: black;
14
32
border-radius: 0.25rem;
@@ -71,10 +89,7 @@
71
89
}
72
90
73
91
h1 {
74
Removed:
/* position: sticky; */
75
Removed:
/* top: 0; */
76
Removed:
/* background: inherit; */
77
Removed:
padding: 0.5em 0;
92
Added:
padding: 0;
78
93
}
79
94
80
95
.timestamp {
lib/views.ml
@@ -41,7 +41,13 @@
41
41
if String.starts_with ~prefix:"Unnamed repository" header2 then ""
42
42
else header2
43
43
in
44
Removed:
HTML.(null [ h1 [] [ txt "%s" header1 ]; h2 [] [ txt "%s" header2 ] ])
44
Added:
HTML.(
45
Added:
header
46
Added:
[ id "page-header" ]
47
Added:
[
48
Added:
img [ src "/static/git_icon.svg"; alt "git"; class_ "site-logo" ];
49
Added:
div [] [ h1 [] [ txt "%s" header1 ]; h2 [] [ txt "%s" header2 ] ];
50
Added:
])
45
51
46
52
let page_footer () =
47
53
let now = Unix.(time () |> localtime) in
@@ -135,7 +141,13 @@
135
141
HTML.(li [] [ txt "%s" author.name ])
136
142
137
143
let li_of_branch repo (branch : Resolvers.Reference.t) =
138
Removed:
HTML.(li [] [ Routes.link_to (Commits_branch (repo, branch.name)) (txt "%s" branch.name) ])
144
Added:
HTML.(
145
Added:
li []
146
Added:
[
147
Added:
Routes.link_to
148
Added:
(Commits_branch (repo, branch.name))
149
Added:
(txt "%s" branch.name);
150
Added:
])
139
151
140
152
let li_of_tag repo (tag : Resolvers.Reference.t) =
141
153
HTML.(li [] [ Routes.link_to (Tags repo) (txt "%s" tag.name) ])
@@ -218,8 +230,7 @@
218
230
let root_link = Routes.link_to (Files repo) (txt "/") in
219
231
let crumbs =
220
232
List.map
221
Removed:
(fun (name, hash) ->
222
Removed:
Routes.link_to (File (repo, hash)) (txt "%s" name))
233
Added:
(fun (name, hash) -> Routes.link_to (File (repo, hash)) (txt "%s" name))
223
234
trail
224
235
in
225
236
let separator = txt " / " in
@@ -238,7 +249,12 @@
238
249
title = repo;
239
250
subtitle = Resolvers.repo_description repo;
240
251
active = Files;
241
Removed:
content = HTML.[ breadcrumbs repo trail; ul [] @@ List.map (li_of_entry repo) tree.entries ];
252
Added:
content =
253
Added:
HTML.
254
Added:
[
255
Added:
breadcrumbs repo trail;
256
Added:
ul [] @@ List.map (li_of_entry repo) tree.entries;
257
Added:
];
242
258
}
243
259
244
260
let file repo trail (blob : Resolvers.Blob.t) =
@@ -261,7 +277,8 @@
261
277
title = repo;
262
278
subtitle = Resolvers.repo_description repo;
263
279
active = Files;
264
Removed:
content = HTML.[ breadcrumbs repo trail; div [ id "blob" ] formatted_blob ];
280
Added:
content =
281
Added:
HTML.[ breadcrumbs repo trail; div [ id "blob" ] formatted_blob ];
265
282
}
266
283
267
284
let commit repo (commit : Resolvers.Commit.t) diff =
@@ -341,22 +358,23 @@
341
358
active = Summary;
342
359
content =
343
360
HTML.(
344
Removed:
[
345
Removed:
h3 [] [ txt "%s" commit_summary_text ];
346
Removed:
]
361
Added:
[ h3 [] [ txt "%s" commit_summary_text ] ]
347
362
@ (if commit_body_text = "" then []
348
Removed:
else [ p [ class_ "commit-body" ] [ txt "%s" commit_body_text ] ])
363
Added:
else
364
Added:
[ p [ class_ "commit-body" ] [ txt "%s" commit_body_text ] ])
349
365
@ [
350
Removed:
dl
351
Removed:
[ class_ "commit-meta" ]
352
Removed:
[
353
Removed:
dt [] [ txt "Commit" ];
354
Removed:
dd [] [ txt "%s" commit.hash ];
355
Removed:
dt [] [ txt "Author" ];
356
Removed:
dd []
357
Removed:
[ txt "%s <%s>" commit.author.name commit.author.email ];
358
Removed:
];
359
Removed:
]
366
Added:
dl
367
Added:
[ class_ "commit-meta" ]
368
Added:
[
369
Added:
dt [] [ txt "Commit" ];
370
Added:
dd [] [ txt "%s" commit.hash ];
371
Added:
dt [] [ txt "Author" ];
372
Added:
dd []
373
Added:
[
374
Added:
txt "%s <%s>" commit.author.name commit.author.email;
375
Added:
];
376
Added:
];
377
Added:
]
360
378
@ diff_content);
361
379
}
362
380