[OCaml] Mobile-friendly clone of cgit.
Regroup Dream_html functionality in Views module.
Changed files
lib/handlers.ml
@@ -1,6 +1,6 @@
1
1
(* -*- mode: tuareg; -*- *)
2
2
3
Removed:
let root _req = Views.root () |> Dream_html.respond
3
Added:
let root _req = Views.root ()
4
4
5
5
module Repo = struct
6
6
open Git_presenters
@@ -20,29 +20,29 @@
20
20
let* branches = all_branches (repo req) in
21
21
let* commits = recent_commits (repo req) 10 in
22
22
let authors = [ "John Pork"; "Sebastian Jellybean" ] in
23
Removed:
Views.Repo.summary (repo req) branches commits authors |> Dream_html.respond
23
Added:
Views.Repo.summary (repo req) branches commits authors
24
24
25
25
let log req =
26
26
let* commits = recent_commits (repo req) 100 in
27
Removed:
Views.Repo.log (repo req) commits |> Dream_html.respond
27
Added:
Views.Repo.log (repo req) commits
28
28
29
29
let files_at_head req =
30
30
let* tree = head_tree (repo req) in
31
Removed:
Views.Repo.files (repo req) tree |> Dream_html.respond
31
Added:
Views.Repo.files (repo req) tree
32
32
33
33
let file_id req =
34
34
let id = id_of_req req in
35
35
let* blob = blob_of_id (repo req) id in
36
Removed:
Views.Repo.file (repo req) blob |> Dream_html.respond
36
Added:
Views.Repo.file (repo req) blob
37
37
38
38
let refs req =
39
39
let* branches = all_branches (repo req) in
40
Removed:
Views.Repo.refs (repo req) branches |> Dream_html.respond
40
Added:
Views.Repo.refs (repo req) branches
41
41
42
42
let commit req =
43
43
let id = id_of_req req in
44
44
let* commit = commit_of_id (repo req) id in
45
Removed:
Views.Repo.commit (repo req) commit |> Dream_html.respond
45
Added:
Views.Repo.commit (repo req) commit
46
46
end
47
47
48
48
let all_handlers =
lib/views.ml
@@ -91,7 +91,7 @@
91
91
content = [ all_repositories ];
92
92
}
93
93
in
94
Removed:
Page.render body_data
94
Added:
respond @@ Page.render body_data
95
95
96
96
module Repo = struct
97
97
open Git_presenters
@@ -140,13 +140,14 @@
140
140
ul [] (List.map li_of_author authors);
141
141
]
142
142
in
143
Removed:
Page.render ~page_title:(page_title repo)
144
Removed:
{
145
Removed:
title = repo;
146
Removed:
subtitle = repo_description repo;
147
Removed:
topnav = Components.Topnav.(v ~active_path:Summary repo);
148
Removed:
content;
149
Removed:
}
143
Added:
respond
144
Added:
@@ Page.render ~page_title:(page_title repo)
145
Added:
{
146
Added:
title = repo;
147
Added:
subtitle = repo_description repo;
148
Added:
topnav = Components.Topnav.(v ~active_path:Summary repo);
149
Added:
content;
150
Added:
}
150
151
151
152
let refs repo branches =
152
153
let content =
@@ -156,13 +157,14 @@
156
157
ul [] (List.map (li_of_branch repo) branches);
157
158
]
158
159
in
159
Removed:
Page.render ~page_title:(page_title repo)
160
Removed:
{
161
Removed:
title = repo;
162
Removed:
subtitle = repo_description repo;
163
Removed:
topnav = Components.Topnav.(v ~active_path:Refs repo);
164
Removed:
content;
165
Removed:
}
160
Added:
respond
161
Added:
@@ Page.render ~page_title:(page_title repo)
162
Added:
{
163
Added:
title = repo;
164
Added:
subtitle = repo_description repo;
165
Added:
topnav = Components.Topnav.(v ~active_path:Refs repo);
166
Added:
content;
167
Added:
}
166
168
167
169
let log repo commits =
168
170
let content =
@@ -172,13 +174,14 @@
172
174
ul [] (List.map (li_of_commit repo) commits);
173
175
]
174
176
in
175
Removed:
Page.render ~page_title:(page_title repo)
176
Removed:
{
177
Removed:
title = repo;
178
Removed:
subtitle = repo_description repo;
179
Removed:
topnav = Components.Topnav.(v ~active_path:Log repo);
180
Removed:
content;
181
Removed:
}
177
Added:
respond
178
Added:
@@ Page.render ~page_title:(page_title repo)
179
Added:
{
180
Added:
title = repo;
181
Added:
subtitle = repo_description repo;
182
Added:
topnav = Components.Topnav.(v ~active_path:Log repo);
183
Added:
content;
184
Added:
}
182
185
183
186
let files repo tree =
184
187
let title = Printf.sprintf "%s" repo in
@@ -189,13 +192,14 @@
189
192
ul [] (List.map (li_of_entry repo) tree.entries);
190
193
]
191
194
in
192
Removed:
Page.render ~page_title:(page_title repo)
193
Removed:
{
194
Removed:
title;
195
Removed:
subtitle = repo_description repo;
196
Removed:
topnav = Components.Topnav.(v ~active_path:Files repo);
197
Removed:
content;
198
Removed:
}
195
Added:
respond
196
Added:
@@ Page.render ~page_title:(page_title repo)
197
Added:
{
198
Added:
title;
199
Added:
subtitle = repo_description repo;
200
Added:
topnav = Components.Topnav.(v ~active_path:Files repo);
201
Added:
content;
202
Added:
}
199
203
200
204
let file repo blob =
201
205
let title = Printf.sprintf "%s" repo in
@@ -214,25 +218,27 @@
214
218
let content =
215
219
HTML.[ h3 [] [ txt "File" ]; div [ id "blob" ] formatted_blob ]
216
220
in
217
Removed:
Page.render ~page_title:(page_title repo)
218
Removed:
{
219
Removed:
title;
220
Removed:
subtitle = repo_description repo;
221
Removed:
topnav = Components.Topnav.(v ~active_path:Files repo);
222
Removed:
content;
223
Removed:
}
221
Added:
respond
222
Added:
@@ Page.render ~page_title:(page_title repo)
223
Added:
{
224
Added:
title;
225
Added:
subtitle = repo_description repo;
226
Added:
topnav = Components.Topnav.(v ~active_path:Files repo);
227
Added:
content;
228
Added:
}
224
229
225
230
let commit repo commit =
226
231
let message = match commit.message with Some msg -> msg | None -> "" in
227
232
let title = Printf.sprintf "%s : %s" repo commit.short_hash in
228
233
let content = HTML.[ h3 [] [ txt "%s" message ] ] in
229
Removed:
Page.render ~page_title:(page_title repo)
230
Removed:
{
231
Removed:
title;
232
Removed:
subtitle = repo_description repo;
233
Removed:
topnav = Components.Topnav.v repo;
234
Removed:
content;
235
Removed:
}
234
Added:
respond
235
Added:
@@ Page.render ~page_title:(page_title repo)
236
Added:
{
237
Added:
title;
238
Added:
subtitle = repo_description repo;
239
Added:
topnav = Components.Topnav.v repo;
240
Added:
content;
241
Added:
}
236
242
end
237
243
238
244
let error_page message =