mount static files
[koha.git] / app.psgi
index 612eee1..7ff4c25 100755 (executable)
--- a/app.psgi
+++ b/app.psgi
@@ -3,6 +3,7 @@
 use CGI::Compile;
 use CGI::Emulate::PSGI;
 use Plack::App::URLMap;
+use Plack::App::Directory;
 
 use lib '/srv/koha';
 my $app = Plack::App::URLMap->new;
@@ -13,6 +14,7 @@ my $to   = '/cgi-bin/koha';
 foreach my $script ( glob "$from/*" ) {
        my $path = $script;
        $path =~ s{^$from}{} || die;
+       $path =~ s{^/+}{};
 
        my $sub = eval { CGI::Compile->compile($script) };
 
@@ -22,8 +24,10 @@ foreach my $script ( glob "$from/*" ) {
        }
 
        my $cgi_app = CGI::Emulate::PSGI->handler($sub);
-       $app->mount( "$to/$path", $cgi_app );
+       $app->mount( "$to/$path" => $cgi_app );
        warn "# script $script -> $to/$path";
 }
 
+$app->mount( '/' => Plack::App::Directory->new( { root => '/srv/koha/koha-tmpl/' } )->to_app );
+
 $app;