summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/handlers.ml14
-rw-r--r--lib/views.ml92
2 files changed, 56 insertions, 50 deletions
diff --git a/lib/handlers.ml b/lib/handlers.ml
index deb9635..ff4c4a5 100644
--- a/lib/handlers.ml
+++ b/lib/handlers.ml
@@ -1,6 +1,6 @@
(* -*- mode: tuareg; -*- *)
-let root _req = Views.root () |> Dream_html.respond
+let root _req = Views.root ()
module Repo = struct
open Git_presenters
@@ -20,29 +20,29 @@ module Repo = struct
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
+ Views.Repo.summary (repo req) branches commits authors
let log req =
let* commits = recent_commits (repo req) 100 in
- Views.Repo.log (repo req) commits |> Dream_html.respond
+ Views.Repo.log (repo req) commits
let files_at_head req =
let* tree = head_tree (repo req) in
- Views.Repo.files (repo req) tree |> Dream_html.respond
+ Views.Repo.files (repo req) tree
let file_id req =
let id = id_of_req req in
let* blob = blob_of_id (repo req) id in
- Views.Repo.file (repo req) blob |> Dream_html.respond
+ Views.Repo.file (repo req) blob
let refs req =
let* branches = all_branches (repo req) in
- Views.Repo.refs (repo req) branches |> Dream_html.respond
+ Views.Repo.refs (repo req) branches
let commit req =
let id = id_of_req req in
let* commit = commit_of_id (repo req) id in
- Views.Repo.commit (repo req) commit |> Dream_html.respond
+ Views.Repo.commit (repo req) commit
end
let all_handlers =
diff --git a/lib/views.ml b/lib/views.ml
index 1e0a858..e65a249 100644
--- a/lib/views.ml
+++ b/lib/views.ml
@@ -91,7 +91,7 @@ let root () =
content = [ all_repositories ];
}
in
- Page.render body_data
+ respond @@ Page.render body_data
module Repo = struct
open Git_presenters
@@ -140,13 +140,14 @@ module Repo = struct
ul [] (List.map li_of_author authors);
]
in
- Page.render ~page_title:(page_title repo)
- {
- title = repo;
- subtitle = repo_description repo;
- topnav = Components.Topnav.(v ~active_path:Summary repo);
- content;
- }
+ respond
+ @@ Page.render ~page_title:(page_title repo)
+ {
+ title = repo;
+ subtitle = repo_description repo;
+ topnav = Components.Topnav.(v ~active_path:Summary repo);
+ content;
+ }
let refs repo branches =
let content =
@@ -156,13 +157,14 @@ module Repo = struct
ul [] (List.map (li_of_branch repo) branches);
]
in
- Page.render ~page_title:(page_title repo)
- {
- title = repo;
- subtitle = repo_description repo;
- topnav = Components.Topnav.(v ~active_path:Refs repo);
- content;
- }
+ respond
+ @@ Page.render ~page_title:(page_title repo)
+ {
+ title = repo;
+ subtitle = repo_description repo;
+ topnav = Components.Topnav.(v ~active_path:Refs repo);
+ content;
+ }
let log repo commits =
let content =
@@ -172,13 +174,14 @@ module Repo = struct
ul [] (List.map (li_of_commit repo) commits);
]
in
- Page.render ~page_title:(page_title repo)
- {
- title = repo;
- subtitle = repo_description repo;
- topnav = Components.Topnav.(v ~active_path:Log repo);
- content;
- }
+ respond
+ @@ Page.render ~page_title:(page_title repo)
+ {
+ title = repo;
+ subtitle = repo_description repo;
+ topnav = Components.Topnav.(v ~active_path:Log repo);
+ content;
+ }
let files repo tree =
let title = Printf.sprintf "%s" repo in
@@ -189,13 +192,14 @@ module Repo = struct
ul [] (List.map (li_of_entry repo) tree.entries);
]
in
- Page.render ~page_title:(page_title repo)
- {
- title;
- subtitle = repo_description repo;
- topnav = Components.Topnav.(v ~active_path:Files repo);
- content;
- }
+ respond
+ @@ Page.render ~page_title:(page_title repo)
+ {
+ title;
+ subtitle = repo_description repo;
+ topnav = Components.Topnav.(v ~active_path:Files repo);
+ content;
+ }
let file repo blob =
let title = Printf.sprintf "%s" repo in
@@ -214,25 +218,27 @@ module Repo = struct
let content =
HTML.[ h3 [] [ txt "File" ]; div [ id "blob" ] formatted_blob ]
in
- Page.render ~page_title:(page_title repo)
- {
- title;
- subtitle = repo_description repo;
- topnav = Components.Topnav.(v ~active_path:Files repo);
- content;
- }
+ respond
+ @@ Page.render ~page_title:(page_title repo)
+ {
+ title;
+ subtitle = repo_description repo;
+ topnav = Components.Topnav.(v ~active_path:Files repo);
+ content;
+ }
let commit repo commit =
let message = match commit.message with Some msg -> msg | None -> "" in
let title = Printf.sprintf "%s : %s" repo commit.short_hash in
let content = HTML.[ h3 [] [ txt "%s" message ] ] in
- Page.render ~page_title:(page_title repo)
- {
- title;
- subtitle = repo_description repo;
- topnav = Components.Topnav.v repo;
- content;
- }
+ respond
+ @@ Page.render ~page_title:(page_title repo)
+ {
+ title;
+ subtitle = repo_description repo;
+ topnav = Components.Topnav.v repo;
+ content;
+ }
end
let error_page message =
Copyright 2019--2025 Marius PETER