summaryrefslogtreecommitdiff
path: root/lib/views.ml
diff options
context:
space:
mode:
authorMarius Peter <marius.peter@tutanota.com>2025-05-28 23:02:14 +0200
committerMarius Peter <marius.peter@tutanota.com>2025-05-28 23:02:14 +0200
commitffae61af1a13862ffc2bf9415313f5da3d90d38e (patch)
treed1849eaf647e498e68cc0c9511d6b1d7f786dc62 /lib/views.ml
parent378d9f24bd19855b7aa59936d7104ab1203c42f3 (diff)
Add link_to route generator.
Diffstat (limited to 'lib/views.ml')
-rw-r--r--lib/views.ml59
1 files changed, 22 insertions, 37 deletions
diff --git a/lib/views.ml b/lib/views.ml
index 986aa35..33654ea 100644
--- a/lib/views.ml
+++ b/lib/views.ml
@@ -82,10 +82,8 @@ let root () =
Sys.readdir config.git_project_root
|> Array.to_list |> List.sort String.compare
in
- let li_of_repo repo =
- HTML.(li [] [ a [ href "%s/" repo ] [ txt "%s" repo ] ])
- in
- HTML.(div [ id "repositories" ] [ ul [] @@ List.map li_of_repo repos ])
+ HTML.(
+ div [ id "repositories" ] [ ul [] @@ List.map Routes.li_of_repo repos ])
in
let body_data =
{
@@ -100,25 +98,25 @@ let root () =
module Repo = struct
let page_title repo = Printf.sprintf "%s — %s" repo (repo_description repo)
+ let li_of_branch repo branch =
+ HTML.(li [] [ Routes.link_to branch.name (Tag (repo, branch.name)) ])
+
+ let li_of_commit repo commit =
+ match commit.message with
+ | Some msg ->
+ HTML.(
+ li []
+ [
+ Routes.link_to
+ (commit.short_hash ^ " - " ^ msg)
+ (Commit (repo, commit.hash));
+ ])
+ | None -> HTML.(li [] [ txt "%s" commit.short_hash ])
+
let summary repo branches commits authors =
- let li_of_branch branch =
- HTML.(li [] [ a [ href "%s" branch.name ] [ txt "%s" branch.name ] ])
- in
- let li_of_commit commit =
- match commit.message with
- | Some msg ->
- HTML.(
- li []
- [
- a
- [ href "commit/?id=%s" commit.hash ]
- [ txt "%s %s" commit.short_hash msg ];
- ])
- | None -> HTML.(li [] [ a [ href "" ] [ txt "caca!!" ] ])
- in
- let li_of_author author =
- HTML.(li [] [ a [ href "" ] [ txt "%s" author ] ])
- in
+ let li_of_branch = li_of_branch repo in
+ let li_of_commit = li_of_commit repo in
+ let li_of_author author = HTML.(li [] [ txt "%s" author ]) in
let content =
HTML.
[
@@ -139,9 +137,7 @@ module Repo = struct
}
let refs repo branches =
- let li_of_branch branch =
- HTML.(li [] [ a [ href "%s" branch.name ] [ txt "%s" branch.name ] ])
- in
+ let li_of_branch = li_of_branch repo in
let content =
HTML.[ h3 [] [ txt "Branches" ]; ul [] (List.map li_of_branch branches) ]
in
@@ -154,18 +150,7 @@ module Repo = struct
}
let log repo commits =
- let li_of_commit commit =
- match commit.message with
- | Some msg ->
- HTML.(
- li []
- [
- a
- [ href "commit/?id=%s" commit.hash ]
- [ txt "%s %s" commit.short_hash msg ];
- ])
- | None -> HTML.(li [] [ a [ href "" ] [ txt "caca!!" ] ])
- in
+ let li_of_commit = li_of_commit repo in
let content =
HTML.
[ h3 [] [ txt "All commits" ]; ul [] (List.map li_of_commit commits) ]
Copyright 2019--2025 Marius PETER