Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 52 lines (41 sloc) 1.668 kB
#!/usr/bin/env perl
use Koha;
use Plack::App::CGIBin;
use Plack::Builder;
use Koha::Plack::Util;
my $root = $ENV{KOHA_BASE} // '.';
my $app = Plack::App::CGIBin->new(root => $root)->to_app;
sub is_staff {
my $hostname = Koha::Plack::Util::GetCanonicalHostname(shift);
if ($ENV{KOHA_STAFF}) { return 1 } # for VPN with only IP
return $hostname =~ /-staff\./;
}
use Koha::Squatting::Branch 'On::PSGI';
use Koha::Squatting::Reserve 'On::PSGI';
use Koha::Squatting::Z3950 'On::PSGI';
Koha::Squatting::Reserve->init;
Koha::Squatting::Z3950->init;
Koha::Squatting::Branch->init;
builder {
enable_if { $_[0]->{REMOTE_ADDR} eq '127.0.0.1' }
'Plack::Middleware::ReverseProxy';
enable 'Deflater';
enable 'HTTPExceptions';
enable 'MethodOverride';
enable 'Static', path => qr{^/opac-tmpl/}, root => "$root/koha-tmpl/";
enable 'Static', path => qr{^/intranet-tmpl/}, root => "$root/koha-tmpl/";
enable 'Status', path => qr{/C4/|/Koha/|/misc/|/t/|/xt/|/etc/}, status => 404;
enable 'Rewrite', rules => sub {
my $env = shift;
return 302 if (is_staff($env) && s{^/$}{/cgi-bin/koha/mainpage.pl});
return 302 if (!is_staff($env) && s{^/$}{/cgi-bin/koha/opac-main.pl});
if (!is_staff($env)) { s{^/cgi-bin/koha/}{/cgi-bin/koha/opac/}}
return;
};
enable 'Header', unset => ['Status'];
enable '+Koha::Plack::Localize';
mount '/reserves/' => sub {Koha::Squatting::Reserve->psgi(shift)};
mount '/z3950/' => sub {Koha::Squatting::Z3950->psgi(shift)};
mount '/branches/' => sub {Koha::Squatting::Branch->psgi(shift)};
mount '/cgi-bin/koha/' => $app;
};
Jump to Line
Something went wrong with that request. Please try again.