Show only commit summary in lists, full body on commit page

- Commit lists (Summary, Commits pages) now display only the first line - Commit detail page shows summary as h3 heading, body as monospace paragraph - Add .commit-body CSS for pre-wrapped mono font styling

Commit
2deb0d20d5277b8ffc742d87020ef4012f435150
Author
Marius Peter <dev@marius-peter.com>
Author date
Committer
Marius Peter <dev@marius-peter.com>
Committer date
Changed files
lib/static/styles.css
index b37bf9df..81dd93ca 100644..100644
@@ -125,6 +125,15 @@
125 125 overflow-wrap: anywhere;
126 126 }
127 127
128 Added: .commit-body {
129 Added: font-family: monospace;
130 Added: white-space: pre-wrap;
131 Added: background: #1e1e1e;
132 Added: padding: 0.75em 1em;
133 Added: border-radius: 0.25rem;
134 Added: border: 1px solid #303030;
135 Added: }
136 Added:
128 137 .diff-file {
129 138 margin: 1.5em 0;
130 139 border: 1px solid #3a3a3a;
lib/views.ml
index 0368b3bc..e55cffa8 100644..100644
@@ -140,6 +140,24 @@
140 140 let li_of_tag repo (tag : Resolvers.Reference.t) =
141 141 HTML.(li [] [ Routes.link_to (Tags repo) (txt "%s" tag.name) ])
142 142
143 Added: let commit_summary message =
144 Added: match message with
145 Added: | None -> ""
146 Added: | Some msg -> (
147 Added: match String.split_on_char '\n' msg with
148 Added: | [] -> ""
149 Added: | first :: _ -> first)
150 Added:
151 Added: let commit_body message =
152 Added: match message with
153 Added: | None -> ""
154 Added: | Some msg -> (
155 Added: match String.split_on_char '\n' msg with
156 Added: | [] | [ _ ] -> ""
157 Added: | _ :: rest ->
158 Added: let body = String.concat "\n" rest |> String.trim in
159 Added: body)
160 Added:
143 161 let li_of_commit repo (commit : Resolvers.Commit.t) =
144 162 let timestamp (date, _) =
145 163 let tm = date |> Int64.to_float |> Unix.localtime in
@@ -147,14 +165,12 @@
147 165 (tm.tm_mon + 1) tm.tm_mday tm.tm_hour tm.tm_min
148 166 in
149 167 let timestamp_span =
150 Removed: (* HTML.(span [ class_ "commit-hash" ] [ txt "%s" commit.datetime ]) *)
151 168 HTML.(
152 169 span [ class_ "timestamp" ] [ txt "%s" (timestamp commit.author.date) ])
153 170 in
171 Added: let summary = commit_summary commit.message in
154 172 let description =
155 Removed: match commit.message with
156 Removed: | None -> HTML.null []
157 Removed: | Some msg -> txt " %s" msg
173 Added: if summary = "" then HTML.null [] else txt " %s" summary
158 174 in
159 175 let route = Routes.Commit (repo, commit.hash) in
160 176 let node = HTML.null [ timestamp_span; description ] in
@@ -233,7 +249,8 @@
233 249 }
234 250
235 251 let commit repo (commit : Resolvers.Commit.t) diff =
236 Removed: let message = match commit.message with Some msg -> msg | None -> "" in
252 Added: let commit_summary_text = commit_summary commit.message in
253 Added: let commit_body_text = commit_body commit.message in
237 254 let number = function Some number -> string_of_int number | None -> "" in
238 255 let line (line : Resolvers.Diff.line) =
239 256 let class_name, marker =
@@ -309,7 +326,11 @@
309 326 content =
310 327 HTML.(
311 328 [
312 Removed: h3 [] [ txt "%s" message ];
329 Added: h3 [] [ txt "%s" commit_summary_text ];
330 Added: ]
331 Added: @ (if commit_body_text = "" then []
332 Added: else [ p [ class_ "commit-body" ] [ txt "%s" commit_body_text ] ])
333 Added: @ [
313 334 dl
314 335 [ class_ "commit-meta" ]
315 336 [