On Jan 3, 2008, at 3:24 PM, Emily Heureux wrote:

(I am starting a brand new email, not replying to an existing one, which I now realize I have been doing, but maybe not every time. Am I sending these to the wrong place? The address I have is [email protected] . Did I do it right this time?)

My question: I have a directory under root: /static/images/ pdbFiles where I have files without extensions for a java applet I am running on my webpage. Catalyst does not seem to recognize them unless I put an extension, like .txt. Do I need to configure Catalyst so that it sees those files as static files?

On cpan, I found that I can force directories into static mode using this (for example):

MyApp->config->{static}->{dirs} = [
        'static',
        qr/^(images/pdbFiles|)/,
    ];

but, where do I put this code, if that is, in fact, what I am supposed to do? And since I want it to work for files with no extensions, what do I put after the pipe?

If you already have your files in /static, then it will do what you want by default. The problem is that without an extension, Static::Simple can't determine the correct MIME type, so it uses text/ html. One approach to handling this is to subclass Catalyst::Plugin::Static::Simple and override _ext_to_type so it returns the correct MIME type for those files...


package MyApp::Plugin::Static::Simple;
use strict;
use warnings;
use base qw( Catalyst::Plugin::Static::Simple );

sub _ext_to_type {
        my ( $self, $path ) = @_;

        if ( $path =~ /pdbFiles/ ) {
                return 'application/x-java-applet';
        } else {
                return $self->SUPER::_ext_to_type( $path );
        }
}

1;

Then in your application class...

use Catalyst qw(
        +MyApp::Plugin::Static::Simple
        Session Cache Whatever...
);

--
Jason Kohles, RHCA RHCDS RHCE
[EMAIL PROTECTED] - http://www.jasonkohles.com/
"A witty saying proves nothing."  -- Voltaire


_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to