summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Peter <marius.peter@tutanota.com>2025-05-27 23:38:10 +0200
committerMarius Peter <marius.peter@tutanota.com>2025-05-27 23:38:10 +0200
commit0a46c9b495557f4634a543c43cdc8fb920c76303 (patch)
treee5b79ea865ff798107e605a6eec99187661e4bdb
parent3d19770adbc6bed784ce2385a03c5c350aa75ebe (diff)
Refactor + proper implementation for refs and log handlers.
-rw-r--r--lib/handlers.ml34
1 files changed, 21 insertions, 13 deletions
diff --git a/lib/handlers.ml b/lib/handlers.ml
index 6b3df29..8771f5f 100644
--- a/lib/handlers.ml
+++ b/lib/handlers.ml
@@ -1,31 +1,39 @@
(* -*- mode: tuareg; -*- *)
-let ( let* ) m f =
- let open Lwt.Infix in
- m >>= function
- | Ok x -> f x
- | Error e ->
- let msg = Format.asprintf "%a" Git_unix.Store.pp_error e in
- Views.error_page msg |> Dream_html.respond
-
let root _req = Views.root () |> Dream_html.respond
module Repo = struct
+ open Git_presenters
+
+ let ( let* ) m f =
+ let open Lwt.Infix in
+ m >>= function
+ | Ok x -> f x
+ | Error e ->
+ let msg = Format.asprintf "%a" Git_unix.Store.pp_error e in
+ Views.error_page msg |> Dream_html.respond
+
let repo req = Dream.param req "repo_name"
let summary req =
- let* branches = Git_presenters.Branch.all_branches (repo req) in
- let* commits = Git_presenters.Commit.recent_commits (repo req) 10 in
+ let* branches = all_branches (repo req) in
+ let* commits = recent_commits (repo req) 10 in
let authors = [ "John Pork"; "Sebastian Jellybean" ] in
Views.Repo.summary (repo req) branches commits authors |> Dream_html.respond
- let refs req = Views.Repo.refs (repo req) |> Dream_html.respond
- let log req = Views.Repo.log (repo req) |> Dream_html.respond
+ let refs req =
+ let* branches = all_branches (repo req) in
+ Views.Repo.refs (repo req) branches |> Dream_html.respond
+
+ let log req =
+ let* commits = recent_commits (repo req) 100 in
+ Views.Repo.log (repo req) commits |> Dream_html.respond
+
let tree req = Views.Repo.tree (repo req) |> Dream_html.respond
let commit req =
let id = match Dream.query req "id" with Some id -> id | None -> "" in
- let* commit = Git_presenters.Commit.of_id (repo req) id in
+ let* commit = of_id (repo req) id in
Views.Repo.commit (repo req) commit |> Dream_html.respond
end
Copyright 2019--2025 Marius PETER