From b18f9bf462cd37bc19368cb7d5c539e019d8fd67 Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Sun, 30 Jul 2006 14:59:57 +0200 Subject: [PATCH] gitweb: Add git_page_nav for later use Adds git_page_nav subroutine to factor out the generation of the navigation bar. Based on Sven Verdoolaege code Message-Id: <20050618113121.GA13122@pc117b.liacs.nl> http://marc.theaimsgroup.com/?l=git&m=111909432415478&w=2 I tried for the refactored navbar generate the same result. Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano --- gitweb/gitweb.cgi | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi index 98505551c..d0d3f3efb 100755 --- a/gitweb/gitweb.cgi +++ b/gitweb/gitweb.cgi @@ -385,6 +385,40 @@ sub die_error { exit; } +sub git_page_nav { + my ($current, $suppress, $head, $treehead, $treebase, $extra) = @_; + $extra = '' if !defined $extra; # pager or formats + + my @navs = qw(summary shortlog log commit commitdiff tree); + if ($suppress) { + @navs = grep { $_ ne $suppress } @navs; + } + + my %arg = map { $_, ''} @navs; + if (defined $head) { + for (qw(commit commitdiff)) { + $arg{$_} = ";h=$head"; + } + if ($current =~ m/^(tree | log | shortlog | commit | commitdiff | search)$/x) { + for (qw(shortlog log)) { + $arg{$_} = ";h=$head"; + } + } + } + $arg{tree} .= ";h=$treehead" if defined $treehead; + $arg{tree} .= ";hb=$treebase" if defined $treebase; + + print "
\n" . + (join " | ", + map { $_ eq $current + ? $_ + : $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=$_$arg{$_}")}, "$_") + } + @navs); + print "
$extra
\n" . + "
\n"; +} + sub git_get_type { my $hash = shift; -- 2.26.2