gitweb: Include links to feeds in HTML header only for '200 OK' response
To do that, generating "<link />"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 <jnareb@gmail.com> Signed-off-by: John 'Warthog9' Hawley <warthog9@eaglescrag.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
0c806a06a3
commit
05bb5a2584
|
@ -3394,6 +3394,51 @@ sub get_page_title {
|
||||||
return $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 "<link ".
|
||||||
|
"rel=\"$link_attr{'-rel'}\" ".
|
||||||
|
"title=\"$link_attr{'-title'}\" ".
|
||||||
|
"href=\"$link_attr{'-href'}\" ".
|
||||||
|
"type=\"$link_attr{'-type'}\" ".
|
||||||
|
"/>\n";
|
||||||
|
|
||||||
|
$href_params{'extra_options'} = '--no-merges';
|
||||||
|
$link_attr{'-href'} = href(%href_params);
|
||||||
|
$link_attr{'-title'} .= ' (no merges)';
|
||||||
|
print "<link ".
|
||||||
|
"rel=\"$link_attr{'-rel'}\" ".
|
||||||
|
"title=\"$link_attr{'-title'}\" ".
|
||||||
|
"href=\"$link_attr{'-href'}\" ".
|
||||||
|
"type=\"$link_attr{'-type'}\" ".
|
||||||
|
"/>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
printf('<link rel="alternate" title="%s projects list" '.
|
||||||
|
'href="%s" type="text/plain; charset=utf-8" />'."\n",
|
||||||
|
esc_attr($site_name), href(project=>undef, action=>"project_index"));
|
||||||
|
printf('<link rel="alternate" title="%s projects feeds" '.
|
||||||
|
'href="%s" type="text/x-opml" />'."\n",
|
||||||
|
esc_attr($site_name), href(project=>undef, action=>"opml"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sub git_header_html {
|
sub git_header_html {
|
||||||
my $status = shift || "200 OK";
|
my $status = shift || "200 OK";
|
||||||
my $expires = shift;
|
my $expires = shift;
|
||||||
|
@ -3443,48 +3488,8 @@ EOF
|
||||||
print '<link rel="stylesheet" type="text/css" href="'.esc_url($stylesheet).'"/>'."\n";
|
print '<link rel="stylesheet" type="text/css" href="'.esc_url($stylesheet).'"/>'."\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (defined $project) {
|
print_feed_meta()
|
||||||
my %href_params = get_feed_info();
|
if ($status eq '200 OK');
|
||||||
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 "<link ".
|
|
||||||
"rel=\"$link_attr{'-rel'}\" ".
|
|
||||||
"title=\"$link_attr{'-title'}\" ".
|
|
||||||
"href=\"$link_attr{'-href'}\" ".
|
|
||||||
"type=\"$link_attr{'-type'}\" ".
|
|
||||||
"/>\n";
|
|
||||||
|
|
||||||
$href_params{'extra_options'} = '--no-merges';
|
|
||||||
$link_attr{'-href'} = href(%href_params);
|
|
||||||
$link_attr{'-title'} .= ' (no merges)';
|
|
||||||
print "<link ".
|
|
||||||
"rel=\"$link_attr{'-rel'}\" ".
|
|
||||||
"title=\"$link_attr{'-title'}\" ".
|
|
||||||
"href=\"$link_attr{'-href'}\" ".
|
|
||||||
"type=\"$link_attr{'-type'}\" ".
|
|
||||||
"/>\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
printf('<link rel="alternate" title="%s projects list" '.
|
|
||||||
'href="%s" type="text/plain; charset=utf-8" />'."\n",
|
|
||||||
esc_attr($site_name), href(project=>undef, action=>"project_index"));
|
|
||||||
printf('<link rel="alternate" title="%s projects feeds" '.
|
|
||||||
'href="%s" type="text/x-opml" />'."\n",
|
|
||||||
esc_attr($site_name), href(project=>undef, action=>"opml"));
|
|
||||||
}
|
|
||||||
if (defined $favicon) {
|
if (defined $favicon) {
|
||||||
print qq(<link rel="shortcut icon" href=").esc_url($favicon).qq(" type="image/png" />\n);
|
print qq(<link rel="shortcut icon" href=").esc_url($favicon).qq(" type="image/png" />\n);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue