Skip to content

Commit 784bdd6

Browse files
committed
Merge branch 'tf/gitweb-extra-breadcrumbs'
An Gitweb installation that is a part of larger site can optionally show extra links that point at the levels higher than the Gitweb pages itself in the link hierarchy of pages. * tf/gitweb-extra-breadcrumbs: gitweb: allow extra breadcrumbs to prefix the trail
2 parents 778e4b8 + ad9c2e2 commit 784bdd6

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

Documentation/gitweb.conf.txt

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,26 @@ $home_link_str::
336336
used as the first component of gitweb's "breadcrumb trail":
337337
`<home link> / <project> / <action>`. Can be set at build time using
338338
the `GITWEB_HOME_LINK_STR` variable. By default it is set to "projects",
339-
as this link leads to the list of projects. Other popular choice it to
340-
set it to the name of site.
339+
as this link leads to the list of projects. Another popular choice is to
340+
set it to the name of site. Note that it is treated as raw HTML so it
341+
should not be set from untrusted sources.
342+
343+
@extra_breadcrumbs::
344+
Additional links to be added to the start of the breadcrumb trail before
345+
the home link, to pages that are logically "above" the gitweb projects
346+
list, such as the organization and department which host the gitweb
347+
server. Each element of the list is a reference to an array, in which
348+
element 0 is the link text (equivalent to `$home_link_str`) and element
349+
1 is the target URL (equivalent to `$home_link`).
350+
+
351+
For example, the following setting produces a breadcrumb trail like
352+
"home / dev / projects / ..." where "projects" is the home link.
353+
----------------------------------------------------------------------------
354+
our @extra_breadcrumbs = (
355+
[ 'home' => 'https://www.example.org/' ],
356+
[ 'dev' => 'https://dev.example.org/' ],
357+
);
358+
----------------------------------------------------------------------------
341359

342360
$logo_url::
343361
$logo_label::

gitweb/gitweb.perl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ sub evaluate_uri {
8585
# string of the home link on top of all pages
8686
our $home_link_str = "++GITWEB_HOME_LINK_STR++";
8787

88+
# extra breadcrumbs preceding the home link
89+
our @extra_breadcrumbs = ();
90+
8891
# name of your site or organization to appear in page titles
8992
# replace this with something more descriptive for clearer bookmarks
9093
our $site_name = "++GITWEB_SITENAME++"
@@ -3982,7 +3985,9 @@ sub print_nav_breadcrumbs_path {
39823985
sub print_nav_breadcrumbs {
39833986
my %opts = @_;
39843987

3985-
print $cgi->a({-href => esc_url($home_link)}, $home_link_str) . " / ";
3988+
for my $crumb (@extra_breadcrumbs, [ $home_link_str => $home_link ]) {
3989+
print $cgi->a({-href => esc_url($crumb->[1])}, $crumb->[0]) . " / ";
3990+
}
39863991
if (defined $project) {
39873992
my @dirname = split '/', $project;
39883993
my $projectbasename = pop @dirname;

0 commit comments

Comments
 (0)