aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/Offline.pm
blob: 7b17bb569b2f452b9cc4147cbb876798ea1e9a0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package FixMyStreet::App::Controller::Offline;
use Moose;
use namespace::autoclean;

BEGIN { extends 'Catalyst::Controller'; }

=head1 NAME

FixMyStreet::App::Controller::Offline - Catalyst Controller

=head1 DESCRIPTION

Offline pages Catalyst Controller.

=head1 METHODS

=cut

sub have_appcache : Private {
    my ($self, $c) = @_;
    return $c->user_exists && $c->user->has_body_permission_to('planned_reports');
}

sub manifest : Path("/offline/appcache.manifest") {
    my ($self, $c) = @_;
    unless ($c->forward('have_appcache')) {
        $c->response->status(404);
        $c->response->body('NOT FOUND');
    }
    $c->res->content_type('text/cache-manifest; charset=utf-8');
    $c->res->header(Cache_Control => 'no-cache, no-store');
}

sub appcache : Path("/offline/appcache") {
    my ($self, $c) = @_;
    $c->detach('/page_error_404_not_found', []) if keys %{$c->req->params};
    unless ($c->forward('have_appcache')) {
        $c->response->status(404);
        $c->response->body('NOT FOUND');
    }
}

__PACKAGE__->meta->make_immutable;

1;