diff options
author | Marius Peter <marius.peter@tutanota.com> | 2025-05-01 19:28:20 +0200 |
---|---|---|
committer | Marius Peter <marius.peter@tutanota.com> | 2025-05-01 19:28:20 +0200 |
commit | f94d27e3df990d9dd7dae69191dd05e5f691b0bb (patch) | |
tree | 0306d92ed67b1b9ad10aa1f7926a25daea119ee5 /lib/handlers.ml | |
parent | ad02d028ab875c5d5ba90f3f8bed31f2678ed664 (diff) |
Perform deep refactoring.
Better separation of concern; this paves the way for better testing
down the road.
Diffstat (limited to 'lib/handlers.ml')
-rw-r--r-- | lib/handlers.ml | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/lib/handlers.ml b/lib/handlers.ml index 171cef2..27ca0b6 100644 --- a/lib/handlers.ml +++ b/lib/handlers.ml @@ -1,27 +1,34 @@ -let ogit_root _req = Views.Ogit_root.render () |> Dream_html.respond +let ogit_root _req = Views.ogit_root () |> Dream_html.respond -let repo_root req = - let repo_name = Dream.param req "repo_name" in - Views.Repo_root.render repo_name |> Dream_html.respond +let repo_summary req = + let repo_path = Dream.param req "repo_name" in + let%lwt branches_result = Git_helpers.all_branches repo_path in + let%lwt commits_result = Git_helpers.latest_commits repo_path 10 in + match (branches_result, commits_result) with + | Ok branches, Ok commits -> + Views.repo_summary repo_path ~branches ~commits |> Dream_html.respond + | Error msg, _ | _, Error msg -> Views.error_page msg |> Dream_html.respond -let repo_tree req = - let repo_name = Dream.param req "repo_name" in - let dir_path = Dream.target req in - Views.Repo_tree.render repo_name dir_path |> Dream_html.respond +(* let repo_tree req = *) +(* let repo_name = Dream.param req "repo_name" in *) +(* let path = Git_helpers.full_path repo_name in *) +(* let dir_path = Dream.target req in *) +(* Views.repo_tree ~repo_path:path dir_path |> Dream_html.respond *) -let repo_blob req = - let repo_name = Dream.param req "repo_name" in - let blob_path = Dream.query req "path" |> Option.value ~default:"" in - Views.Repo_blob.render repo_name blob_path |> Dream_html.respond +(* let repo_blob req = *) +(* let repo_name = Dream.param req "repo_name" in *) +(* let path = Git_helpers.full_path repo_name in *) +(* let blob_path = Dream.query req "path" |> Option.value ~default:"" in *) +(* Views.repo_blob repo_name blob_path |> Dream_html.respond *) let all_handlers = [ Dream.get "/" ogit_root; Dream.scope "/:repo_name" [] [ - Dream.get "/" repo_root; - Dream.get "/tree" repo_tree; - Dream.get "/blob" repo_blob; + Dream.get "/" repo_summary; + (* Dream.get "/tree" repo_tree; *) + (* Dream.get "/blob" repo_blob; *) ]; Dream.get "/static/**" (Dream.static "./lib/static"); ] |