Start working with utop session stashes...

Hopefully, this will increase developement velocity!

Commit
1ab828cd61c355e8918ce864ba08bb2ba864be2a
Author
Marius Peter <marius.peter@tutanota.com>
Author date
Committer
Marius Peter <marius.peter@tutanota.com>
Committer date
Changed files
lib/handlers.ml
index d50eca87..171cef21 100644..100644
@@ -6,7 +6,7 @@
6 6
7 7 let repo_tree req =
8 8 let repo_name = Dream.param req "repo_name" in
9 Removed: let dir_path = Dream.query req "path" |> Option.value ~default:"" in
9 Added: let dir_path = Dream.target req in
10 10 Views.Repo_tree.render repo_name dir_path |> Dream_html.respond
11 11
12 12 let repo_blob req =
lib/views.ml
index 66218316..bbb9de51 100644..100644
@@ -101,13 +101,17 @@
101 101 open Dream_html
102 102 open HTML
103 103
104 Added: let branches =
105 Added: let repo_path = Fpath.v "/home/blendux/git.test/ogit.git/" in
106 Added: let load_repo () = Git_unix.Store.v ~dotgit:repo_path repo_path in
107 Added: let store = Lwt_main.run @@ load_repo () in
108 Added: let refs = Lwt_main.run @@ Git_unix.Store.Ref.list @@ Result.get_ok store in
109 Added: refs |> List.map fst |> List.map Git.Reference.to_string
110 Added:
104 111 let render repo_path =
105 112 let title = repo_path in
106 113 let subtitle = Filename.concat Config.git_directory repo_path in
107 Removed: let all_branches = Git_unhelpers.get_all_branches repo_path in
108 Removed: let li_of_branch branch =
109 Removed: li [] [ a [ href "%s" branch ] [ txt "%s" branch ] ]
110 Removed: in
114 Added: let li_of_branch hash = li [] [ txt "%s" hash ] in
111 115 let recent_commits = Git_unhelpers.get_latest_commits repo_path 10 in
112 116 let li_of_commit commit =
113 117 li [] [ a [ href "%s" commit ] [ txt "%s" commit ] ]
@@ -115,7 +119,7 @@
115 119 let content =
116 120 [
117 121 h3 [] [ txt "Branches" ];
118 Removed: ul [] (List.map li_of_branch all_branches);
122 Added: ul [] (List.map li_of_branch branches);
119 123 h3 [] [ txt "Recent commits" ];
120 124 ul [] (List.map li_of_commit recent_commits);
121 125 ]
@@ -159,50 +163,15 @@
159 163 let display_name = if is_dir then entry ^ "/" else entry in
160 164 li [] [ a [ href "%s" link ] [ txt "%s" display_name ] ]
161 165
162 Removed: (* Generate breadcrumb navigation for the directory path *)
163 Removed: let breadcrumb_navigation repo_name dir_path =
164 Removed: let parts = String.split_on_char '/' dir_path in
165 Removed:
166 Removed: let rec build_paths acc paths =
167 Removed: match paths with
168 Removed: | [] -> List.rev acc
169 Removed: | part :: rest ->
170 Removed: let new_path =
171 Removed: match acc with [] -> part | _ -> List.hd acc ^ "/" ^ part
172 Removed: in
173 Removed: build_paths (new_path :: acc) rest
174 Removed: in
175 Removed:
176 Removed: let breadcrumb_links =
177 Removed: build_paths [] parts
178 Removed: |> List.mapi (fun i path ->
179 Removed: let display_name = List.nth parts i in
180 Removed: a
181 Removed: [ href "%s" (Printf.sprintf "/%s/tree?path=%s" repo_name path) ]
182 Removed: [ txt "%s" display_name ])
183 Removed: in
184 Removed:
185 Removed: (* Manually intersperse " / " separators *)
186 Removed: let rec intersperse sep = function
187 Removed: | [] -> []
188 Removed: | [ x ] -> [ x ]
189 Removed: | x :: xs -> x :: txt sep :: intersperse sep xs
190 Removed: in
191 Removed:
192 Removed: match breadcrumb_links with
193 Removed: | [] -> txt "/"
194 Removed: | _ -> span [] (intersperse " / " breadcrumb_links)
195 Removed:
196 166 (* Render function *)
197 167 let render repo_name dir_path =
198 168 let title = repo_name in
199 Removed: (* Only display the repo name as the title *)
200 169 let subtitle = "Files" in
201 170
202 Removed: let repo_entries = ls_dir repo_name dir_path in
171 Added: let repo_entries = ls_dir repo_name @@ dir_path in
203 172 let content =
204 173 [
205 Removed: h3 [] [ breadcrumb_navigation repo_name dir_path ];
174 Added: txt "%s" dir_path;
206 175 ul [] (List.map (link_for_entry repo_name) repo_entries);
207 176 ]
208 177 in