Re: [Catalyst] How to get uri_for something with a fragment?

2011-03-07 Thread Larry Leszczynski

> Using the fragment is probably a bad idea. It's not supported by all
> servers so it can end up lost on the backend depending on your setup.

I have see fragments cause problems in server-side code that is naive
about URL handling, like splitting the string on "?" and assuming all
the stuff after the question mark is query params when it might in fact
include a fragment.

Since most (all?) of the URLs you see being passed around in Catalyst
code are actual URI objects (http://search.cpan.org/perldoc?URI), just
treat them as objects and use all the nice URI methods for manipulating
them and you'll be fine.


Larry

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] How to get uri_for something with a fragment?

2011-03-07 Thread Ashley Pond V
On Mon, Mar 7, 2011 at 12:34 PM, Ronald J Kimball
 wrote:
> On Mon, Mar 7, 2011 at 3:25 PM, John M. Dlugosz  
> wrote:
>>  On 3/7/2011 1:35 PM, Ashley Pond V apv-at-sedition.com |Catalyst/Allow to
>> home| wrote:
>>>
>>> Using the fragment is probably a bad idea. It's not supported by all
>>> servers so it can end up lost on the backend depending on your setup.
>>
>> I've never heard of a web server that didn't have fragments.  I link to
>> anchors all the time!
>
> No, really, that's meaningless.  Fragments are handled by the user
> agent, not by the server.

What Ronald said + the #fragment is not passed along in the available
ENV with some servers and setups. In these cases it doesn't exist as
far as the backend is concerned. If you rely on it for dispatch, you
may get burned.

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] How to get uri_for something with a fragment?

2011-03-07 Thread Ronald J Kimball
On Mon, Mar 7, 2011 at 3:25 PM, John M. Dlugosz  wrote:
>  On 3/7/2011 1:35 PM, Ashley Pond V apv-at-sedition.com |Catalyst/Allow to
> home| wrote:
>>
>> Using the fragment is probably a bad idea. It's not supported by all
>> servers so it can end up lost on the backend depending on your setup.
>
> I've never heard of a web server that didn't have fragments.  I link to
> anchors all the time!

No, really, that's meaningless.  Fragments are handled by the user
agent, not by the server.

http://tools.ietf.org/html/rfc3986#section-3.5

Ronald

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] How to get uri_for something with a fragment?

2011-03-07 Thread John M. Dlugosz

 On 3/7/2011 1:35 PM, Ashley Pond V apv-at-sedition.com |Catalyst/Allow to 
home| wrote:

Using the fragment is probably a bad idea. It's not supported by all
servers so it can end up lost on the backend depending on your setup.

-Ashley



I've never heard of a web server that didn't have fragments.  I link to anchors 
all the time!

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] How to get uri_for something with a fragment?

2011-03-07 Thread Ronald J Kimball
On Mon, Mar 7, 2011 at 2:35 PM, Ashley Pond V  wrote:

> Using the fragment is probably a bad idea. It's not supported by all
> servers so it can end up lost on the backend depending on your setup.

I can't figure out what you mean by this.  This is a URL that will be
included in the body of a response.  How is the server involved at
all?

Ronald

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] How to get uri_for something with a fragment?

2011-03-07 Thread Ashley Pond V
On Mon, Mar 7, 2011 at 10:05 AM, John M. Dlugosz  wrote:
>  On 3/7/2011 9:34 AM, Ronald J Kimball rkimball-at-pangeamedia.com
> |Catalyst/Allow to home| wrote:
>>
>> On Sun, Mar 6, 2011 at 6:46 AM, John M. Dlugosz
>>  wrote:
>>>
>>>  On 3/6/2011 5:28 AM, Andrew Rodland andrew-at-cleverdomain.org
>>> |Catalyst/Allow to home| wrote:

 Or, since you know that what it generates *doesn't* have a fragment you
 could
 always just $c->uri_for_action(...) . '#id' which will be perfectly
 valid
 (although no longer a URI object).

>>> I considered that a hack until I knew better, since it won't work if
>>> there
>>> are query arguments.
>>
>> Why won't it work if there are query arguments?  Seems correct to me.
>>

Using the fragment is probably a bad idea. It's not supported by all
servers so it can end up lost on the backend depending on your setup.

-Ashley

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] How to get uri_for something with a fragment?

2011-03-07 Thread John M. Dlugosz
 On 3/7/2011 9:34 AM, Ronald J Kimball rkimball-at-pangeamedia.com |Catalyst/Allow to 
home| wrote:

On Sun, Mar 6, 2011 at 6:46 AM, John M. Dlugosz  wrote:

  On 3/6/2011 5:28 AM, Andrew Rodland andrew-at-cleverdomain.org
|Catalyst/Allow to home| wrote:

Or, since you know that what it generates *doesn't* have a fragment you could
always just $c->uri_for_action(...) . '#id' which will be perfectly valid
(although no longer a URI object).


I considered that a hack until I knew better, since it won't work if there
are query arguments.

Why won't it work if there are query arguments?  Seems correct to me.

Ronald

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/

My bad.  I thought the ? came after the #.

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] How to get uri_for something with a fragment?

2011-03-07 Thread Ronald J Kimball
On Sun, Mar 6, 2011 at 6:46 AM, John M. Dlugosz  wrote:
>  On 3/6/2011 5:28 AM, Andrew Rodland andrew-at-cleverdomain.org
> |Catalyst/Allow to home| wrote:
>>
>> Or, since you know that what it generates *doesn't* have a fragment you could
>> always just $c->uri_for_action(...) . '#id' which will be perfectly valid
>> (although no longer a URI object).
>>
> I considered that a hack until I knew better, since it won't work if there
> are query arguments.

Why won't it work if there are query arguments?  Seems correct to me.

Ronald

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] How to get uri_for something with a fragment?

2011-03-06 Thread John M. Dlugosz
 On 3/6/2011 5:28 AM, Andrew Rodland andrew-at-cleverdomain.org |Catalyst/Allow to home| 
wrote:


Or, since you know that what it generates *doesn't* have a fragment you could
always just $c->uri_for_action(...) . '#id' which will be perfectly valid
(although no longer a URI object).

I considered that a hack until I knew better, since it won't work if there are query 
arguments.


This worked:

[% IF c.action != 'index' ;
   SET toplink = c.uri_for_action('/index') ;
   CALL toplink.fragment('galleries') %]
Gallery Index
[% END %]

though I'd certainly be interested in hearing how I could do it better.

--John


___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] How to get uri_for something with a fragment?

2011-03-06 Thread Andrew Rodland
On Sunday, March 06, 2011 05:07:25 AM John M. Dlugosz wrote:
>   How do I call uri_for_action and pass it the '#id' part?  It's not an arg
> and it's not part of the query string.  This is called the fragment
> identifier in the final URL.

uri_for returns a URI object, so you can always

my $uri = $c->uri_for_action(...);
$uri->fragment('id');
# Use $uri

Or, since you know that what it generates *doesn't* have a fragment you could 
always just $c->uri_for_action(...) . '#id' which will be perfectly valid 
(although no longer a URI object).

Andrew

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


[Catalyst] How to get uri_for something with a fragment?

2011-03-06 Thread John M. Dlugosz
 How do I call uri_for_action and pass it the '#id' part?  It's not an arg and it's not 
part of the query string.  This is called the fragment identifier in the final URL.




___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/