From: Jakub Narebski Date: Sun, 30 Jul 2006 12:59:57 +0000 (+0200) Subject: gitweb: Add git_page_nav for later use X-Git-Tag: v1.4.3-rc1~274^2~46 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=b18f9bf462cd37bc19368cb7d5c539e019d8fd67;p=git.git 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 --- 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;