[OCaml] Mobile-friendly clone of cgit.
Improve page title.
lib/views.ml
@@ -4,8 +4,6 @@
4
4
open Git_presenters
5
5
open Config
6
6
7
Removed:
type head_data = { page_title : string }
8
Removed:
9
7
type body_data = {
10
8
title : string;
11
9
subtitle : string;
@@ -58,14 +56,12 @@
58
56
let footer_text = Printf.sprintf "Copyright %s %s" year config.user in
59
57
footer [] [ txt "%s" footer_text ]
60
58
61
Removed:
let default_head_data = { page_title = "Ogit" }
62
Removed:
63
Removed:
let render ?(head_data = default_head_data) body_data =
59
Added:
let render ?(page_title = "Ogit") body_data =
64
60
html []
65
61
[
66
62
head []
67
63
[
68
Removed:
title [] "%s" head_data.page_title;
64
Added:
title [] "%s" page_title;
69
65
link [ rel "stylesheet"; href "/static/styles.css" ];
70
66
link
71
67
[ rel "icon"; type_ "image/x-icon"; href "/static/git_icon.svg" ];
@@ -102,6 +98,8 @@
102
98
Page.render body_data
103
99
104
100
module Repo = struct
101
Added:
let page_title repo = Printf.sprintf "%s — %s" repo (repo_description repo)
102
Added:
105
103
let summary repo branches commits authors =
106
104
let li_of_branch branch =
107
105
HTML.(li [] [ a [ href "%s" branch.name ] [ txt "%s" branch.name ] ])
@@ -132,10 +130,10 @@
132
130
ul [] (List.map li_of_author authors);
133
131
]
134
132
in
135
Removed:
Page.render
133
Added:
Page.render ~page_title:(page_title repo)
136
134
{
137
135
title = repo;
138
Removed:
subtitle = Git_presenters.repo_description repo;
136
Added:
subtitle = repo_description repo;
139
137
topnav = Components.topnav repo;
140
138
content;
141
139
}
@@ -144,15 +142,16 @@
144
142
let li_of_branch branch =
145
143
HTML.(li [] [ a [ href "%s" branch.name ] [ txt "%s" branch.name ] ])
146
144
in
147
Removed:
Page.render
148
Removed:
HTML.
149
Removed:
{
150
Removed:
title = repo;
151
Removed:
subtitle = Git_presenters.repo_description repo;
152
Removed:
topnav = Components.topnav repo;
153
Removed:
content =
154
Removed:
[ h3 [] [ txt "Branches" ]; ul [] (List.map li_of_branch branches) ];
155
Removed:
}
145
Added:
let content =
146
Added:
HTML.[ h3 [] [ txt "Branches" ]; ul [] (List.map li_of_branch branches) ]
147
Added:
in
148
Added:
Page.render ~page_title:(page_title repo)
149
Added:
{
150
Added:
title = repo;
151
Added:
subtitle = repo_description repo;
152
Added:
topnav = Components.topnav repo;
153
Added:
content;
154
Added:
}
156
155
157
156
let log repo commits =
158
157
let li_of_commit commit =
@@ -167,34 +166,39 @@
167
166
])
168
167
| None -> HTML.(li [] [ a [ href "" ] [ txt "caca!!" ] ])
169
168
in
170
Removed:
Page.render
169
Added:
let content =
171
170
HTML.
172
Removed:
{
173
Removed:
title = repo;
174
Removed:
subtitle = Git_presenters.repo_description repo;
175
Removed:
topnav = Components.topnav repo;
176
Removed:
content =
177
Removed:
[
178
Removed:
h3 [] [ txt "All commits" ]; ul [] (List.map li_of_commit commits);
179
Removed:
];
180
Removed:
}
171
Added:
[ h3 [] [ txt "All commits" ]; ul [] (List.map li_of_commit commits) ]
172
Added:
in
173
Added:
Page.render ~page_title:(page_title repo)
174
Added:
{
175
Added:
title = repo;
176
Added:
subtitle = repo_description repo;
177
Added:
topnav = Components.topnav repo;
178
Added:
content;
179
Added:
}
181
180
182
181
let tree repo =
183
Removed:
Page.render
184
Removed:
HTML.
185
Removed:
{
186
Removed:
title = repo;
187
Removed:
subtitle = Git_presenters.repo_description repo;
188
Removed:
topnav = Components.topnav repo;
189
Removed:
content = [ null [] ];
190
Removed:
}
182
Added:
let content = HTML.[ null [] ] in
183
Added:
Page.render ~page_title:(page_title repo)
184
Added:
{
185
Added:
title = repo;
186
Added:
subtitle = repo_description repo;
187
Added:
topnav = Components.topnav repo;
188
Added:
content;
189
Added:
}
191
190
192
191
let commit repo commit =
193
192
let message = match commit.message with Some msg -> msg | None -> "" in
194
Removed:
let content = HTML.[ h3 [] [ txt "%s" message ] ] in
195
193
let title = Printf.sprintf "%s : %s" repo commit.short_hash in
196
Removed:
Page.render
197
Removed:
{ title; subtitle = ""; topnav = Components.topnav repo; content }
194
Added:
let content = HTML.[ h3 [] [ txt "%s" message ] ] in
195
Added:
Page.render ~page_title:(page_title repo)
196
Added:
{
197
Added:
title;
198
Added:
subtitle = repo_description repo;
199
Added:
topnav = Components.topnav repo;
200
Added:
content;
201
Added:
}
198
202
end
199
203
200
204
let error_page message =