1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-25 22:56:10 +02:00

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 <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Jakub Narebski 2006-07-30 14:59:57 +02:00 committed by Junio C Hamano
parent 0881d2d130
commit b18f9bf462

View File

@ -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 "<div class=\"page_nav\">\n" .
(join " | ",
map { $_ eq $current
? $_
: $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=$_$arg{$_}")}, "$_")
}
@navs);
print "<br/>$extra<br/>\n" .
"</div>\n";
}
sub git_get_type {
my $hash = shift;