All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: "J.H." <warthog9@eaglescrag.net>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] gitweb: Include links to feeds in HTML header only for '200	OK' response
Date: Sat, 18 Dec 2010 22:48:39 +0100	[thread overview]
Message-ID: <201012182248.40731.jnareb@gmail.com> (raw)
In-Reply-To: <4D0D1529.6030806@eaglescrag.net>

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

  reply	other threads:[~2010-12-18 21:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2010-12-18 21:53     ` J.H.
2010-12-20 23:59       ` Jakub Narebski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201012182248.40731.jnareb@gmail.com \
    --to=jnareb@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=warthog9@eaglescrag.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.