Good progress today 💯

Commit
f0c8906cd19479447ff5d0c1044ecbad6ab845d6
Author
Marius Peter <marius.peter@tutanota.com>
Author date
Committer
Marius Peter <marius.peter@tutanota.com>
Committer date
Changed files
lib/handlers.ml
index 321c6936..17b9eaba 100644..100644
@@ -12,7 +12,7 @@
12 12 let repo_path req = Dream.param req "repo_name"
13 13
14 14 let summary req =
15 Removed: let branches = Git_helpers.Branch.all_branches (repo_path req) in
15 Added: let* branches = Git_helpers.Branch.all_branches (repo_path req) in
16 16 let* commits = Git_helpers.Commit.recent_commits (repo_path req) 10 in
17 17 let authors = [ "John Pork"; "Sebastian Jellybean" ] in
18 18 Views.Repo.summary (repo_path req) branches commits authors
lib/views.ml
index e023236f..ccaf73be 100644..100644
@@ -3,21 +3,21 @@
3 3 type body_data = {
4 4 title : string;
5 5 subtitle : string;
6 Added: topnav : Dream_html.node;
6 7 content : Dream_html.node list;
7 8 }
8 9
9 10 module Components = struct
10 11 open Dream_html
11 12
12 Removed: let topnav current_path =
13 Added: let topnav repo_path =
13 14 let open HTML in
15 Added: let () = Dream.log "%s" ("current path is: " ^ repo_path) in
14 16 let li_of_a (path, text) =
15 Removed: let is_active = path = current_path in
17 Added: let () = Dream.log "%s" ("and path is: " ^ path) in
18 Added: let is_active = String.ends_with ~suffix:path repo_path in
16 19 let attrs = if is_active then [ id "active" ] else [] in
17 Removed: let url =
18 Removed: if String.equal path "/" then Printf.sprintf "/%s/" current_path
19 Removed: else Printf.sprintf "/%s/%s" current_path path
20 Removed: in
20 Added: let url = Printf.sprintf "/%s/%s" repo_path path in
21 21 li attrs [ a [ href "%s" url ] [ txt text ] ]
22 22 in
23 23 nav
@@ -26,7 +26,7 @@
26 26 ul []
27 27 @@ List.map li_of_a
28 28 [
29 Removed: ("/", "summary");
29 Added: ("", "summary");
30 30 ("refs/", "refs");
31 31 ("log/", "log");
32 32 ("tree/", "tree");
@@ -40,6 +40,10 @@
40 40 open HTML
41 41
42 42 let header title subtitle =
43 Added: let subtitle =
44 Added: if String.starts_with ~prefix:"Unnamed repository" subtitle then ""
45 Added: else subtitle
46 Added: in
43 47 null [ h1 [] [ txt "%s" title ]; h2 [] [ txt "%s" subtitle ] ]
44 48
45 49 let footer () =
@@ -63,7 +67,7 @@
63 67 body []
64 68 [
65 69 header body_data.title body_data.subtitle;
66 Removed: Components.topnav body_data.title;
70 Added: body_data.topnav;
67 71 div [ id "main" ] body_data.content;
68 72 footer ();
69 73 ];
@@ -85,6 +89,7 @@
85 89 {
86 90 title = "Ogit";
87 91 subtitle = "Repositories for " ^ Config.author;
92 Added: topnav = HTML.null [];
88 93 content = [ repositories_in Config.git_directory ];
89 94 }
90 95 in
@@ -126,6 +131,7 @@
126 131 {
127 132 title = repo_path;
128 133 subtitle = Git_helpers.repo_description repo_path;
134 Added: topnav = Components.topnav repo_path;
129 135 content;
130 136 }
131 137
@@ -136,6 +142,7 @@
136 142 {
137 143 title = repo_path;
138 144 subtitle = Git_helpers.repo_description repo_path;
145 Added: topnav = Components.topnav repo_path;
139 146 content = [ null [] ];
140 147 }
141 148
@@ -146,6 +153,7 @@
146 153 {
147 154 title = repo_path;
148 155 subtitle = Git_helpers.repo_description repo_path;
156 Added: topnav = Components.topnav repo_path;
149 157 content = [ null [] ];
150 158 }
151 159
@@ -156,6 +164,7 @@
156 164 {
157 165 title = repo_path;
158 166 subtitle = Git_helpers.repo_description repo_path;
167 Added: topnav = Components.topnav repo_path;
159 168 content = [ null [] ];
160 169 }
161 170
@@ -165,7 +174,8 @@
165 174 let message = match commit.message with Some msg -> msg | None -> "" in
166 175 let content = HTML.[ h3 [] [ txt "%s" message ] ] in
167 176 let title = Printf.sprintf "%s : %s" repo_path (short_hash commit.hash) in
168 Removed: Page.render { title; subtitle = ""; content }
177 Added: Page.render
178 Added: { title; subtitle = ""; topnav = Components.topnav repo_path; content }
169 179 end
170 180
171 181 let error_page message =