summaryrefslogtreecommitdiff
path: root/lib/views
diff options
context:
space:
mode:
Diffstat (limited to 'lib/views')
-rw-r--r--lib/views/dune4
-rw-r--r--lib/views/layouts.ml45
-rw-r--r--lib/views/ogit_root.ml12
-rw-r--r--lib/views/repo_root.ml41
4 files changed, 0 insertions, 102 deletions
diff --git a/lib/views/dune b/lib/views/dune
deleted file mode 100644
index 2c9ab5e..0000000
--- a/lib/views/dune
+++ /dev/null
@@ -1,4 +0,0 @@
-(library
- (name views)
- (public_name ogit.views)
- (libraries dream-html git-unix))
diff --git a/lib/views/layouts.ml b/lib/views/layouts.ml
deleted file mode 100644
index d9def3c..0000000
--- a/lib/views/layouts.ml
+++ /dev/null
@@ -1,45 +0,0 @@
-open Dream_html
-open HTML
-
-let header =
- div []
- [
- h1 [] [ txt "ogit" ];
- h2 [] [ txt "A mobile-friendly Git repository viewer" ];
- ]
-
-let topnav =
- nav
- [ id "top" ]
- [
- ul []
- [
- li [] [ a [ href "/" ] [ txt "Home" ] ];
- li [] [ a [ href "/" ] [ txt "Refs" ] ];
- li [] [ a [ href "/" ] [ txt "Log" ] ];
- li [] [ a [ href "/" ] [ txt "Tree" ] ];
- li [] [ a [ href "/" ] [ txt "Commit" ] ];
- li [] [ a [ href "/" ] [ txt "Diff" ] ];
- ];
- ]
-
-let footer name =
- let today = Unix.localtime (Unix.time ()) in
- let year = string_of_int (today.Unix.tm_year + 1900) in
- let space = " " in
- let footer_text = String.concat space [ "©"; year; name ] in
- footer [] [ txt "%s" footer_text ]
-
-let application ?(page_title = "ogit") ?(head_content = null []) ~main_content
- () =
- html []
- [
- head [] [ title [] "%s" page_title; head_content ];
- body []
- [
- header;
- topnav;
- div [ id "main" ] [ main_content ];
- footer "Marius PETER";
- ];
- ]
diff --git a/lib/views/ogit_root.ml b/lib/views/ogit_root.ml
deleted file mode 100644
index ca8e870..0000000
--- a/lib/views/ogit_root.ml
+++ /dev/null
@@ -1,12 +0,0 @@
-open Dream_html
-open HTML
-
-let git_directory = Filename.concat (Unix.getenv "HOME") "git"
-
-let repositories_in directory =
- let repositories = Sys.readdir directory |> Array.to_list
- and li_of_repo repo = li [] [ a [ href "%s" repo ] [ txt "%s" repo ] ] in
- div [ id "repositories" ] [ ul [] @@ List.map li_of_repo repositories ]
-
-let main_content = null [ txt "Hello World!"; repositories_in git_directory ]
-let render = Layouts.application ~page_title:"My repositories" ~main_content
diff --git a/lib/views/repo_root.ml b/lib/views/repo_root.ml
deleted file mode 100644
index dd391d8..0000000
--- a/lib/views/repo_root.ml
+++ /dev/null
@@ -1,41 +0,0 @@
-open Dream_html
-open HTML
-open Git_unix
-
-let git_directory = Filename.concat (Unix.getenv "HOME") "git"
-
-let err_to_string err = Fmt.to_to_string Store.pp_error err
-
-let get_head_commit repo_path =
- Lwt_main.run (
- let open Lwt.Infix in
- match Git.Reference.of_string "HEAD" with
- | Error err ->
- Lwt.return (Error ("Invalid HEAD reference string: " ^ err_to_string err))
- | Ok head_ref_name ->
- Store.v (Fpath.v repo_path) >>= function
- | Error err ->
- Lwt.return (Error ("Failed to open repository: " ^ err_to_string err))
- | Ok store ->
- Store.Ref.resolve store head_ref_name >>= function
- | Error err ->
- Lwt.return (Error ("Failed to resolve HEAD: " ^ err_to_string err))
- | Ok head_oid -> Lwt.return (Ok head_oid)
- (* Git.Commit.v store head_oid >>= function *)
- (* | Error err -> *)
- (* Lwt.return (Error ("Failed to get commit from hash: " ^ err_to_string err)) *)
- (* | Ok commit -> *)
- (* Lwt.return (Ok commit) *)
- )
-
-let main_content =
- let open Lwt.Infix in
- Lwt.async (fun _ ->
- get_head_commit git_directory >>= function
- | Error msg ->
- Lwt.map (fun content -> [ p [] [ txt content ]]) (Error msg)
- | Ok head_oid ->
- Lwt.map (fun content -> [ p [] [ txt "HEAD commit hash: %s" content ]]) (Store.Hash.to_string head_oid)
- )
-
-let render = Layouts.application ~page_title:"My repositories" ~main_content
Copyright 2019--2025 Marius PETER