summaryrefslogtreecommitdiff
path: root/lib/views.ml
diff options
context:
space:
mode:
authorMarius Peter <marius.peter@tutanota.com>2025-06-21 12:09:35 +0200
committerMarius Peter <marius.peter@tutanota.com>2025-06-21 12:09:35 +0200
commit034ae69f2f22d7957386e73b3c42053fbf0cdfb2 (patch)
treeb991f59a492b62b059029aa7365547e826c07416 /lib/views.ml
parent6e07594aace8bc2c6f99219b4022a68291201aad (diff)
Refactor resolvers.
Diffstat (limited to 'lib/views.ml')
-rw-r--r--lib/views.ml52
1 files changed, 27 insertions, 25 deletions
diff --git a/lib/views.ml b/lib/views.ml
index fc211c5..ca012fc 100644
--- a/lib/views.ml
+++ b/lib/views.ml
@@ -90,18 +90,19 @@ let root () =
respond @@ Page.render body_data
module Repo = struct
- open Resolvers
+ let page_title repo =
+ Printf.sprintf "%s — %s" repo (Resolvers.repo_description repo)
- let page_title repo = Printf.sprintf "%s — %s" repo (repo_description repo)
let li_of_author author = HTML.(li [] [ txt "%s" author ])
- let li_of_branch repo (branch : branch) =
- HTML.(li [] [ Routes.link_to (Refs repo) (txt "%s" branch.name) ])
+ (* let li_of_branch repo (branch : Resolvers.Branch.t) = *)
+ (* HTML.(li [] [ Routes.link_to (Refs repo) (txt "%s" branch.name) ]) *)
- let li_of_commit repo commit =
+ let li_of_commit repo (commit : Resolvers.Commit.t) =
let open HTML in
+ let short_hash = Resolvers.short_hash commit.hash in
match commit.message with
- | None -> li [] [ txt "%s" commit.short_hash ]
+ | None -> li [] [ txt "%s" short_hash ]
| Some msg ->
li []
[
@@ -109,12 +110,12 @@ module Repo = struct
(Commit (repo, commit.hash))
(null
[
- span [ class_ "commit-hash" ] [ txt "%s" commit.short_hash ];
+ span [ class_ "commit-hash" ] [ txt "%s" short_hash ];
txt " — %s" msg;
]);
]
- let li_of_entry repo entry =
+ let li_of_entry repo (entry : Resolvers.Entry.t) =
let display_name =
if entry.perm = 0o040000 then entry.name ^ "/" else entry.name
in
@@ -124,12 +125,12 @@ module Repo = struct
in
HTML.(li [] [ Routes.link_to route @@ txt "%s" display_name ])
- let summary repo branches commits authors =
+ let summary repo _branches commits authors =
let content =
HTML.
[
h3 [] [ txt "Branches" ];
- ul [] (List.map (li_of_branch repo) branches);
+ (* ul [] (List.map (li_of_branch repo) branches); *)
h3 [] [ txt "Latest commits" ];
ul [] (List.map (li_of_commit repo) commits);
h3 [] [ txt "Authors" ];
@@ -140,24 +141,24 @@ module Repo = struct
@@ Page.render ~page_title:(page_title repo)
{
title = repo;
- subtitle = repo_description repo;
+ subtitle = Resolvers.repo_description repo;
topnav = Components.Topnav.(v ~active_path:Summary repo);
content;
}
- let refs repo branches =
+ let refs repo _branches =
let content =
HTML.
[
h3 [] [ txt "Branches" ];
- ul [] (List.map (li_of_branch repo) branches);
+ (* ul [] (List.map (li_of_branch repo) branches); *)
]
in
respond
@@ Page.render ~page_title:(page_title repo)
{
title = repo;
- subtitle = repo_description repo;
+ subtitle = Resolvers.repo_description repo;
topnav = Components.Topnav.(v ~active_path:Refs repo);
content;
}
@@ -174,30 +175,29 @@ module Repo = struct
@@ Page.render ~page_title:(page_title repo)
{
title = repo;
- subtitle = repo_description repo;
+ subtitle = Resolvers.repo_description repo;
topnav = Components.Topnav.(v ~active_path:Log repo);
content;
}
- let files repo tree =
- let title = Printf.sprintf "%s" repo in
+ let files repo (tree : Resolvers.Tree.t) =
let content =
HTML.
[
- h3 [] [ txt "Files %s" tree.short_hash ];
+ h3 [] [ txt "Files %s" @@ Resolvers.short_hash tree.hash ];
ul [] (List.map (li_of_entry repo) tree.entries);
]
in
respond
@@ Page.render ~page_title:(page_title repo)
{
- title;
- subtitle = repo_description repo;
+ title = Printf.sprintf "%s" repo;
+ subtitle = Resolvers.repo_description repo;
topnav = Components.Topnav.(v ~active_path:Files repo);
content;
}
- let file repo blob =
+ let file repo (blob : Resolvers.Blob.t) =
let title = Printf.sprintf "%s" repo in
let to_numbered_line number line =
let n = number + 1 in
@@ -218,20 +218,22 @@ module Repo = struct
@@ Page.render ~page_title:(page_title repo)
{
title;
- subtitle = repo_description repo;
+ subtitle = Resolvers.repo_description repo;
topnav = Components.Topnav.(v ~active_path:Files repo);
content;
}
- let commit repo commit =
+ let commit repo (commit : Resolvers.Commit.t) =
let message = match commit.message with Some msg -> msg | None -> "" in
- let title = Printf.sprintf "%s : %s" repo commit.short_hash in
+ let title =
+ Printf.sprintf "%s : %s" repo @@ Resolvers.short_hash commit.hash
+ in
let content = HTML.[ h3 [] [ txt "%s" message ] ] in
respond
@@ Page.render ~page_title:(page_title repo)
{
title;
- subtitle = repo_description repo;
+ subtitle = Resolvers.repo_description repo;
topnav = Components.Topnav.v repo;
content;
}
Copyright 2019--2025 Marius PETER