From 05bb5a2584ca0e1c87a2135a83c5573b9337d06f Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Sat, 18 Dec 2010 21:02:13 +0100 Subject: [PATCH] gitweb: Include links to feeds in HTML header only for '200 OK' response To do that, generating ""s to feeds were refactored into print_feed_meta() subroutine, to keep nesting (indent) level in git_header_html() low. This has also the advantage of making code more clear. Signed-off-by: Jakub Narebski Signed-off-by: John 'Warthog9' Hawley Signed-off-by: Junio C Hamano --- gitweb/gitweb.perl | 89 ++++++++++++++++++++++++---------------------- 1 file changed, 47 insertions(+), 42 deletions(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 53253c622..42cc1da7f 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -3394,6 +3394,51 @@ sub get_page_title { return $title; } +sub print_feed_meta { + if (defined $project) { + my %href_params = get_feed_info(); + if (!exists $href_params{'-title'}) { + $href_params{'-title'} = 'log'; + } + + foreach my $format qw(RSS Atom) { + my $type = lc($format); + my %link_attr = ( + '-rel' => 'alternate', + '-title' => esc_attr("$project - $href_params{'-title'} - $format feed"), + '-type' => "application/$type+xml" + ); + + $href_params{'action'} = $type; + $link_attr{'-href'} = href(%href_params); + print "\n"; + + $href_params{'extra_options'} = '--no-merges'; + $link_attr{'-href'} = href(%href_params); + $link_attr{'-title'} .= ' (no merges)'; + print "\n"; + } + + } else { + printf(''."\n", + esc_attr($site_name), href(project=>undef, action=>"project_index")); + printf(''."\n", + esc_attr($site_name), href(project=>undef, action=>"opml")); + } +} + sub git_header_html { my $status = shift || "200 OK"; my $expires = shift; @@ -3443,48 +3488,8 @@ EOF print ''."\n"; } } - if (defined $project) { - my %href_params = get_feed_info(); - if (!exists $href_params{'-title'}) { - $href_params{'-title'} = 'log'; - } - - foreach my $format qw(RSS Atom) { - my $type = lc($format); - my %link_attr = ( - '-rel' => 'alternate', - '-title' => esc_attr("$project - $href_params{'-title'} - $format feed"), - '-type' => "application/$type+xml" - ); - - $href_params{'action'} = $type; - $link_attr{'-href'} = href(%href_params); - print "\n"; - - $href_params{'extra_options'} = '--no-merges'; - $link_attr{'-href'} = href(%href_params); - $link_attr{'-title'} .= ' (no merges)'; - print "\n"; - } - - } else { - printf(''."\n", - esc_attr($site_name), href(project=>undef, action=>"project_index")); - printf(''."\n", - esc_attr($site_name), href(project=>undef, action=>"opml")); - } + print_feed_meta() + if ($status eq '200 OK'); if (defined $favicon) { print qq(\n); } -- 2.30.2