gitweb: nagivation menu for tags, heads and remotes
tags, heads and remotes are all views that inspect a (particular class of) refs, so allow the user to easily switch between them by adding the appropriate navigation submenu to each view. Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com> Acked-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Giuseppe Bilotta committed
Nov 11, 2010 at 13:26 UTC
11e7bece1559695faf72803ef8aa52c1d65350f9
1 file changed
+16
-3
gitweb/gitweb.perl
+16
-3
@@ -3733,6 +3733,19 @@ sub git_print_page_nav {
3733
"</div>\n";
3734
}
3735
3736
+# returns a submenu for the nagivation of the refs views (tags, heads,
3737
+# remotes) with the current view disabled and the remotes view only
3738
+# available if the feature is enabled
3739
+sub format_ref_views {
3740
+ my ($current) = @_;
3741
+ my @ref_views = qw{tags heads};
3742
+ push @ref_views, 'remotes' if gitweb_check_feature('remote_heads');
3743
+ return join " | ", map {
3744
+ $_ eq $current ? $_ :
3745
+ $cgi->a({-href => href(action=>$_)}, $_)
3746
+ } @ref_views
3747
+}
3748
+
3749
sub format_paging_nav {
3750
my ($action, $page, $has_next_link) = @_;
3751
my $paging_nav;
@@ -5509,7 +5522,7 @@ sub git_blame_data {
5522
sub git_tags {
5523
my $head = git_get_head_hash($project);
5524
git_header_html();
5512
- git_print_page_nav('','', $head,undef,$head);
5525
+ git_print_page_nav('','', $head,undef,$head,format_ref_views('tags'));
5526
git_print_header_div('summary', $project);
5527
5528
my @tagslist = git_get_tags_list();
@@ -5522,7 +5535,7 @@ sub git_tags {
5535
sub git_heads {
5536
my $head = git_get_head_hash($project);
5537
git_header_html();
5525
- git_print_page_nav('','', $head,undef,$head);
5538
+ git_print_page_nav('','', $head,undef,$head,format_ref_views('heads'));
5539
git_print_header_div('summary', $project);
5540
5541
my @headslist = git_get_heads_list();
@@ -5538,7 +5551,7 @@ sub git_remotes {
5551
5552
my $head = git_get_head_hash($project);
5553
git_header_html();
5541
- git_print_page_nav('','', $head,undef,$head);
5554
+ git_print_page_nav('','', $head,undef,$head,format_ref_views('remotes'));
5555
git_print_header_div('summary', $project);
5556
5557
my @remotelist = git_get_heads_list(undef, 'remotes');