diff options
author | Jakub Narebski <jnareb@gmail.com> | 2006-07-30 14:59:57 +0200 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2006-07-30 18:38:17 -0700 |
commit | b18f9bf462cd37bc19368cb7d5c539e019d8fd67 (patch) | |
tree | e37868dd491c8f65809a024651ccb087023cc4f7 /gitweb/gitweb.cgi | |
parent | gitweb: Cleanup - chomp @lines in consistent style (diff) | |
download | tgif-b18f9bf462cd37bc19368cb7d5c539e019d8fd67.tar.xz |
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>
Diffstat (limited to 'gitweb/gitweb.cgi')
-rwxr-xr-x | gitweb/gitweb.cgi | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi index 98505551cd..d0d3f3efb1 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 "<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; |