]> Lady’s Gitweb - Gitweb/blobdiff - gitweb.perl
gitweb: refactor repository URL printing
[Gitweb] / gitweb.perl
index b5ac7c0e10cdf18e6579743905f1b049f81835e0ac5d35917c27df46188bef1c..85110d689472b9c22e955215b82d4555ed7280c57e69904c920e6eaf407a5031 100755 (executable)
@@ -3525,7 +3525,15 @@ EOF
        if (defined $project) {
                print $cgi->a({-href => href(action=>"summary")}, esc_html($project));
                if (defined $action) {
        if (defined $project) {
                print $cgi->a({-href => href(action=>"summary")}, esc_html($project));
                if (defined $action) {
-                       print " / $action";
+                       my $action_print = $action ;
+                       if (defined $opts{-action_extra}) {
+                               $action_print = $cgi->a({-href => href(action=>$action)},
+                                       $action);
+                       }
+                       print " / $action_print";
+               }
+               if (defined $opts{-action_extra}) {
+                       print " / $opts{-action_extra}";
                }
                print "\n";
        }
                }
                print "\n";
        }
@@ -3732,6 +3740,19 @@ sub git_print_page_nav {
              "</div>\n";
 }
 
              "</div>\n";
 }
 
+# returns a submenu for the nagivation of the refs views (tags, heads,
+# remotes) with the current view disabled and the remotes view only
+# available if the feature is enabled
+sub format_ref_views {
+       my ($current) = @_;
+       my @ref_views = qw{tags heads};
+       push @ref_views, 'remotes' if gitweb_check_feature('remote_heads');
+       return join " | ", map {
+               $_ eq $current ? $_ :
+               $cgi->a({-href => href(action=>$_)}, $_)
+       } @ref_views
+}
+
 sub format_paging_nav {
        my ($action, $page, $has_next_link) = @_;
        my $paging_nav;
 sub format_paging_nav {
        my ($action, $page, $has_next_link) = @_;
        my $paging_nav;
@@ -3775,6 +3796,11 @@ sub git_print_header_div {
              "\n</div>\n";
 }
 
              "\n</div>\n";
 }
 
+sub format_repo_url {
+       my ($name, $url) = @_;
+       return "<tr class=\"metadata_url\"><td>$name</td><td>$url</td></tr>\n";
+}
+
 sub print_local_time {
        print format_local_time(@_);
 }
 sub print_local_time {
        print format_local_time(@_);
 }
@@ -5158,7 +5184,7 @@ sub git_summary {
        @url_list = map { "$_/$project" } @git_base_url_list unless @url_list;
        foreach my $git_url (@url_list) {
                next unless $git_url;
        @url_list = map { "$_/$project" } @git_base_url_list unless @url_list;
        foreach my $git_url (@url_list) {
                next unless $git_url;
-               print "<tr class=\"metadata_url\"><td>$url_tag</td><td>$git_url</td></tr>\n";
+               print format_repo_url($url_tag, $git_url);
                $url_tag = "";
        }
 
                $url_tag = "";
        }
 
@@ -5508,7 +5534,7 @@ sub git_blame_data {
 sub git_tags {
        my $head = git_get_head_hash($project);
        git_header_html();
 sub git_tags {
        my $head = git_get_head_hash($project);
        git_header_html();
-       git_print_page_nav('','', $head,undef,$head);
+       git_print_page_nav('','', $head,undef,$head,format_ref_views('tags'));
        git_print_header_div('summary', $project);
 
        my @tagslist = git_get_tags_list();
        git_print_header_div('summary', $project);
 
        my @tagslist = git_get_tags_list();
@@ -5521,7 +5547,7 @@ sub git_tags {
 sub git_heads {
        my $head = git_get_head_hash($project);
        git_header_html();
 sub git_heads {
        my $head = git_get_head_hash($project);
        git_header_html();
-       git_print_page_nav('','', $head,undef,$head);
+       git_print_page_nav('','', $head,undef,$head,format_ref_views('heads'));
        git_print_header_div('summary', $project);
 
        my @headslist = git_get_heads_list();
        git_print_header_div('summary', $project);
 
        my @headslist = git_get_heads_list();
@@ -5536,14 +5562,36 @@ sub git_remotes {
                or die_error(403, "Remote heads view is disabled");
 
        my $head = git_get_head_hash($project);
                or die_error(403, "Remote heads view is disabled");
 
        my $head = git_get_head_hash($project);
-       git_header_html();
-       git_print_page_nav('','', $head,undef,$head);
-       git_print_header_div('summary', $project);
+       my $remote = $input_params{'hash'};
+
+       my @remotelist;
+
+       if (defined $remote) {
+               # only display the heads in a given remote, stripping the
+               # remote name which is already visible elsewhere
+               @remotelist = map {
+                       my $ref = $_ ;
+                       $ref->{'name'} =~ s!^$remote/!!;
+                       $ref
+               } git_get_heads_list(undef, "remotes/$remote");
+       } else {
+               @remotelist = git_get_heads_list(undef, 'remotes');
+       }
+
+       git_header_html(undef, undef, -action_extra => $remote);
+       git_print_page_nav('', '',  $head, undef, $head,
+               format_ref_views($remote ? '' : 'remotes'));
+
+       if (defined $remote) {
+               git_print_header_div('remotes', "$remote remote for $project");
+       } else {
+               git_print_header_div('summary', "$project remotes");
+       }
 
 
-       my @remotelist = git_get_heads_list(undef, 'remotes');
        if (@remotelist) {
                git_heads_body(\@remotelist, $head);
        }
        if (@remotelist) {
                git_heads_body(\@remotelist, $head);
        }
+
        git_footer_html();
 }
 
        git_footer_html();
 }
 
This page took 0.262061 seconds and 4 git commands to generate.