[OCaml] Mobile-friendly clone of cgit.
feat make breadcrumb segments navigable for nested repos
For repos nested under project directories (e.g. projects/myrepo), each path segment in the breadcrumb is now a separate link: - Intermediate directory segments link to / (root listing) - The final repo segment links to the repo's files page - File trail segments continue linking to their blob/tree as before This supports per-project navigation when repos are grouped under project directories.
lib/views/repo.ml
@@ -676,12 +676,34 @@
676
676
]
677
677
678
678
let breadcrumb_pill repo (trail : (string * string) list) =
679
Removed:
let root_anchor =
680
Removed:
Routes.link_to (Files repo)
681
Removed:
~other_attrs:[ HTML.class_ "path-pill-link" ]
682
Removed:
(txt "%s" repo)
679
Added:
let repo_segments = String.split_on_char '/' repo in
680
Added:
let repo_anchors =
681
Added:
match repo_segments with
682
Added:
| [] -> [ txt "%s" repo ]
683
Added:
| [ single ] ->
684
Added:
[
685
Added:
Routes.link_to (Files repo)
686
Added:
~other_attrs:[ HTML.class_ "path-pill-link" ]
687
Added:
(txt "%s" single);
688
Added:
]
689
Added:
| segments ->
690
Added:
let last_idx = List.length segments - 1 in
691
Added:
List.mapi
692
Added:
(fun i seg ->
693
Added:
let node =
694
Added:
if i = last_idx then
695
Added:
Routes.link_to (Files repo)
696
Added:
~other_attrs:[ HTML.class_ "path-pill-link" ]
697
Added:
(txt "%s" seg)
698
Added:
else
699
Added:
HTML.(a [ href "/"; class_ "path-pill-link" ] [ txt "%s" seg ])
700
Added:
in
701
Added:
if i = 0 then node
702
Added:
else
703
Added:
HTML.(null [ span [ class_ "path-pill-sep" ] [ txt "/" ]; node ]))
704
Added:
segments
683
705
in
684
Removed:
let segments =
706
Added:
let file_segments =
685
707
List.map
686
708
(fun (entry_name, hash) ->
687
709
HTML.(
@@ -695,7 +717,7 @@
695
717
]))
696
718
trail
697
719
in
698
Removed:
HTML.(span [ class_ "path-pill" ] (root_anchor :: segments))
720
Added:
HTML.(span [ class_ "path-pill" ] (repo_anchors @ file_segments))
699
721
700
722
let files context trail ?readme (entries : Resolvers.Tree.tree_node list) =
701
723
let pill = breadcrumb_pill context.repo trail in