Re: [Catalyst] Root page for site (my first attempt!)

2011-02-24 Thread Octavian Rasnita

From: John M. Dlugosz wxju46g...@snkmail.com
...


And as Carl recommended, it is good to not hard-code the URLS in the 
templates because they won't work if you'll want to make some changes and 
want to put the whole application to listen to a different base than /, 
for example /old-site.


So use $c-uri_for('/path/to/static/file');
or
$c-uri_for_action('/path/to/action'); #for the dynamic pages


I see, so do that for static files too, not just actions?




Yes you should do this for static files too, because if you'll move the 
entire application, say from / to /old-app, then the static files will also 
move from /images to /old-app/images.


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] Root page for site (my first attempt!)

2011-02-23 Thread Carl Franks
On 23 February 2011 11:30, John M. Dlugosz wxju46g...@snkmail.com wrote:
 I just started trying Catalyst.  I went through the Packt Publishing book, 
 but now want a more technical explanation with details.  Any suggestions on 
 what documentation to read?

 With the situation as set-up by default, I would write:
    img src=/static/images/bad_logo.png /
 to access a site image.  How can I configure it so I can write
    src=foo/bad_logo.png
 instead?

Using TT, that would be:
[% c.uri_for('/foo/bad_logo.png') %]

Cheers,
Carl

___
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] Root page for site (my first attempt!)

2011-02-23 Thread Octavian Rasnita

From: John M. Dlugosz wxju46g...@snkmail.com
I just started trying Catalyst.  I went through the Packt Publishing book, 
but now want a more technical explanation with details.  Any suggestions on 
what documentation to read?


With the situation as set-up by default, I would write:
   img src=/static/images/bad_logo.png /
to access a site image.  How can I configure it so I can write
   src=foo/bad_logo.png
instead?




By default, Catalyst apps keep the static content in the /static directory.
Usually you also want to configure the web server to not send the requests 
to /static to Catalyst, but to serve the files directly for performance 
reasons.


If it wouldn't do so, think what might happen if you'll also make a 
controller named Foo that will use the /foo path...


But you can create one or more directory with static files, for example 
/images, /js, /css. These directories must be created under the root 
directory.
And of course, it is recommended to configure the web server to not send the 
requests to those directories to the Catalyst app.


And as Carl recommended, it is good to not hard-code the URLS in the 
templates because they won't work if you'll want to make some changes and 
want to put the whole application to listen to a different base than /, for 
example /old-site.


So use $c-uri_for('/path/to/static/file');
or
$c-uri_for_action('/path/to/action'); #for the dynamic pages

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] Root page for site (my first attempt!)

2011-02-23 Thread John M. Dlugosz

 On 2/23/2011 5:41 AM, Carl Franks fireartist-at-gmail.com |Catalyst/Allow to 
home| wrote:

On 23 February 2011 11:30, John M. Dlugoszwxju46g...@snkmail.com  wrote:

I just started trying Catalyst.  I went through the Packt Publishing book, but 
now want a more technical explanation with details.  Any suggestions on what 
documentation to read?

With the situation as set-up by default, I would write:
img src=/static/images/bad_logo.png /
to access a site image.  How can I configure it so I can write
src=foo/bad_logo.png
instead?

Using TT, that would be:
 [% c.uri_for('/foo/bad_logo.png') %]

Cheers,
Carl


I mean make the things under /foo serve as static files!

My understanding is that uri_for takes a Controller's private spec and produces the 
URL.  So what you wrote would be if I had a controller named Foo with a method named 
bad_logo.png.  Am I missing something here?


___
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] Root page for site (my first attempt!)

2011-02-23 Thread John M. Dlugosz
 On 2/23/2011 6:26 AM, Octavian Rasnita orasnita-at-gmail.com |Catalyst/Allow to home| 
wrote:


But you can create one or more directory with static files, for example /images, /js, 
/css. These directories must be created under the root directory.
And of course, it is recommended to configure the web server to not send the requests to 
those directories to the Catalyst app.


That's exactly what I want.  How do I tell Catalyst that /images should be static files 
under /root/images, rather than a controller named Images?




And as Carl recommended, it is good to not hard-code the URLS in the templates because 
they won't work if you'll want to make some changes and want to put the whole 
application to listen to a different base than /, for example /old-site.


So use $c-uri_for('/path/to/static/file');
or
$c-uri_for_action('/path/to/action'); #for the dynamic pages


I see, so do that for static files too, not just actions?



___
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] Root page for site (my first attempt!)

2011-02-23 Thread will trillich
In your main lib/MyApp.pm file you'll probably notice you've got a line of
code like
use Catalyst qw/ ... Static::Simple .../;

That pulls in Catalyst::Plugin::Static::Simple which does the part you're
asking about.

See
http://search.cpan.org/~mstrout/Catalyst-Plugin-Static-Simple-0.29/lib/Catalyst/Plugin/Static/Simple.pm
for
tricks on configuring it to do your bidding.


Also, when running under a webserver such as Apache, you'd likely do some
configuring there to have the webserver send the static files directly
instead of calling on Catalyst to parse through them.

E.g.
http://search.cpan.org/dist/Catalyst-Runtime/lib/Catalyst/Engine/FastCGI.pm#Static_mode



On Wed, Feb 23, 2011 at 7:21 PM, John M. Dlugosz wxju46g...@snkmail.comwrote:

  On 2/23/2011 6:26 AM, Octavian Rasnita orasnita-at-gmail.com|Catalyst/Allow 
 to home| wrote:


 But you can create one or more directory with static files, for example
 /images, /js, /css. These directories must be created under the root
 directory.
 And of course, it is recommended to configure the web server to not send
 the requests to those directories to the Catalyst app.


 That's exactly what I want.  How do I tell Catalyst that /images should be
 static files under /root/images, rather than a controller named Images?



 And as Carl recommended, it is good to not hard-code the URLS in the
 templates because they won't work if you'll want to make some changes and
 want to put the whole application to listen to a different base than /, for
 example /old-site.

 So use $c-uri_for('/path/to/static/file');
 or
 $c-uri_for_action('/path/to/action'); #for the dynamic pages

  I see, so do that for static files too, not just actions?




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




-- 
The first step towards getting somewhere is to decide that you are not going
to stay where you are.  -- J.P.Morgan
___
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/