git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gitweb: Include links to feeds in HTML header only for '200 OK' response
@ 2010-12-18 20:02 Jakub Narebski
  2010-12-18 20:10 ` J.H.
  0 siblings, 1 reply; 5+ messages in thread
From: Jakub Narebski @ 2010-12-18 20:02 UTC (permalink / raw)
  To: git; +Cc: J.H., Junio C Hamano

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>
---
 gitweb/gitweb.perl |   89 +++++++++++++++++++++++++++-------------------------
 1 files changed, 47 insertions(+), 42 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index d521c93..d965cda 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -3479,6 +3479,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 "<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 {
 	my $status = shift || "200 OK";
 	my $expires = shift;
@@ -3528,48 +3573,8 @@ EOF
 			print '<link rel="stylesheet" type="text/css" href="'.esc_url($stylesheet).'"/>'."\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 "<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"));
-	}
+	print_feed_meta()
+		if ($status eq '200 OK');
 	if (defined $favicon) {
 		print qq(<link rel="shortcut icon" href=").esc_url($favicon).qq(" type="image/png" />\n);
 	}

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] gitweb: Include links to feeds in HTML header only for '200 OK' response
  2010-12-18 20:02 [PATCH] gitweb: Include links to feeds in HTML header only for '200 OK' response Jakub Narebski
@ 2010-12-18 20:10 ` J.H.
  2010-12-18 21:48   ` Jakub Narebski
  0 siblings, 1 reply; 5+ messages in thread
From: J.H. @ 2010-12-18 20:10 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: git, Junio C Hamano

I've no objection, you can add a sign-off from me.

- John

On 12/18/2010 12:02 PM, Jakub Narebski wrote:
> 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>
> ---
>  gitweb/gitweb.perl |   89 +++++++++++++++++++++++++++-------------------------
>  1 files changed, 47 insertions(+), 42 deletions(-)
> 
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index d521c93..d965cda 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -3479,6 +3479,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 "<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 {
>  	my $status = shift || "200 OK";
>  	my $expires = shift;
> @@ -3528,48 +3573,8 @@ EOF
>  			print '<link rel="stylesheet" type="text/css" href="'.esc_url($stylesheet).'"/>'."\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 "<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"));
> -	}
> +	print_feed_meta()
> +		if ($status eq '200 OK');
>  	if (defined $favicon) {
>  		print qq(<link rel="shortcut icon" href=").esc_url($favicon).qq(" type="image/png" />\n);
>  	}

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] gitweb: Include links to feeds in HTML header only for '200 OK' response
  2010-12-18 20:10 ` J.H.
@ 2010-12-18 21:48   ` Jakub Narebski
  2010-12-18 21:53     ` J.H.
  0 siblings, 1 reply; 5+ messages in thread
From: Jakub Narebski @ 2010-12-18 21:48 UTC (permalink / raw)
  To: J.H.; +Cc: git, Junio C Hamano

J.H. wrote:

> I've no objection, you can add a sign-off from me.

Errr... sign-off or ack?  Signed-off-by is about provenance of code...

> On 12/18/2010 12:02 PM, Jakub Narebski wrote:
> > 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>
> > ---
> >  gitweb/gitweb.perl |   89 +++++++++++++++++++++++++++-------------------------
> >  1 files changed, 47 insertions(+), 42 deletions(-)
> > 
> > diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> > index d521c93..d965cda 100755
> > --- a/gitweb/gitweb.perl
> > +++ b/gitweb/gitweb.perl
> > @@ -3479,6 +3479,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 "<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 {
> >  	my $status = shift || "200 OK";
> >  	my $expires = shift;
> > @@ -3528,48 +3573,8 @@ EOF
> >  			print '<link rel="stylesheet" type="text/css" href="'.esc_url($stylesheet).'"/>'."\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 "<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"));
> > -	}
> > +	print_feed_meta()
> > +		if ($status eq '200 OK');
> >  	if (defined $favicon) {
> >  		print qq(<link rel="shortcut icon" href=").esc_url($favicon).qq(" type="image/png" />\n);
> >  	}
> 
> 

-- 
Jakub Narebski
Poland

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] gitweb: Include links to feeds in HTML header only for '200 OK' response
  2010-12-18 21:48   ` Jakub Narebski
@ 2010-12-18 21:53     ` J.H.
  2010-12-20 23:59       ` Jakub Narebski
  0 siblings, 1 reply; 5+ messages in thread
From: J.H. @ 2010-12-18 21:53 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: git, Junio C Hamano

On 12/18/2010 01:48 PM, Jakub Narebski wrote:
> J.H. wrote:
> 
>> I've no objection, you can add a sign-off from me.
> 
> Errr... sign-off or ack?  Signed-off-by is about provenance of code...

Considering this has already been running on kernel.org - sign-off.

http://git.kernel.org/?p=git/warthog9/gitweb.git;a=commit;h=41d9c63ad27a8d3c95bf8bb1ec5876483d39fbd6

- John 'Warthog9' Hawley

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] gitweb: Include links to feeds in HTML header only for '200 OK' response
  2010-12-18 21:53     ` J.H.
@ 2010-12-20 23:59       ` Jakub Narebski
  0 siblings, 0 replies; 5+ messages in thread
From: Jakub Narebski @ 2010-12-20 23:59 UTC (permalink / raw)
  To: J.H.; +Cc: git, Junio C Hamano

On Sat, 18 Dec 2010, J.H. wrote:
> On 12/18/2010 01:48 PM, Jakub Narebski wrote:
>> J.H. wrote:
>> 
>>> I've no objection, you can add a sign-off from me.
>> 
>> Errr... sign-off or ack?  Signed-off-by is about provenance of code...
> 
> Considering this has already been running on kernel.org - sign-off.
> 
> http://git.kernel.org/?p=git/warthog9/gitweb.git;a=commit;h=41d9c63ad27a8d3c95bf8bb1ec5876483d39fbd6

>From Documentation/SubmittingPatches:

  The sign-off is a simple line at the end of the explanation for
  the patch, which certifies that you wrote it or otherwise have
  the right to pass it on as a open-source patch.

So sign-off is about code provenance.  As I don't think that code goes
into official git/git.git repository managed by Junio via your
git/warthog9/gitweb.git repository, I don't quite see why it is *sign-off*
from you, and not ack (Acked-by:).

-- 
Jakub Narebski
Poland

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-12-20 23:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-18 20:02 [PATCH] gitweb: Include links to feeds in HTML header only for '200 OK' response Jakub Narebski
2010-12-18 20:10 ` J.H.
2010-12-18 21:48   ` Jakub Narebski
2010-12-18 21:53     ` J.H.
2010-12-20 23:59       ` Jakub Narebski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).