aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/Offline.pm
diff options
context:
space:
mode:
authorMarius Halden <marius.h@lden.org>2017-05-28 21:31:42 +0200
committerMarius Halden <marius.h@lden.org>2017-05-28 21:31:42 +0200
commit987124b09a32248414faf4d0d6615d43b29ac6f6 (patch)
treea549db8af723c981d3b346e855f25d6fd5ff8aa7 /perllib/FixMyStreet/App/Controller/Offline.pm
parentdbf56159e44c1560a413022451bf1a1c4cb22a52 (diff)
parenta085b63ce09f87e83b75cda9b9cd08aadfe75d61 (diff)
Merge tag 'v2.0.4' into fiksgatami-dev
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Offline.pm')
-rw-r--r--perllib/FixMyStreet/App/Controller/Offline.pm47
1 files changed, 47 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Offline.pm b/perllib/FixMyStreet/App/Controller/Offline.pm
new file mode 100644
index 000000000..dceccc81f
--- /dev/null
+++ b/perllib/FixMyStreet/App/Controller/Offline.pm
@@ -0,0 +1,47 @@
+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.
+On staging site, appcache only for people who want it.
+
+=head1 METHODS
+
+=cut
+
+sub have_appcache : Private {
+ my ($self, $c) = @_;
+ return $c->user_exists && $c->user->has_body_permission_to('planned_reports')
+ && !FixMyStreet->staging_flag('enable_appcache', 0);
+}
+
+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;