git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Kevin Cernekee <cernekee@gmail.com>, git@vger.kernel.org
Subject: Re: [PATCH 1/2] gitweb: fix #patchNN anchors when path_info is enabled
Date: Thu, 17 Mar 2011 20:19:59 +0100	[thread overview]
Message-ID: <201103172020.05055.jnareb@gmail.com> (raw)
In-Reply-To: <7v62rh4ml1.fsf@alter.siamese.dyndns.org>

On Thu, 17 Mar 2011, Junio C Hamano wrote:
> Jakub Narebski <jnareb@gmail.com> writes:
> 
>> It would be better (less error prone) and easier to use '-replay'
>> option to href(), i.e. write
>>
>>> +				print $cgi->a({-href => href(-replay=>1, -anchor=>"patch$patchno")},
>>> +				              "patch") .
>>
>> or even make it so 'href(-anchor=>"ANCHOR")' implies '-replay => 1'.
> 
> I don't see why "or even" is an improvement, given the following
> implementation.

Well, 

  -href => href(-anchor=>"patch$patchno")

is closer in spirit to

  -href => "#patch$patchno"

that is currently used, and does not work with path_info.
 
> >   @@ -1310,6 +1310,7 @@ sub href {
> >   
> >   	$params{'project'} = $project unless exists $params{'project'};
> >   
> >  -	if ($params{-replay}) {
> >  +	if ($params{-replay} ||
> >  +	    ($params{-anchor} && keys %params == 1)) {
> >   		while (my ($name, $symbol) = each %cgi_param_mapping) {
> >   			if (!exists $params{$name}) {
> >   				$params{$name} = $input_params{$name};
> 
> I don't share your intuition that "anchor" is so special that this part
> will not grow into a long chain of "(I want an implicit replay too) ||".
> 
> Implicitly enabling it in certain obvious cases is perfectly fine, but the
> logic to do so should be in a separate place.  Wouldn't it better to have
> a separate code that sets 'replay' under this and that condition so that
> other people can later add to it at the very beginning of "sub href"?
> 
> Unless we do so, if there are other places that need to change the
> behaviour based on 'replay', they need to duplicate the "implicit" logic.

So you would prefer to have something like this:

 	# implicit -replay
 	if (keys %params == 1 && $params{-anchor}) {
 		# href(-anchor=>"ANCHOR") works like "#ANCHOR", 
 		# correctly if base href is set (for path_info URLs)
 		$params{-replay} = 1;
 	}

set above 'if ($params{-replay}) {'?

-- 
Jakub Narebski
Poland

  reply	other threads:[~2011-03-17 19:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-16  2:15 [PATCH 1/2] gitweb: fix #patchNN anchors when path_info is enabled Kevin Cernekee
2011-03-16  2:15 ` [PATCH 2/2] gitweb: introduce localtime feature Kevin Cernekee
2011-03-17 11:01   ` Jakub Narebski
2011-03-17 18:26     ` Junio C Hamano
2011-03-17 20:12     ` Kevin Cernekee
2011-03-17 22:30       ` Jakub Narebski
2011-03-17 10:43 ` [PATCH 1/2] gitweb: fix #patchNN anchors when path_info is enabled Jakub Narebski
2011-03-17 18:40   ` Junio C Hamano
2011-03-17 19:19     ` Jakub Narebski [this message]
2011-03-17 20:55       ` Junio C Hamano

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=201103172020.05055.jnareb@gmail.com \
    --to=jnareb@gmail.com \
    --cc=cernekee@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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 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).