X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FPlugin%2FStatic%2FSimple.pm;h=e547b72dc641530e4528c4d2fce62b02e5ec3e2a;hb=b771f9550df5b0486ec4df1fdd018f452c37e4a6;hp=a0a00e7f073eebbdba029b9995e9d993563b1446;hpb=c338a2151d2645aaf4732167b321c5f8e52a613b;p=catagits%2FCatalyst-Plugin-Static-Simple.git diff --git a/lib/Catalyst/Plugin/Static/Simple.pm b/lib/Catalyst/Plugin/Static/Simple.pm old mode 100644 new mode 100755 index a0a00e7..e547b72 --- a/lib/Catalyst/Plugin/Static/Simple.pm +++ b/lib/Catalyst/Plugin/Static/Simple.pm @@ -5,14 +5,22 @@ use File::stat; use File::Spec (); use IO::File (); use MIME::Types (); -use MooseX::Types::Moose qw/ArrayRef Str/; use Catalyst::Utils; use namespace::autoclean; -our $VERSION = '0.30'; +our $VERSION = '0.37'; has _static_file => ( is => 'rw' ); -has _static_debug_message => ( is => 'rw', isa => ArrayRef[Str] ); +has _static_debug_message => ( is => 'rw', isa => 'ArrayRef[Str]' ); + +after setup_finalize => sub { + my $c = shift; + + # New: Turn off new 'autoflush' flag in logger (see Catalyst::Log). + # This is needed to surpress output of debug log messages for + # static requests: + $c->log->autoflush(0) if $c->log->can('autoflush'); +}; before prepare_action => sub { my $c = shift; @@ -55,7 +63,7 @@ before prepare_action => sub { } # Does the path have an extension? - if ( $path =~ /.*\.(\S{1,})$/xms ) { + if ( $path =~ /\.([^\/\\]+)$/m ) { # and does it exist? $c->_locate_static_file( $path ); } @@ -92,6 +100,14 @@ before setup_finalize => sub { $c->log->warn("Deprecated 'static' config key used, please use the key 'Plugin::Static::Simple' instead") if exists $c->config->{static}; + + if (exists $c->config->{static}->{include_path}) { + $c->config->{'Plugin::Static::Simple'}->{include_path} = [ + @{$c->config->{'Plugin::Static::Simple'}->{include_path} || []}, + @{delete $c->config->{static}->{include_path} || []} + ]; + } + my $config = $c->config->{'Plugin::Static::Simple'} = $c->config->{'static'} @@ -305,7 +321,7 @@ properly. If the plugin can not find the file, the request is dispatched to your application instead. This means you are responsible for generating a -C<404> error if your applicaton can not process the request: +C<404> error if your application can not process the request: # handled by static::simple, not dispatched to your application /images/exists.png @@ -577,6 +593,18 @@ messages. C initializes all default values. +=head1 DEPRECATIONS + +The old style of configuration using the C<'static'> config key was deprecated +in version 0.30. A warning will be issued if this is used, and the contents of +the config at this key will be merged with the newer C<'Plugin::Static::Simple'> +key. + +Be aware that if the C<'include_path'> key under C<'static'> exists at all, it +will be merged with any content of the same key under +C<'Plugin::Static::Simple'>. Be careful not to set this to a non-arrayref, +therefore. + =head1 SEE ALSO L, L,