Bug 16733: Adjust other debian scripts using PERL5LIB
[koha.git] / debian / templates / plack.psgi
1 #!/usr/bin/perl
2
3 # This file is part of Koha.
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18 use Modern::Perl;
19
20 use Plack::Builder;
21 use Plack::App::CGIBin;
22 use Plack::App::Directory;
23 use Plack::App::URLMap;
24
25 # Pre-load libraries
26 use C4::Boolean;
27 use C4::Branch;
28 use C4::Category;
29 use C4::Koha;
30 use C4::Languages;
31 use C4::Letters;
32 use C4::Members;
33 use C4::XSLT;
34 use Koha::Cache;
35 use Koha::Cache::Memory::Lite;
36 use Koha::Database;
37 use Koha::DateUtils;
38
39 use CGI qw(-utf8 ); # we will loose -utf8 under plack, otherwise
40 {
41     no warnings 'redefine';
42     my $old_new = \&CGI::new;
43     *CGI::new = sub {
44         my $q = $old_new->( @_ );
45         $CGI::PARAM_UTF8 = 1;
46         Koha::Cache->flush_L1_cache();
47         Koha::Cache::Memory::Lite->flush();
48         return $q;
49     };
50 }
51
52 my $home = $ENV{KOHA_HOME};
53 my $intranet = Plack::App::CGIBin->new(
54     root => $ENV{DEV_INSTALL}? $home: "$home/intranet/cgi-bin"
55 )->to_app;
56
57 my $opac = Plack::App::CGIBin->new(
58     root => $ENV{DEV_INSTALL}? "$home/opac": "$home/opac/cgi-bin/opac"
59 )->to_app;
60
61 # my $api  = Plack::App::CGIBin->new(
62 #     root => '/usr/share/koha/api/'
63 # )->to_app;
64
65 builder {
66
67     enable "ReverseProxy";
68     enable "Plack::Middleware::Static";
69
70     mount '/opac'     => $opac;
71     mount '/intranet' => $intranet;
72     # mount '/api'       => $api;
73 };