Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: Mason newbe question

by ForgotPasswordAgain (Deacon)
on Jul 15, 2008 at 07:13 UTC ( #697653=note: print w/replies, xml ) Need Help??

in reply to Mason newbe question

Your config seems quite different than what I see in the article. Why are you using autohandler.mason, dhandler.mason, instead of autohandler and dhandler? It's as if you named your Perl scripts foo.Perl instead of

I think you're missing the first part of the configuration in your article:

PerlModule HTML::Mason::ApacheHandler <Location /gallery> SetHandler perl-script PerlHandler HTML::Mason::ApacheHandler </Location>
Without that, how would Apache know that Mason is in charge of things under /gallery?

Replies are listed 'Best First'.
Re^2: Mason newbe question
by John M. Dlugosz (Monsignor) on Jul 15, 2008 at 07:47 UTC
    I named the files with an extension so my text editor knows what "type" they are, and I'm used to files having extensions. And BTW, I do use ".perl" as an extension for perl programs.

    The /gallery location you cite causes big problems because all the .js and .css files get processed too! The download code is fancier than the article's version. So /gallery gets changed to (just) gallery/images and my cite-wide LocationMatch for .html files.

    The reason to handle all files in this subdirectory is because URI's will be generated for image file names with query strings, and that will pick up the real file from a different directory and resize it. I normally don't have Mason process .JPG files, and only want to turn that on in this special directory.

    So, if I change that back to /gallery, how do I exclude the gallery/css and other subdirectories?

    I can see in my own design I should learn this lesson and not mix up the virtual directories (gallery/Vacation/June/...) and its implementation file directories (gallery/js, gallery/css).


      Well, okay this is mostly Apache config not Perl:

      # By default, Mason handles everything <Directory /var/www-mason> SetHandler perl-script PerlHandler HTML::Mason::ApacheHandler Options Includes FollowSymLinks AllowOverride None Order allow,deny Allow from all # whatever else... </Directory> # But we don't want bare autohandler or dhandler served by Apache <LocationMatch "handler$"> SetHandler perl-script PerlInitHandler Apache::Constants::NOT_FOUND </LocationMatch> # Nor do we want Mason touching stylesheets, javascript, or images <Location /css> SetHandler default-handler </Location> <Location /js> SetHandler default-handler Options FollowSymLinks Indexes </Location> <Location /img> SetHandler default-handler </Location>

      And if there's some directory under Mason control that I want to switch to non-HTML, I can put this in an autohandler if for example I wanted to output JSON:

      <%init>; # get rid of crap from parent autohandler $m->clear_buffer(); # change content-type $r->content_type('application/json; charset=utf-8'); # call any dhandlers, etc. $m->call_next(); $m->flush_buffer(); # but don't go back to the parent autohandler $m->abort(); </%init>

      And well generally there are other tricks but it depends on what you're doing.

        Can you specify, for example, that any directory named js has the default-handler? That is, cover foo/bar/js and this/that/js and any future directories I create with one declaration?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://697653]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2018-05-25 02:00 GMT
Find Nodes?
    Voting Booth?