Re: [Catalyst] website member urls

2009-04-30 Thread Tomas Doran

J. Shirley wrote:
If you did want to do something in Catalyst, you could create a plugin 
that runs after prepare_path and modifies $c->request->path accordingly 
(match off $c->req->base domain)... it'd be an interesting plugin, 
that's for sure.  I'm sure some of the deeper Catalyst hackers can think 
of alternative, and perhaps simpler, ways to do it.


package MyApp::RequestRole::PrependHostName;
use Moose::Role;

around path => sub {
my ($orig, $self, @path) = @_;

return $self->$orig() if ! @path;

$self->$orig($self->hostname, @path));
};

package MyApp;
use Moose;
use Catalyst;
use Catalyst::App::RoleApplicator;

__PACKAGE__->apply_request_class_roles(
  qw/MyApp::RequestRole::PrependHostName/
);

I think would do what you want (untested).

I am unsure if this is a sane approach however, but that has already 
been covered elsewhere in the thread. :_)


Cheers
t0m

___
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] website member urls

2009-04-30 Thread Merlyn Kline

It could be also helpful if we could find a way to create urls like

http://user.hostname.com/

dynamicly as Google blogger site does.
We do this with a wildcard A record in the DNS and an Apache URL
rewriting rule that moves the hostname into the path. When I started writing
my app (in Catalytic pre-history) there wasn't any support (that I could
see) in Catalyst for using the hostname in the rules that decide when an
action is invoked and what parameters to pass to it. Things have moved on a
lot since then though so perhaps the URL rewriter could be replaced with a
better action description now.
Merlyn

 If others don't know more about a newer and better way as you
suggested, can you give some hints about the way you told about?
It's pretty simple. The wildcard A record in the DNS just makes sure that
all requests for http://.ourdomain.com/ are sent to the server.
The Apache URL rewriter goes in the Apache config file and is basically a
piece of code, typically like a perl s/// regexp, that hacks the URL up a
bit so that, for example, http://anything.ourdomain.com/path might be
presented to the back end as http://ourdomain.com/ouraction/anything/path or
whatever suits you. See
http://httpd.apache.org/docs/2.0/misc/rewriteguide.html for more info on
Apache URL rewriting.

The idea I had about Catalyst supporting this more directly was just that
there might be something like the PathPart() thing that would so something
similar with the hostname so you could say something like:

  sub handler : Chained('/') HostPart(something) CaptureArgs(1) {}

but from what J.Shirley said in another message it sounds like there is no
such thing. I'm afraid that's all a bit beyond me though - all my Catalyst
apps were started before the introduction of PathPart() and getting up to
date is still on my job list...

Merlyn


___
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] website member urls

2009-04-30 Thread J. Shirley
On Thu, Apr 30, 2009 at 7:14 PM, Octavian Rasnita wrote:

>  *From:* Merlyn Kline 
>
>
>
>  It could be also helpful if we could find a way to create urls like
>
> http://user.hostname.com/
>
> dynamicly as Google blogger site does.
>
> We do this with a wildcard A record in the DNS and an Apache URL rewriting
> rule that moves the hostname into the path. When I started writing my app
> (in Catalytic pre-history) there wasn't any support (that I could see) in
> Catalyst for using the hostname in the rules that decide when an action is
> invoked and what parameters to pass to it. Things have moved on a lot since
> then though so perhaps the URL rewriter could be replaced with a better
> action description now.
> Merlyn
>
>
>
>
> If others don't know more about a newer and better way as you suggested,
> can you give some hints about the way you told about?
>
>
>
> Thanks.
>
>
>
> Octavian
>
>
>
>
I don't see much reason for this to be inside of Catalyst, because the only
way to properly test is to stuff the Host: header with the data... that
could get a bit weird.

Instead, what you can easily do is just setup a rewrite rule in your
front-end webserver and translate the path accordingly (this is fairly
common).

If you did want to do something in Catalyst, you could create a plugin that
runs after prepare_path and modifies $c->request->path accordingly (match
off $c->req->base domain)... it'd be an interesting plugin, that's for
sure.  I'm sure some of the deeper Catalyst hackers can think of
alternative, and perhaps simpler, ways to do it.

I would highly recommend doing it at the webserver level, though...
Catalyst's uri_for would generate URIs like '
www.myapp.com/user/$foo/whatever' rather than $foo.myapp.com/whatever, but
that is the only drawback I can see.

-J
___
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] website member urls

2009-04-30 Thread Octavian Rasnita
From: Merlyn Kline 

  It could be also helpful if we could find a way to create urls like

  http://user.hostname.com/

  dynamicly as Google blogger site does. 
  We do this with a wildcard A record in the DNS and an Apache URL rewriting 
rule that moves the hostname into the path. When I started writing my app (in 
Catalytic pre-history) there wasn't any support (that I could see) in Catalyst 
for using the hostname in the rules that decide when an action is invoked and 
what parameters to pass to it. Things have moved on a lot since then though so 
perhaps the URL rewriter could be replaced with a better action description now.
  Merlyn



  If others don't know more about a newer and better way as you suggested, can 
you give some hints about the way you told about?



  Thanks.



  Octavian


___
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] website member urls

2009-04-30 Thread Merlyn Kline

It could be also helpful if we could find a way to create urls like

http://user.hostname.com/

dynamicly as Google blogger site does.
We do this with a wildcard A record in the DNS and an Apache URL rewriting
rule that moves the hostname into the path. When I started writing my app
(in Catalytic pre-history) there wasn't any support (that I could see) in
Catalyst for using the hostname in the rules that decide when an action is
invoked and what parameters to pass to it. Things have moved on a lot since
then though so perhaps the URL rewriter could be replaced with a better
action description now.

Merlyn
___
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] website member urls

2009-04-29 Thread Octavian Rasnita
From: Charles 
  technically, you're correct in that I should consider placing the usernames 
under /user. But I'm thinking of the fuzzy (to me) usability issues involved 
and the   http://website.com/ meme is what hundreds of millions non-developer 
users have come to expect.  Also, fwiw,  http://website.com/ is the user's 
profile which is publically viewable while http://website.com/member/ is the 
users url when they are logged in.


  Thanks so much for your input.


  Catalyst Rocks.


  -Charles
  **
  It could be also helpful if we could find a way to create urls like

  http://user.hostname.com/

  dynamicly as Google blogger site does.

  Octavian
___
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] website member urls

2009-04-29 Thread Mesdaq, Ali
Couldn’t you do something with the default method in the root controller? So 
similar to what others suggested except you would modify the default method so 
that if the user doesn’t exist you can 404 and have some kind of message.

Thanks,
--
Ali Mesdaq (CISSP, GIAC-GREM)
Sr. Security Researcher
Websense Security Labs
http://www.WebsenseSecurityLabs.com<http://www.websensesecuritylabs.com/>
--

From: Charles [mailto:cshtr...@yahoo.com]
Sent: Wednesday, April 29, 2009 1:23 PM
To: Catalyst@lists.scsys.co.uk
Subject: [Catalyst] website member urls

I'd like someone w/ better catalyst-fu to recommend how I could implement urls 
for members a la myspace and youtube ( ie  http://websiteurl.com/ ) 
.

There's got to be a better way that creating a seperate controller for each 
user.

perl 5.9
catalyst-runtime 5.71



Click here<https://www.mailcontrol.com/sr/wQw0zmjPoHdJTZGyOCrrhg==> to report 
this email as spam.


 Protected by Websense Hosted Email Security -- www.websense.com 
___
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] website member urls

2009-04-29 Thread Charles
correction: http://website.com/is the user's profile which is publically 
viewable ...




From: Charles 
To: The elegant MVC web framework 
Sent: Wednesday, April 29, 2009 5:46:23 PM
Subject: Re: [Catalyst] website member urls


John,

John,
technically, you're correct in that I should consider placing the usernames 
under /user. But I'm thinking of the fuzzy (to me) usability issues involved 
and the   http://website.com/ meme is what hundreds of millions non-developer 
users have come to expect.  Also, fwiw,  http://website.com/is the user's 
profile which is publically viewable while http://website.com/member/ is the 
users url when they are logged in.

Thanks so much for your input.

Catalyst Rocks.

-Charles


Are you sure you want to layout your URLs that way, though? You'll *never* need 
other top level items that might conflict with user names? If you put all the 
users under /user (or something like that) then they're in their own namespace 
and you won't have problems with name conflicts.
- john romkey
http://www.romkey.com/




From: John Romkey 
To: The elegant MVC web framework 
Sent: Wednesday, April 29, 2009 5:21:53 PM
Subject: Re: [Catalyst] website member urls


On Apr 29, 2009, at 4:52 PM, Charles wrote:
On Wed, Apr 29, 2009 at 05:31:43PM -0300, Fernan Aguero wrote:
> On Wed, Apr 29, 2009 at 5:23 PM, Charles  wrote:
> > I'd like someone w/ better catalyst-fu to recommend how I could implement
> > urls for members a la myspace and youtube ( ie
> >  http://websiteurl.com/  ) .
> > There's got to be a better way that creating a seperate controller for each
> > user.
> 
> sub member : Regex('\S+') {
>  my ($self, $c) = @_;

Using Regex for that seems weird to me.

  sub member : Chained(/) Args(1) {
my ($self, $c, $id) = @_;
...
  }
hans,

This seems to work, although, i'd have to add logic to have this member 
controller  ignore the following types of urls

http://websiteurl.com/signup
http://websiteurl.com/members/ <= users see this as their url when logged in.
Not at all. You just add handlers for those URLs to your controller; they're 
more specific than the member handler and should match.

sub signup : Chained('/') PathPart('signup') Args(0) {
...
}

Are you sure you want to layout your URLs that way, though? You'll *never* need 
other top level items that might conflict with user names? If you put all the 
users under /user (or something like that) then they're in their own namespace 
and you won't have problems with name conflicts.
- john romkey
http://www.romkey.com/


  ___
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] website member urls

2009-04-29 Thread Charles
John,

John,
technically, you're correct in that I should consider placing the usernames 
under /user. But I'm thinking of the fuzzy (to me) usability issues involved 
and the   http://website.com/meme is what hundreds of millions non-developer 
users have come to expect.  Also, fwiw,  http://website.com/is the user's 
profile which is publically viewable while http://website.com/member/ is the 
users url when they are logged in.

Thanks so much for your input.

Catalyst Rocks.

-Charles


Are you sure you want to layout your URLs that way, though? You'll *never* need 
other top level items that might conflict with user names? If you put all the 
users under /user (or something like that) then they're in their own namespace 
and you won't have problems with name conflicts.
- john romkey
http://www.romkey.com/




From: John Romkey 
To: The elegant MVC web framework 
Sent: Wednesday, April 29, 2009 5:21:53 PM
Subject: Re: [Catalyst] website member urls


On Apr 29, 2009, at 4:52 PM, Charles wrote:
On Wed, Apr 29, 2009 at 05:31:43PM -0300, Fernan Aguero wrote:
> On Wed, Apr 29, 2009 at 5:23 PM, Charles  wrote:
> > I'd like someone w/ better catalyst-fu to recommend how I could implement
> > urls for members a la myspace and youtube ( ie
> >  http://websiteurl.com/  ) .
> > There's got to be a better way that creating a seperate controller for each
> > user.
> 
> sub member : Regex('\S+') {
>  my ($self, $c) = @_;

Using Regex for that seems weird to me.

  sub member : Chained(/) Args(1) {
my ($self, $c, $id) = @_;
...
  }
hans,

This seems to work, although, i'd have to add logic to have this member 
controller  ignore the following types of urls

http://websiteurl.com/signup
http://websiteurl.com/members/ <= users see this as their url when logged in.
Not at all. You just add handlers for those URLs to your controller; they're 
more specific than the member handler and should match.

sub signup : Chained('/') PathPart('signup') Args(0) {
...
}

Are you sure you want to layout your URLs that way, though? You'll *never* need 
other top level items that might conflict with user names? If you put all the 
users under /user (or something like that) then they're in their own namespace 
and you won't have problems with name conflicts.
- john romkey
http://www.romkey.com/


  ___
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] website member urls

2009-04-29 Thread John Romkey

On Apr 29, 2009, at 4:52 PM, Charles wrote:

On Wed, Apr 29, 2009 at 05:31:43PM -0300, Fernan Aguero wrote:
> On Wed, Apr 29, 2009 at 5:23 PM, Charles  wrote:
> > I'd like someone w/ better catalyst-fu to recommend how I could  
implement

> > urls for members a la myspace and youtube ( ie
> >  http://websiteurl.com/ ) .
> > There's got to be a better way that creating a seperate  
controller for each

> > user.
>
> sub member : Regex('\S+') {
>  my ($self, $c) = @_;

Using Regex for that seems weird to me.

  sub member : Chained(/) Args(1) {
my ($self, $c, $id) = @_;
...
  }
hans,

This seems to work, although, i'd have to add logic to have this  
member controller  ignore the following types of urls


http://websiteurl.com/signup
http://websiteurl.com/members/ <= users see this as their url when  
logged in.


Not at all. You just add handlers for those URLs to your controller;  
they're more specific than the member handler and should match.


sub signup : Chained('/') PathPart('signup') Args(0) {
...
}

Are you sure you want to layout your URLs that way, though? You'll  
*never* need other top level items that might conflict with user  
names? If you put all the users under /user (or something like that)  
then they're in their own namespace and you won't have problems with  
name conflicts.

- john romkey
http://www.romkey.com/

___
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] website member urls

2009-04-29 Thread Charles
hans,

This seems to work, although, i'd have to add logic to have this member 
controller  ignore the following types of urls

http://websiteurl.com/signup
http://websiteurl.com/members/ <= users see this as their url when logged in.

-Charles




From: Hans Dieter Pearcey 
To: catalyst@lists.scsys.co.uk
Sent: Wednesday, April 29, 2009 4:42:08 PM
Subject: Re: [Catalyst] website member urls

On Wed, Apr 29, 2009 at 05:31:43PM -0300, Fernan Aguero wrote:
> On Wed, Apr 29, 2009 at 5:23 PM, Charles  wrote:
> > I'd like someone w/ better catalyst-fu to recommend how I could implement
> > urls for members a la myspace and youtube ( ie
> >  http://websiteurl.com/) .
> > There's got to be a better way that creating a seperate controller for each
> > user.
> 
> sub member : Regex('\S+') {
>  my ($self, $c) = @_;

Using Regex for that seems weird to me.

  sub member : Chained(/) Args(1) {
my ($self, $c, $id) = @_;
...
  }

hdp.

___
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/



  ___
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] website member urls

2009-04-29 Thread Hans Dieter Pearcey
On Wed, Apr 29, 2009 at 04:42:08PM -0400, Hans Dieter Pearcey wrote:
>   sub member : Chained(/) Args(1) {
> my ($self, $c, $id) = @_;
> ...
>   }

duh, with PathPart('') also.

hdp.

___
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] website member urls

2009-04-29 Thread Hans Dieter Pearcey
On Wed, Apr 29, 2009 at 05:31:43PM -0300, Fernan Aguero wrote:
> On Wed, Apr 29, 2009 at 5:23 PM, Charles  wrote:
> > I'd like someone w/ better catalyst-fu to recommend how I could implement
> > urls for members a la myspace and youtube ( ie
> >  http://websiteurl.com/ ) .
> > There's got to be a better way that creating a seperate controller for each
> > user.
> 
> sub member : Regex('\S+') {
>  my ($self, $c) = @_;

Using Regex for that seems weird to me.

  sub member : Chained(/) Args(1) {
my ($self, $c, $id) = @_;
...
  }

hdp.

___
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] website member urls

2009-04-29 Thread Fernan Aguero
On Wed, Apr 29, 2009 at 5:23 PM, Charles  wrote:
> I'd like someone w/ better catalyst-fu to recommend how I could implement
> urls for members a la myspace and youtube ( ie
>  http://websiteurl.com/ ) .
> There's got to be a better way that creating a seperate controller for each
> user.

sub member : Regex('\S+') {
 my ($self, $c) = @_;
 my $user = $c->req->captures->[0];

if ( $c->model->('Users')->find($user) ) {
 # user exists, do something
 }


}


-- 
fernan

___
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] website member urls

2009-04-29 Thread Charles
I'd like someone w/ better catalyst-fu to recommend how I could implement urls 
for members a la myspace and youtube ( ie  http://websiteurl.com/ ) 
. 

There's got to be a better way that creating a seperate controller for each 
user.

perl 5.9
catalyst-runtime 5.71


  ___
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/