summaryrefslogtreecommitdiff
path: root/lib/views.ml
diff options
context:
space:
mode:
authorMarius Peter <marius.peter@tutanota.com>2025-06-09 18:09:55 +0200
committerMarius Peter <marius.peter@tutanota.com>2025-06-09 18:09:55 +0200
commitafe686e6bab1d4b6a85b1f5c610f57fcf1a72d74 (patch)
treedd86520bff4d24522a750c8dfee04a1b59ec728f /lib/views.ml
parentef89b655e942603605d0d94837ba2407f86352bf (diff)
Implement blob display.
Diffstat (limited to 'lib/views.ml')
-rw-r--r--lib/views.ml16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/views.ml b/lib/views.ml
index e1056b7..029e311 100644
--- a/lib/views.ml
+++ b/lib/views.ml
@@ -199,10 +199,22 @@ module Repo = struct
content;
}
- let blob repo blob =
+ let file repo blob =
let title = Printf.sprintf "%s" repo in
+ let to_numbered_line number line =
+ let n = number + 1 in
+ HTML.
+ [
+ a [ id "%d" n; class_ "line-anchor"; href "#%d" n ] [ txt "%d" n ];
+ span [ class_ "line" ] [ txt "\t%s\n" line ];
+ ]
+ in
+ let formatted_blob =
+ String.split_on_char '\n' blob.content
+ |> List.mapi to_numbered_line |> List.flatten
+ in
let content =
- HTML.[ h3 [] [ txt "Blob" ]; p [] [ txt "%s" blob.content ] ]
+ HTML.[ h3 [] [ txt "File" ]; div [ id "blob" ] formatted_blob ]
in
Page.render ~page_title:(page_title repo)
{
Copyright 2019--2025 Marius PETER