diff options
-rw-r--r-- | lib/routes.ml | 5 | ||||
-rw-r--r-- | lib/static/styles.css | 4 | ||||
-rw-r--r-- | lib/views.ml | 29 |
3 files changed, 24 insertions, 14 deletions
diff --git a/lib/routes.ml b/lib/routes.ml index 0778c18..c136152 100644 --- a/lib/routes.ml +++ b/lib/routes.ml @@ -12,7 +12,7 @@ type t = | Blob of string * string * string let%path root_path = "/" -let%path repo_path = "/%s" +let%path repo_path = "/%s/" let%path tag_path = "/%s/refs/%s" let%path commit_path = "/%s/commit/%s" let%path tree_path = "/%s/tree/%s/%s" @@ -26,5 +26,4 @@ let path_attr = function | Tree (repo, commit, path) -> path_attr href tree_path repo commit path | Blob (repo, commit, path) -> path_attr href blob_path repo commit path -let link_to label route = a [ path_attr route ] [ txt "%s" label ] -let li_of_repo repo = li [] [ link_to repo (Repo repo) ] +let link_to route content = a [ path_attr route ] [ content ] diff --git a/lib/static/styles.css b/lib/static/styles.css index ae8a86c..f72a473 100644 --- a/lib/static/styles.css +++ b/lib/static/styles.css @@ -76,3 +76,7 @@ h1 { background: inherit; padding: 0.5em 0; } + +.commit-hash { + font-family: monospace; +} diff --git a/lib/views.ml b/lib/views.ml index 283d8d9..b6cf617 100644 --- a/lib/views.ml +++ b/lib/views.ml @@ -82,8 +82,10 @@ let root () = Sys.readdir config.git_project_root |> Array.to_list |> List.sort String.compare in - HTML.( - div [ id "repositories" ] [ ul [] @@ List.map Routes.li_of_repo repos ]) + let li_of_repo repo = + HTML.li [] [ Routes.link_to (Routes.Repo repo) (txt "%s" repo) ] + in + HTML.(div [ id "repositories" ] [ ul [] @@ List.map li_of_repo repos ]) in let body_data = { @@ -99,19 +101,24 @@ module Repo = struct let page_title repo = Printf.sprintf "%s — %s" repo (repo_description repo) let li_of_branch repo (branch : branch) = - HTML.(li [] [ Routes.link_to branch.name (Tag (repo, branch.name)) ]) + HTML.( + li [] [ Routes.link_to (Tag (repo, branch.name)) (txt "%s" branch.name) ]) let li_of_commit repo commit = + let open HTML in match commit.message with + | None -> li [] [ txt "%s" commit.short_hash ] | Some msg -> - HTML.( - li [] - [ - Routes.link_to - (commit.short_hash ^ " - " ^ msg) - (Commit (repo, commit.hash)); - ]) - | None -> HTML.(li [] [ txt "%s" commit.short_hash ]) + li [] + [ + Routes.link_to + (Commit (repo, commit.hash)) + (null + [ + span [ class_ "commit-hash" ] [ txt "%s" commit.short_hash ]; + txt " — %s" msg; + ]); + ] let summary repo branches commits authors = let li_of_branch = li_of_branch repo in |