1 package Koha
::App
::Intranet
;
3 # Copyright 2020 BibLibre
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22 use Mojo
::Base
'Mojolicious';
25 use Koha
::Cache
::Memory
::Lite
;
30 push @
{$self->plugins->namespaces}, 'Koha::App::Plugin';
31 push @
{$self->static->paths}, $self->home->rel_file('koha-tmpl');
33 # Create route for all CGI scripts, need to be loaded first because of
35 $self->plugin('CGIBinKoha');
37 # Create routes for API
38 # FIXME This generates routes like this: /api/api/v1/...
39 $self->plugin('RESTV1');
41 $self->hook(before_dispatch
=> \
&_before_dispatch
);
42 $self->hook(around_action
=> \
&_around_action
);
44 my $r = $self->routes;
46 $r->any('/')->to(cb
=> sub { shift->redirect_to('/cgi-bin/koha/mainpage.pl') });
49 sub _before_dispatch
{
52 my $path = $c->req->url->path->to_string;
54 # Remove Koha version from URL
55 $path =~ s/_\d{2}\.\d{7}\.(js|css)/.$1/;
58 if ($path =~ m
|^/api/v
|) {
59 $path = '/api' . $path;
62 $c->req->url->path->parse($path);
66 my ($next, $c, $action, $last) = @_;
68 # Flush memory caches before every request
69 Koha
::Caches
->flush_L1_caches();
70 Koha
::Cache
::Memory
::Lite
->flush();
81 Koha::App::Intranet - Mojolicious app for Koha's Intranet Client
85 Run the Koha Intranet using Mojolicious servers
91 Called at application startup; Sets up routes, loads plugins and invokes hooks.