[OCaml] Mobile-friendly clone of cgit.
Refactor + proper implementation for refs and log pages.
Great progress! Ogit is increasingly looking like a usable (useful?) product.
lib/views.ml
@@ -1,5 +1,7 @@
1
1
(* -*- mode: tuareg; -*- *)
2
2
3
Added:
open Dream_html
4
Added:
open Git_presenters
3
5
open Config
4
6
5
7
type head_data = { page_title : string }
@@ -79,10 +81,10 @@
79
81
end
80
82
81
83
let root () =
82
Removed:
let open Dream_html in
83
Removed:
let repositories_in directory =
84
Added:
let all_repositories =
84
85
let repos =
85
Removed:
Sys.readdir directory |> Array.to_list |> List.sort String.compare
86
Added:
Sys.readdir config.git_project_root
87
Added:
|> Array.to_list |> List.sort String.compare
86
88
in
87
89
let li_of_repo repo =
88
90
HTML.(li [] [ a [ href "%s/" repo ] [ txt "%s" repo ] ])
@@ -94,18 +96,17 @@
94
96
title = "Ogit";
95
97
subtitle = "Repositories for " ^ config.user;
96
98
topnav = HTML.null [];
97
Removed:
content = [ repositories_in config.repositories_root_path ];
99
Added:
content = [ all_repositories ];
98
100
}
99
101
in
100
102
Page.render body_data
101
103
102
104
module Repo = struct
103
105
let summary repo branches commits authors =
104
Removed:
let open Dream_html in
105
106
let li_of_branch branch =
106
Removed:
HTML.(li [] [ a [ href "%s" branch ] [ txt "%s" branch ] ])
107
Added:
HTML.(li [] [ a [ href "%s" branch.name ] [ txt "%s" branch.name ] ])
107
108
in
108
Removed:
let li_of_commit (commit : Git_presenters.Commit.t) =
109
Added:
let li_of_commit commit =
109
110
match commit.message with
110
111
| Some msg ->
111
112
HTML.(
@@ -139,30 +140,46 @@
139
140
content;
140
141
}
141
142
142
Removed:
let refs repo =
143
Removed:
let open Dream_html in
143
Added:
let refs repo branches =
144
Added:
let li_of_branch branch =
145
Added:
HTML.(li [] [ a [ href "%s" branch.name ] [ txt "%s" branch.name ] ])
146
Added:
in
144
147
Page.render
145
148
HTML.
146
149
{
147
150
title = repo;
148
151
subtitle = Git_presenters.repo_description repo;
149
152
topnav = Components.topnav repo;
150
Removed:
content = [ null [] ];
153
Added:
content =
154
Added:
[ h3 [] [ txt "Branches" ]; ul [] (List.map li_of_branch branches) ];
151
155
}
152
156
153
Removed:
let log repo =
154
Removed:
let open Dream_html in
157
Added:
let log repo commits =
158
Added:
let li_of_commit commit =
159
Added:
match commit.message with
160
Added:
| Some msg ->
161
Added:
HTML.(
162
Added:
li []
163
Added:
[
164
Added:
a
165
Added:
[ href "commit/?id=%s" commit.hash ]
166
Added:
[ txt "%s %s" commit.short_hash msg ];
167
Added:
])
168
Added:
| None -> HTML.(li [] [ a [ href "" ] [ txt "caca!!" ] ])
169
Added:
in
155
170
Page.render
156
171
HTML.
157
172
{
158
173
title = repo;
159
174
subtitle = Git_presenters.repo_description repo;
160
175
topnav = Components.topnav repo;
161
Removed:
content = [ null [] ];
176
Added:
content =
177
Added:
[
178
Added:
h3 [] [ txt "All commits" ]; ul [] (List.map li_of_commit commits);
179
Added:
];
162
180
}
163
181
164
182
let tree repo =
165
Removed:
let open Dream_html in
166
183
Page.render
167
184
HTML.
168
185
{
@@ -172,8 +189,7 @@
172
189
content = [ null [] ];
173
190
}
174
191
175
Removed:
let commit repo (commit : Git_presenters.Commit.t) =
176
Removed:
let open Dream_html in
192
Added:
let commit repo commit =
177
193
let message = match commit.message with Some msg -> msg | None -> "" in
178
194
let content = HTML.[ h3 [] [ txt "%s" message ] ] in
179
195
let title = Printf.sprintf "%s : %s" repo commit.short_hash in
@@ -182,7 +198,6 @@
182
198
end
183
199
184
200
let error_page message =
185
Removed:
let open Dream_html in
186
201
HTML.(
187
202
html []
188
203
[