Re: [PATCH v2 2/2] gitweb: place links to parent directories in page header
From: Jakub Narebski <hidden>
Date: 2016-06-15 22:52:52
"Bernhard R. Link" [off-list ref] writes: Description?
Signed-off-by: Bernhard R. Link <redacted> --- This patch was not yet part of v1. I'm not sure this if having this as seperate patch or merged into 1/2 makes more sense.
While adding links that lead to gitweb URLs with project_filter parameter set, i.e. linking new feature in, could be postponed to a later commit, I think some way of notifying client that project list is filtered would be better to have in 1/2.
quoted hunk ↗ jump to hunk
gitweb/gitweb.perl | 23 ++++++++++++++++++++++- 1 files changed, 22 insertions(+), 1 deletions(-)diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index a114bd4..ddce27d 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl@@ -3841,7 +3841,18 @@ sub print_nav_breadcrumbs { print $cgi->a({-href => esc_url($home_link)}, $home_link_str) . " / "; if (defined $project) { - print $cgi->a({-href => href(action=>"summary")}, esc_html($project)); + my @dirname = split '/', $project; + my $projectbasename = pop @dirname; + my $dirprefix = undef; + while (my $part = shift @dirname) { + $dirprefix .= "/" if defined $dirprefix; + $dirprefix .= $part; + print $cgi->a({-href => href(project => undef, + project_filter => $dirprefix, + action=>"project_list")}, + esc_html($part)) . " / "; + } + print $cgi->a({-href => href(action=>"summary")}, esc_html($projectbasename)); if (defined $action) { my $action_print = $action ; if (defined $opts{-action_extra}) {
Nice solution.
quoted hunk ↗ jump to hunk
@@ -3854,6 +3865,16 @@ sub print_nav_breadcrumbs { print " / $opts{-action_extra}"; } print "\n"; + } elsif (defined $project_filter) { + my @dirname = split '/', $project_filter; + my $dirprefix = undef; + while (my $part = shift @dirname) { + $dirprefix .= "/" if defined $dirprefix; + $dirprefix .= $part; + print $cgi->a({-href => href(project_filter => $dirprefix, + action=>"project_list")}, + esc_html($part)) . " / "; + } } }
Hmmm... I'd have to check how it looks like, but seems like a good idea... even if there is a little bit of code duplication. -- Jakub Narebski