Implement blob display.

Commit
afe686e6bab1d4b6a85b1f5c610f57fcf1a72d74
Author
Marius Peter <marius.peter@tutanota.com>
Author date
Committer
Marius Peter <marius.peter@tutanota.com>
Committer date
Changed files
lib/static/styles.css
index f72a4732..ad38179f 100644..100644
@@ -71,12 +71,56 @@
71 71 }
72 72
73 73 h1 {
74 Removed: position: sticky;
75 Removed: top: 0;
76 Removed: background: inherit;
74 Added: /* position: sticky; */
75 Added: /* top: 0; */
76 Added: /* background: inherit; */
77 77 padding: 0.5em 0;
78 78 }
79 79
80 80 .commit-hash {
81 81 font-family: monospace;
82 Added: }
83 Added:
84 Added: #blob {
85 Added: display: grid;
86 Added: column-gap: 1.5em;
87 Added: grid-template-columns: 3em auto;
88 Added: font-family: monospace;
89 Added: }
90 Added:
91 Added: #blob a.line-anchor {
92 Added: color: grey;
93 Added: text-decoration: none;
94 Added: text-align: right;
95 Added: }
96 Added:
97 Added: #blob a.line-anchor:target {
98 Added: color: white;
99 Added: background-color: grey;
100 Added: }
101 Added:
102 Added: #blob a.line-anchor:hover {
103 Added: color: skyblue;
104 Added: background-color: inherit;
105 Added: text-decoration: none;
106 Added: }
107 Added:
108 Added: #blob span.line {
109 Added: white-space: preserve-spaces;
110 Added: }
111 Added:
112 Added: footer {
113 Added: margin-top: 1em;
114 Added: text-align: center;
115 Added: }
116 Added:
117 Added: @media (max-width: 400px) {
118 Added: body {
119 Added: padding: 0;
120 Added: }
121 Added:
122 Added: #blob {
123 Added: column-gap: 1em;
124 Added: grid-template-columns: max-content auto;
125 Added: }
82 126 }
lib/views.ml
index e1056b7d..029e3116 100644..100644
@@ -199,10 +199,22 @@
199 199 content;
200 200 }
201 201
202 Removed: let blob repo blob =
202 Added: let file repo blob =
203 203 let title = Printf.sprintf "%s" repo in
204 Added: let to_numbered_line number line =
205 Added: let n = number + 1 in
206 Added: HTML.
207 Added: [
208 Added: a [ id "%d" n; class_ "line-anchor"; href "#%d" n ] [ txt "%d" n ];
209 Added: span [ class_ "line" ] [ txt "\t%s\n" line ];
210 Added: ]
211 Added: in
212 Added: let formatted_blob =
213 Added: String.split_on_char '\n' blob.content
214 Added: |> List.mapi to_numbered_line |> List.flatten
215 Added: in
204 216 let content =
205 Removed: HTML.[ h3 [] [ txt "Blob" ]; p [] [ txt "%s" blob.content ] ]
217 Added: HTML.[ h3 [] [ txt "File" ]; div [ id "blob" ] formatted_blob ]
206 218 in
207 219 Page.render ~page_title:(page_title repo)
208 220 {