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>
Jakub Narebski committed
Jul 30, 2006 at 14:59 UTC
b18f9bf462cd37bc19368cb7d5c539e019d8fd67
1 file changed
+34
gitweb/gitweb.cgi
+34
@@ -385,6 +385,40 @@ sub die_error {
385
exit;
386
}
387
388
+sub git_page_nav {
389
+ my ($current, $suppress, $head, $treehead, $treebase, $extra) = @_;
390
+ $extra = '' if !defined $extra; # pager or formats
391
+
392
+ my @navs = qw(summary shortlog log commit commitdiff tree);
393
+ if ($suppress) {
394
+ @navs = grep { $_ ne $suppress } @navs;
395
+ }
396
+
397
+ my %arg = map { $_, ''} @navs;
398
+ if (defined $head) {
399
+ for (qw(commit commitdiff)) {
400
+ $arg{$_} = ";h=$head";
401
+ }
402
+ if ($current =~ m/^(tree | log | shortlog | commit | commitdiff | search)$/x) {
403
+ for (qw(shortlog log)) {
404
+ $arg{$_} = ";h=$head";
405
+ }
406
+ }
407
+ }
408
+ $arg{tree} .= ";h=$treehead" if defined $treehead;
409
+ $arg{tree} .= ";hb=$treebase" if defined $treebase;
410
+
411
+ print "<div class=\"page_nav\">\n" .
412
+ (join " | ",
413
+ map { $_ eq $current
414
+ ? $_
415
+ : $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=$_$arg{$_}")}, "$_")
416
+ }
417
+ @navs);
418
+ print "<br/>$extra<br/>\n" .
419
+ "</div>\n";
420
+}
421
+
422
sub git_get_type {
423
my $hash = shift;
424