[OCaml] Mobile-friendly clone of cgit.
remove dedicated README/ page
Remove the standalone /repo/README route and its handler. The README is now displayed exclusively on the summary page. - Remove Readme route variant and dispatcher - Remove readme handler function - Remove Readme from page type and navigation links - Simplify file view: remove ?active parameter (always Files now) - Update dispatch tests The navigation now shows only: Summary, Commits, Files.
Changed files
lib/handlers.ml
@@ -276,20 +276,6 @@
276
276
| `Tree _ ->
277
277
error_response (Resolvers.Bad_request "object is a tree, not a blob")
278
278
279
Removed:
let readme repository context =
280
Removed:
let* readme = Resolvers.Repo.readme repository in
281
Removed:
let blob =
282
Removed:
match readme with
283
Removed:
| None ->
284
Removed:
Resolvers.Blob.
285
Removed:
{
286
Removed:
content =
287
Removed:
"README does not exist for "
288
Removed:
^ Resolvers.repository_name repository;
289
Removed:
}
290
Removed:
| Some blob -> blob
291
Removed:
in
292
Removed:
Views.Repo.file ~active:Layout.Readme context [] blob
293
279
end
294
280
295
281
let project_dir config subdir =
@@ -365,8 +351,7 @@
365
351
Repo.file_id repository context hash)
366
352
| Routes.Raw hash ->
367
353
Repo.with_repository config name (fun repository context ->
368
Removed:
Repo.raw_file repository context hash)
369
Removed:
| Routes.Readme_page -> Repo.with_repository config name Repo.readme)
354
Added:
Repo.raw_file repository context hash))
370
355
in
371
356
[
372
357
Dream.get "/" (root config);
lib/routes.ml
@@ -20,7 +20,6 @@
20
20
| Commit of string * string
21
21
| Files of string
22
22
| File of string * string
23
Removed:
| Readme of string
24
23
| Raw_file of string * string
25
24
26
25
(* Generate URL paths for routes *)
@@ -33,7 +32,6 @@
33
32
| Commit (repo, hash) -> "/" ^ repo ^ "/commit/" ^ hash
34
33
| Files repo -> "/" ^ repo ^ "/files/"
35
34
| File (repo, hash) -> "/" ^ repo ^ "/file/" ^ hash
36
Removed:
| Readme repo -> "/" ^ repo ^ "/README"
37
35
| Raw_file (repo, hash) -> "/" ^ repo ^ "/raw/" ^ hash
38
36
39
37
(** Dispatch a request path (without leading slash) into a route. Returns
@@ -45,7 +43,6 @@
45
43
| Commit_detail of string
46
44
| Files_page
47
45
| File_detail of string
48
Removed:
| Readme_page
49
46
| Raw of string
50
47
51
48
let known_actions =
@@ -55,7 +52,6 @@
55
52
"commit";
56
53
"files";
57
54
"file";
58
Removed:
"README";
59
55
"raw";
60
56
]
61
57
@@ -82,7 +78,6 @@
82
78
| "commit", [ hash ] -> Some (Commit_detail hash)
83
79
| "files", _ -> Some Files_page
84
80
| "file", [ hash ] -> Some (File_detail hash)
85
Removed:
| "README", _ -> Some Readme_page
86
81
| "raw", [ hash ] -> Some (Raw hash)
87
82
| _ -> None
88
83
in
lib/views/components.ml
@@ -14,7 +14,6 @@
14
14
| Summary
15
15
| Commits
16
16
| Files
17
Removed:
| Readme
18
17
(** Which repository page is being shown. Drives the [aria-current] marker
19
18
in the navigation. *)
20
19
@@ -56,13 +55,11 @@
56
55
| Summary -> Routes.Repo repo
57
56
| Commits -> Routes.Commits repo
58
57
| Files -> Routes.Files repo
59
Removed:
| Readme -> Routes.Readme repo
60
58
61
59
let page_name = function
62
60
| Summary -> "Summary"
63
61
| Commits -> "Commits"
64
62
| Files -> "Files"
65
Removed:
| Readme -> "README"
66
63
67
64
let page_link repo ~active page =
68
65
Ui.nav_link ~current:(page = active)
@@ -132,7 +129,7 @@
132
129
~control_class:"nav-hamburger" ~label:"Menu" ~glyph:"\xe2\x8b\xae" ();
133
130
Ui.nav_links ~id:"nav-links"
134
131
(List.map (page_link repo ~active)
135
Removed:
[ Summary; Commits; Files; Readme ]);
132
Added:
[ Summary; Commits; Files ]);
136
133
]
137
134
138
135
(** The same repository destinations as {!repo_nav}, condensed and pinned to the
@@ -145,7 +142,7 @@
145
142
Ui.navigation ~id:"bottom-nav" ~label:"Compact navigation"
146
143
[
147
144
Ui.nav_links ~id:"bottom-nav-links" ~item_class:"bottom-nav-item"
148
Removed:
(List.map (page_link repo ~active) [ Summary; Commits; Files; Readme ]);
145
Added:
(List.map (page_link repo ~active) [ Summary; Commits; Files ]);
149
146
]
150
147
151
148
(** {1 Toolbar} *)
lib/views/layout.ml
@@ -15,7 +15,6 @@
15
15
| Summary
16
16
| Commits
17
17
| Files
18
Removed:
| Readme
19
18
20
19
type site = Components.site = {
21
20
user_name : string;
lib/views/repo.ml
@@ -289,7 +289,7 @@
289
289
Ui.items_of ~id:"file-tree" (tree_row context.repo) entries; readme_panel;
290
290
]
291
291
292
Removed:
let file ?(active = Layout.Files) context trail (blob : Resolvers.Blob.t) =
292
Added:
let file context trail (blob : Resolvers.Blob.t) =
293
293
let filename =
294
294
match List.rev trail with (name, _) :: _ -> Some name | [] -> None
295
295
in
@@ -301,14 +301,8 @@
301
301
[ Components.route_link (Raw_file (context.repo, hash)) "View raw" ]
302
302
| [] -> Ui.nothing
303
303
in
304
Removed:
(* The README page reuses this view but reaches it without a path, so it has no
305
Removed:
trail to show. *)
306
Removed:
let toolbar =
307
Removed:
match active with
308
Removed:
| Layout.Readme -> []
309
Removed:
| _ -> [ path_trail context.repo trail ]
310
Removed:
in
311
Removed:
render_page context ~active ~toolbar
304
Added:
let toolbar = [ path_trail context.repo trail ] in
305
Added:
render_page context ~active:Files ~toolbar
312
306
[
313
307
raw_link;
314
308
(let lines = Highlight.highlight ~lang:language blob.content in
test/test_dispatch.ml
@@ -10,7 +10,6 @@
10
10
| Ogit.Routes.Commit_detail h -> "Commit_detail " ^ h
11
11
| Ogit.Routes.Files_page -> "Files_page"
12
12
| Ogit.Routes.File_detail h -> "File_detail " ^ h
13
Removed:
| Ogit.Routes.Readme_page -> "Readme_page"
14
13
| Ogit.Routes.Raw h -> "Raw " ^ h
15
14
16
15
let check_dispatch msg path expected =
@@ -33,8 +32,7 @@
33
32
let test_basic_actions () =
34
33
check_dispatch "summary" "myrepo/summary/" (Some ("myrepo", Summary));
35
34
check_dispatch "commits" "myrepo/commits/" (Some ("myrepo", Commits_page));
36
Removed:
check_dispatch "files" "myrepo/files/" (Some ("myrepo", Files_page));
37
Removed:
check_dispatch "readme" "myrepo/README" (Some ("myrepo", Readme_page))
35
Added:
check_dispatch "files" "myrepo/files/" (Some ("myrepo", Files_page))
38
36
39
37
let test_parametric_actions () =
40
38
check_dispatch "commit with hash" "myrepo/commit/abc123"