Routes.link_to now accepts arbitrary nodes as content.

Commit
0647fb79dea80219ea0b0be2b315163d9a5d3ae2
Author
Marius Peter <marius.peter@tutanota.com>
Author date
Committer
Marius Peter <marius.peter@tutanota.com>
Committer date
Changed files
lib/routes.ml
index 0778c18f..c136152a 100644..100644
@@ -12,7 +12,7 @@
12 12 | Blob of string * string * string
13 13
14 14 let%path root_path = "/"
15 Removed: let%path repo_path = "/%s"
15 Added: let%path repo_path = "/%s/"
16 16 let%path tag_path = "/%s/refs/%s"
17 17 let%path commit_path = "/%s/commit/%s"
18 18 let%path tree_path = "/%s/tree/%s/%s"
@@ -26,5 +26,4 @@
26 26 | Tree (repo, commit, path) -> path_attr href tree_path repo commit path
27 27 | Blob (repo, commit, path) -> path_attr href blob_path repo commit path
28 28
29 Removed: let link_to label route = a [ path_attr route ] [ txt "%s" label ]
30 Removed: let li_of_repo repo = li [] [ link_to repo (Repo repo) ]
29 Added: let link_to route content = a [ path_attr route ] [ content ]
lib/static/styles.css
index ae8a86c4..f72a4732 100644..100644
@@ -76,3 +76,7 @@
76 76 background: inherit;
77 77 padding: 0.5em 0;
78 78 }
79 Added:
80 Added: .commit-hash {
81 Added: font-family: monospace;
82 Added: }
lib/views.ml
index 283d8d9d..b6cf6174 100644..100644
@@ -82,8 +82,10 @@
82 82 Sys.readdir config.git_project_root
83 83 |> Array.to_list |> List.sort String.compare
84 84 in
85 Removed: HTML.(
86 Removed: div [ id "repositories" ] [ ul [] @@ List.map Routes.li_of_repo repos ])
85 Added: let li_of_repo repo =
86 Added: HTML.li [] [ Routes.link_to (Routes.Repo repo) (txt "%s" repo) ]
87 Added: in
88 Added: HTML.(div [ id "repositories" ] [ ul [] @@ List.map li_of_repo repos ])
87 89 in
88 90 let body_data =
89 91 {
@@ -99,19 +101,24 @@
99 101 let page_title repo = Printf.sprintf "%s — %s" repo (repo_description repo)
100 102
101 103 let li_of_branch repo (branch : branch) =
102 Removed: HTML.(li [] [ Routes.link_to branch.name (Tag (repo, branch.name)) ])
104 Added: HTML.(
105 Added: li [] [ Routes.link_to (Tag (repo, branch.name)) (txt "%s" branch.name) ])
103 106
104 107 let li_of_commit repo commit =
108 Added: let open HTML in
105 109 match commit.message with
110 Added: | None -> li [] [ txt "%s" commit.short_hash ]
106 111 | Some msg ->
107 Removed: HTML.(
108 Removed: li []
109 Removed: [
110 Removed: Routes.link_to
111 Removed: (commit.short_hash ^ " - " ^ msg)
112 Removed: (Commit (repo, commit.hash));
113 Removed: ])
114 Removed: | None -> HTML.(li [] [ txt "%s" commit.short_hash ])
112 Added: li []
113 Added: [
114 Added: Routes.link_to
115 Added: (Commit (repo, commit.hash))
116 Added: (null
117 Added: [
118 Added: span [ class_ "commit-hash" ] [ txt "%s" commit.short_hash ];
119 Added: txt " — %s" msg;
120 Added: ]);
121 Added: ]
115 122
116 123 let summary repo branches commits authors =
117 124 let li_of_branch = li_of_branch repo in