move our panels to top, run only low-impact debug
[koha.git] / misc / plack / koha.psgi
1 #!/usr/bin/perl
2 use Plack::Builder;
3 use Plack::App::CGIBin;
4 use lib qw( ./p5-plack-devel-debug-devel-size/lib ./lib );
5 use Plack::Middleware::Debug;
6 use Plack::App::Directory;
7
8 use C4::Context;
9 use C4::Languages;
10 use C4::Members;
11 use C4::Dates;
12 use C4::Boolean;
13 use C4::Letters;
14 use C4::Koha;
15 use C4::XSLT;
16 use C4::Branch;
17 use C4::Category;
18
19 use Devel::Size 0.77; # 0.71 doesn't work for Koha
20 my $watch_size = [
21         map { s/^.*C4/C4/; s/\//::/g; s/\.pm$//; $_ } # fix paths
22         grep { /C4/ }
23         keys %INC
24 ];
25         
26
27 my $app=Plack::App::CGIBin->new(root => $ENV{INTRANETDIR} || $ENV{OPACDIR});
28
29 builder {
30
31         enable_if { $ENV{PLACK_DEBUG} } 'Debug',  panels => [
32                 qw(Koha Persistant),
33                 qw(Environment Response Timer Memory),
34                 [ 'Profiler::NYTProf', exclude => [qw(.*\.css .*\.png .*\.ico .*\.js .*\.gif)] ],
35 #               [ 'DBITrace', level => 1 ], # a LOT of fine-graded SQL trace
36                 [ 'DBIProfile', profile => 2 ],
37 #               [ 'Devel::Size', for => $watch_size ],
38         ];
39
40         enable_if { $ENV{PLACK_DEBUG} } 'StackTrace';
41
42         enable_if { $ENV{INTRANETDIR} } "Plack::Middleware::Static",
43                 path => qr{^/intranet-tmpl/}, root => '/srv/koha/koha-tmpl/';
44
45         enable_if { $ENV{OPACDIR} } "Plack::Middleware::Static",
46                 path => qr{^/opac-tmpl/}, root => '/srv/koha/koha-tmpl/';
47
48         enable_if { $ENV{PLACK_MINIFIER} } "Plack::Middleware::Static::Minifier",
49                 path => qr{^/(intranet|opac)-tmpl/},
50                 root => './koha-tmpl/';
51
52
53         mount "/cgi-bin/koha" => $app;
54
55 };
56