$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'}
C<setup> 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<Catalyst>, L<Catalyst::Plugin::Static>,
--- /dev/null
+#!perl
+
+use strict;
+use warnings;
+
+use FindBin;
+use lib "$FindBin::Bin/lib";
+
+use Test::More tests => 4;
+use Catalyst::Test 'TestApp';
+
+# test passthrough to root
+ok( my $res = request('http://localhost/images/bad.gif'), 'request ok' );
+is( $res->content_type, 'image/gif', 'root path ok' );
+
+is( scalar @{ TestApp->config->{'Plugin::Static::Simple'}->{include_path} }, 1, 'One include path used');
+is( TestApp->config->{'Plugin::Static::Simple'}->{include_path}->[0], TestApp->config->{root}, "It's the root path" );
--- /dev/null
+#!perl
+
+use strict;
+use warnings;
+
+use FindBin;
+use lib "$FindBin::Bin/lib";
+
+use Test::More tests => 5;
+use Catalyst::Test 'IncTestApp';
+
+is( $TestLog::logged, "Deprecated 'static' config key used, please use the key 'Plugin::Static::Simple' instead",
+ "Got warning" );
+
+# test overlay dir
+ok( my $res = request('http://localhost/overlay.jpg'), 'request ok' );
+is( $res->content_type, 'image/jpeg', 'overlay path ok' );
+
+# test passthrough to root
+ok( $res = request('http://localhost/images/bad.gif'), 'request ok' );
+is( $res->content_type, 'image/gif', 'root path ok' );
+
--- /dev/null
+package IncTestApp;\r
+# FIXME: I have to do this because TestApp runs setup at compile time\r
+# Perhaps it would be better to let the tests run setup?\r
+\r
+use strict;\r
+use Catalyst;\r
+use FindBin;\r
+use TestLog;\r
+\r
+our $VERSION = '0.01';\r
+\r
+IncTestApp->config(\r
+ name => 'TestApp',\r
+ debug => 1,\r
+ static => {\r
+ include_path => [\r
+ IncTestApp->config->{root},\r
+ ]\r
+ },\r
+ 'Plugin::Static::Simple' => {\r
+ include_path => [\r
+ IncTestApp->config->{root} . '/overlay',\r
+ ]\r
+ },\r
+);\r
+\r
+IncTestApp->log( TestLog->new );\r
+my @plugins = qw/Static::Simple/;\r
+\r
+# load the SubRequest plugin if available\r
+eval { \r
+ require Catalyst::Plugin::SubRequest; \r
+ die unless Catalyst::Plugin::SubRequest->VERSION ge '0.08';\r
+};\r
+push @plugins, 'SubRequest' unless ($@);\r
+\r
+IncTestApp->setup( @plugins );\r
+\r
+sub incpath_generator {\r
+ my $c = shift;\r
+ \r
+ return [ $c->config->{root} . '/incpath' ];\r
+}\r
+\r
+\r
+1;\r
--- /dev/null
+package IncTestApp::Controller::Root;\r
+\r
+use strict;\r
+use warnings;\r
+use File::Spec::Functions;\r
+\r
+use base qw/Catalyst::Controller/;\r
+\r
+__PACKAGE__->config(namespace => '');\r
+\r
+sub default : Private {\r
+ my ( $self, $c ) = @_;\r
+ \r
+ $c->res->output( 'default' );\r
+}\r
+\r
+sub subtest : Local {\r
+ my ( $self, $c ) = @_;\r
+\r
+ $c->res->output( $c->subreq('/subtest2') );\r
+}\r
+\r
+sub subtest2 : Local {\r
+ my ( $self, $c ) = @_;\r
+ \r
+ $c->res->output( 'subtest2 ok' );\r
+}\r
+\r
+sub serve_static : Local {\r
+ my ( $self, $c ) = @_;\r
+ \r
+ my $file = catfile( $FindBin::Bin, 'lib', 'TestApp.pm' );\r
+ \r
+ $c->serve_static_file( $file );\r
+}\r
+\r
+sub serve_static_404 : Local {\r
+ my ( $self, $c ) = @_;\r
+ \r
+ my $file = catfile( $FindBin::Bin, 'lib', 'foo.pm' );\r
+ \r
+ $c->serve_static_file( $file );\r
+}\r
+\r
+1;\r
--- /dev/null
+I am a text file!
--- /dev/null
+<html>
+ <head>
+ <title>test</title>
+ </head>
+ <body>
+ <div>test</div>
+ </body>
+</html>
--- /dev/null
+body {
+ background: #fff;
+}
--- /dev/null
+body {
+ background: #fff;
+}
--- /dev/null
+body {
+ background: #fff;
+}
--- /dev/null
+body {
+ background: #fff;
+}
--- /dev/null
+body {
+ background: #fff;
+}
--- /dev/null
+body {
+ background: #fff;
+}
--- /dev/null
+body {
+ background: #fff;
+}
--- /dev/null
+body {
+ background: #fff;
+}
--- /dev/null
+body {
+ background: #fff;
+}
--- /dev/null
+body {
+ background: #fff;
+}
--- /dev/null
+body {
+ background: #fff;
+}
--- /dev/null
+body {
+ background: #fff;
+}
--- /dev/null
+body {
+ background: #fff;
+}
--- /dev/null
+body {
+ background: #fff;
+}
--- /dev/null
+body {
+ background: #fff;
+}
--- /dev/null
+body {
+ background: #fff;
+}