feat truncate nested directories with more than seven entries

Nested directories with more than seven children now show only the first three, followed by an '<n> more items...' link to the full directory page. The repository root is exempt and always shows all its direct entries.

Commit
8bdaa612eb7bcb0346d60a261e7455e6ef495cb7
Author
Marius Peter <dev@marius-peter.com>
Author date
Committer
Marius Peter <dev@marius-peter.com>
Committer date
Changed files
lib/views/components.ml
index bead870e..06ca6ffe 100644..100644
@@ -143,8 +143,7 @@
143 143
144 144 (** The row closing a truncated listing, linking to the full contents. *)
145 145 let overflow_row ~route count =
146 Removed: Ui.tree_overflow ~href:(url route)
147 Removed: (Printf.sprintf "%d more items\xe2\x80\xa6" count)
146 Added: Ui.tree_overflow ~href:(url route) (Printf.sprintf "%d more items..." count)
148 147
149 148 (** {1 Sections} *)
150 149
lib/views/repo.ml
index 05c3fbaa..473c2462 100644..100644
@@ -140,10 +140,13 @@
140 140 ]);
141 141 ]
142 142
143 Removed: (** Long directories are truncated with a link to the directory's own page,
144 Removed: keeping the tree scannable without hiding anything permanently. *)
145 Removed: let tree_display_limit = 16
143 Added: (** Directories with more than seven entries show three children and a link to
144 Added: the full directory page, keeping the tree scannable without hiding anything
145 Added: permanently. The repository root is exempt — it always shows all entries. *)
146 Added: let tree_truncation_threshold = 7
146 147
148 Added: let tree_display_limit = 3
149 Added:
147 150 let rec tree_row repo (node : Resolvers.Tree.tree_node) =
148 151 let entry = node.entry in
149 152 let route = Routes.File (repo, entry.hash) in
@@ -157,7 +160,7 @@
157 160 | Some children ->
158 161 let total = List.length children in
159 162 let shown, omitted =
160 Removed: if total <= tree_display_limit then (children, 0)
163 Added: if total <= tree_truncation_threshold then (children, 0)
161 164 else
162 165 (List_ext.take tree_display_limit children, total - tree_display_limit)
163 166 in