From: Tomas Doran Date: Thu, 28 May 2009 01:13:42 +0000 (+0000) Subject: Revert config key change which broke all the tests and provided no back compat. svn... X-Git-Tag: v0.22~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Plugin-Static-Simple.git;a=commitdiff_plain;h=86880b0ddf3f233ccf32b67c4d2dd03725b21c96 Revert config key change which broke all the tests and provided no back compat. svn diff -r9644:9643 . | patch -p0 --- diff --git a/Changes b/Changes index bcf222d..978ce64 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,5 @@ Revision history for Perl extension Catalyst::Plugin::Static::Simple - - Fix config key (mst) - Fix docs to not include plugins in call to ->setup() (t0m) 0.21 2009-03-29 20:31:49 diff --git a/lib/Catalyst/Plugin/Static/Simple.pm b/lib/Catalyst/Plugin/Static/Simple.pm index 02801de..6993ff0 100644 --- a/lib/Catalyst/Plugin/Static/Simple.pm +++ b/lib/Catalyst/Plugin/Static/Simple.pm @@ -13,12 +13,10 @@ our $VERSION = '0.21'; __PACKAGE__->mk_accessors( qw/_static_file _static_debug_message/ ); -my $CONFIG_KEY = "Plugin::Static::Simple"; - sub prepare_action { my $c = shift; my $path = $c->req->path; - my $config = $c->config->{$CONFIG_KEY} ||= $c->config->{static}; + my $config = $c->config->{static}; $path =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg; @@ -61,7 +59,7 @@ sub dispatch { return if ( $c->res->status != 200 ); if ( $c->_static_file ) { - if ( $c->config->{$CONFIG_KEY}{no_logs} && $c->log->can('abort') ) { + if ( $c->config->{static}{no_logs} && $c->log->can('abort') ) { $c->log->abort( 1 ); } return $c->_serve_static; @@ -75,7 +73,7 @@ sub finalize { my $c = shift; # display all log messages - if ( $c->config->{$CONFIG_KEY}{debug} && scalar @{$c->_debug_msg} ) { + if ( $c->config->{static}{debug} && scalar @{$c->_debug_msg} ) { $c->log->debug( 'Static::Simple: ' . join q{ }, @{$c->_debug_msg} ); } @@ -91,7 +89,7 @@ sub setup { require File::Slurp; } - my $config = $c->config->{$CONFIG_KEY} ||= {}; + my $config = $c->config->{static} ||= {}; $config->{dirs} ||= []; $config->{include_path} ||= [ $c->config->{root} ]; @@ -119,7 +117,7 @@ sub _locate_static_file { File::Spec->no_upwards( File::Spec->splitdir( $path ) ) ); - my $config = $c->config->{$CONFIG_KEY}; + my $config = $c->config->{static}; my @ipaths = @{ $config->{include_path} }; my $dpaths; my $count = 64; # maximum number of directories to search @@ -207,7 +205,7 @@ sub _serve_static { sub serve_static_file { my ( $c, $full_path ) = @_; - my $config = $c->config->{$CONFIG_KEY} ||= {}; + my $config = $c->config->{static} ||= {}; if ( -e $full_path ) { $c->_debug_msg( "Serving static file: $full_path" ) @@ -228,7 +226,7 @@ sub serve_static_file { sub _ext_to_type { my ( $c, $full_path ) = @_; - my $config = $c->config->{$CONFIG_KEY}; + my $config = $c->config->{static}; if ( $full_path =~ /.*\.(\S{1,})$/xms ) { my $ext = $1; @@ -339,8 +337,8 @@ Logging of static files is turned off by default. =head1 ADVANCED CONFIGURATION Configuration is completely optional and is specified within -Cconfig-E{'Plugin::Static::Simple'}>. If you use any of these -options, this module will probably feel less "simple" to you! +Cconfig-E{static}>. If you use any of these options, +this module will probably feel less "simple" to you! =head2 Enabling request logging @@ -348,7 +346,7 @@ Since Catalyst 5.50, logging of static requests is turned off by default; static requests tend to clutter the log output and rarely reveal anything useful. However, if you want to enable logging of static requests, you can do so by setting -Cconfig-E{'Plugin::Static::Simple'}-E{logging}> to 1. +Cconfig-E{static}-E{logging}> to 1. =head2 Forcing directories into static mode @@ -356,7 +354,7 @@ Define a list of top-level directories beneath your 'root' directory that should always be served in static mode. Regular expressions may be specified using C. - MyApp->config->{'Plugin::Static::Simple'}->{dirs} = [ + MyApp->config->{static}->{dirs} = [ 'static', qr/^(images|css)/, ]; @@ -369,7 +367,7 @@ first file found. Note that your root directory is B automatically added to the search path when you specify an C. You should use Cconfig-E{root}> to add it. - MyApp->config->{'Plugin::Static::Simple'}->{include_path} = [ + MyApp->config->{static}->{include_path} = [ '/path/to/overlay', \&incpath_generator, MyApp->config->{root} @@ -409,7 +407,7 @@ C will be ignored by Static::Simple in the interest of security. If you wish to define your own extensions to ignore, use the C option: - MyApp->config->{'Plugin::Static::Simple'}->{ignore_extensions} + MyApp->config->{static}->{ignore_extensions} = [ qw/html asp php/ ]; =head2 Ignoring entire directories @@ -419,7 +417,7 @@ the C option. This option contains a list of relative directory paths to ignore. If using C, the path will be checked against every included path. - MyApp->config->{'Plugin::Static::Simple'}->{ignore_dirs} = [ qw/tmpl css/ ]; + MyApp->config->{static}->{ignore_dirs} = [ qw/tmpl css/ ]; For example, if combined with the above C setting, this C value will ignore the following directories if they exist: @@ -436,7 +434,7 @@ C value will ignore the following directories if they exist: To override or add to the default MIME types set by the L module, you may enter your own extension to MIME type mapping. - MyApp->config->{'Plugin::Static::Simple'}->{mime_types} = { + MyApp->config->{static}->{mime_types} = { jpg => 'image/jpg', png => 'image/png', }; @@ -452,7 +450,7 @@ many compatibility issues with other plugins. Enable additional debugging information printed in the Catalyst log. This is automatically enabled when running Catalyst in -Debug mode. - MyApp->config->{'Plugin::Static::Simple'}->{debug} = 1; + MyApp->config->{static}->{debug} = 1; =head1 USING WITH APACHE