aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2019-12-19 14:55:35 +0000
committerMatthew Somerville <matthew@mysociety.org>2020-02-14 10:38:49 +0000
commitb5a6187db01a997b6beea8dea4f21908b2be6091 (patch)
treeb1660deea52a26f70017632af25f267f110f2944
parent0e80a90bebc12fe381892386f9ffd751edb38d7c (diff)
Remove appcache (breaking showing reports from localStorage cache).
-rw-r--r--conf/general.yml-docker3
-rw-r--r--conf/general.yml-example3
-rw-r--r--docs/customising/config.md5
-rw-r--r--perllib/FixMyStreet/App/Controller/Offline.pm29
-rw-r--r--perllib/FixMyStreet/App/Controller/Root.pm5
-rw-r--r--t/app/controller/root.t12
-rw-r--r--templates/web/base/header.html5
-rw-r--r--templates/web/base/offline/appcache.html14
-rw-r--r--templates/web/base/offline/appcache_manifest.html16
-rw-r--r--templates/web/oxfordshire/header.html5
-rw-r--r--web/cobrands/fixmystreet/offline.js71
11 files changed, 31 insertions, 137 deletions
diff --git a/conf/general.yml-docker b/conf/general.yml-docker
index c73bd3657..33dcad67b 100644
--- a/conf/general.yml-docker
+++ b/conf/general.yml-docker
@@ -52,13 +52,10 @@ STAGING_SITE: 1
# this to 1 if you want a staging site to route reports as normal.
# - skip_checks: Manual testing of multiple cobrands can be made easier by
# skipping some checks they have in them, if this variable is set.
-# - enable_appcache: Whether the appcache should be active. NB: Only affects
-# superuser sessions.
STAGING_FLAGS:
send_reports: 0
skip_checks: 0
hide_staging_banner: 0
- enable_appcache: 0
# What to use as front page/alert example places placeholder
# Defaults to High Street, Main Street
diff --git a/conf/general.yml-example b/conf/general.yml-example
index 9bf6d1d05..8e8d0f76a 100644
--- a/conf/general.yml-example
+++ b/conf/general.yml-example
@@ -52,13 +52,10 @@ STAGING_SITE: 1
# this to 1 if you want a staging site to route reports as normal.
# - skip_checks: Manual testing of multiple cobrands can be made easier by
# skipping some checks they have in them, if this variable is set.
-# - enable_appcache: Whether the appcache should be active. NB: Only affects
-# superuser sessions.
STAGING_FLAGS:
send_reports: 0
skip_checks: 0
hide_staging_banner: 0
- enable_appcache: 0
# What to use as front page/alert example places placeholder
# Defaults to High Street, Main Street
diff --git a/docs/customising/config.md b/docs/customising/config.md
index ff994a25b..c5ac015b7 100644
--- a/docs/customising/config.md
+++ b/docs/customising/config.md
@@ -348,13 +348,12 @@ STAGING_FLAGS:
send_reports: 0
skip_checks: 1
hide_staging_banner: 1
- enable_appcache: 0
</pre>
</div>
<p>
Any reports created will now be sent to the email of the reporter
- and <em>not</em> the body's; any location checks are skipped, and
- we won't ever use appcache. Great for testing!
+ and <em>not</em> the body's; and any location checks are skipped.
+ Great for testing!
</p>
</dd>
diff --git a/perllib/FixMyStreet/App/Controller/Offline.pm b/perllib/FixMyStreet/App/Controller/Offline.pm
index d8b9180dd..57cbe201c 100644
--- a/perllib/FixMyStreet/App/Controller/Offline.pm
+++ b/perllib/FixMyStreet/App/Controller/Offline.pm
@@ -14,7 +14,7 @@ FixMyStreet::App::Controller::Offline - Catalyst Controller
=head1 DESCRIPTION
-Offline pages Catalyst Controller - service worker and appcache.
+Offline pages Catalyst Controller - service worker handling
=head1 METHODS
@@ -82,33 +82,6 @@ sub manifest: Path("/.well-known/manifest.webmanifest") {
$c->res->body($json);
}
-# Old appcache functions below
-
-sub have_appcache : Private {
- my ($self, $c) = @_;
- return $c->user_exists && $c->user->has_body_permission_to('planned_reports')
- && !($c->user->is_superuser && FixMyStreet->staging_flag('enable_appcache', 0));
-}
-
-sub appcache_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} && !$c->req->query_keywords;
- unless ($c->forward('have_appcache')) {
- $c->response->status(404);
- $c->response->body('NOT FOUND');
- }
-}
-
__PACKAGE__->meta->make_immutable;
1;
diff --git a/perllib/FixMyStreet/App/Controller/Root.pm b/perllib/FixMyStreet/App/Controller/Root.pm
index fb6d063be..caaa260ff 100644
--- a/perllib/FixMyStreet/App/Controller/Root.pm
+++ b/perllib/FixMyStreet/App/Controller/Root.pm
@@ -159,11 +159,6 @@ sub check_login_required : Private {
}x;
return if $c->request->path =~ $whitelist;
- # Blacklisted URLs immediately 404
- # This is primarily to work around a Safari bug where the appcache
- # URL is requested in an infinite loop if it returns a 302 redirect.
- $c->detach('/page_error_404_not_found', []) if $c->request->path =~ /^offline/;
-
$c->detach( '/auth/redirect' );
}
diff --git a/t/app/controller/root.t b/t/app/controller/root.t
index 85119da24..0263b65d7 100644
--- a/t/app/controller/root.t
+++ b/t/app/controller/root.t
@@ -60,18 +60,6 @@ FixMyStreet::override_config {
is $mech->res->previous, undef, 'No redirect';
}
};
-
- subtest 'LOGIN_REQUIRED = 1 404s blacklisted URLs' => sub {
- my @blacklist = (
- '/offline/appcache',
- );
-
- foreach my $url (@blacklist) {
- $mech->get($url);
- ok !$mech->res->is_success(), "want a bad response";
- is $mech->res->code, 404, "got 404";
- }
- };
};
subtest "check_login_disallowed cobrand hook" => sub {
diff --git a/templates/web/base/header.html b/templates/web/base/header.html
index 74ec2d16a..b3d77b3a6 100644
--- a/templates/web/base/header.html
+++ b/templates/web/base/header.html
@@ -6,10 +6,7 @@
<!doctype html>
<!--[if IE 8]> <html class="no-js ie8"[% html_att | safe %]><![endif]-->
<!--[if IE 9]> <html class="no-js ie9"[% html_att | safe %]><![endif]-->
-<!--[if gt IE 9]><!--><html class="no-js"[% html_att | safe %]
-[% IF appcache ~%]
- manifest="/offline/appcache.manifest"
-[%~ END %]><!--<![endif]-->
+<!--[if gt IE 9]><!--><html class="no-js"[% html_att | safe %]><!--<![endif]-->
<head>
<meta name="viewport" content="initial-scale=1.0">
diff --git a/templates/web/base/offline/appcache.html b/templates/web/base/offline/appcache.html
deleted file mode 100644
index ed48b7a00..000000000
--- a/templates/web/base/offline/appcache.html
+++ /dev/null
@@ -1,14 +0,0 @@
-[% SET bodyclass = "fullwidthpage offlinepage" ~%]
-[% INCLUDE 'header.html' appcache = 1 %]
-
-<h1>[% loc('Internet glitch') %]</h1>
-
-<p>[% loc('Sorry, we don’t have a good enough connection to fetch that page, or the
-page wasn’t found or there was a server error. Please try again later.') %]
-</p>
-
-<ul class="item-list item-list--reports" id="offline_list"></ul>
-
-<div id="offline_clear"></div>
-
-[% INCLUDE 'footer.html' %]
diff --git a/templates/web/base/offline/appcache_manifest.html b/templates/web/base/offline/appcache_manifest.html
deleted file mode 100644
index 93d26cb94..000000000
--- a/templates/web/base/offline/appcache_manifest.html
+++ /dev/null
@@ -1,16 +0,0 @@
-CACHE MANIFEST
-
-[% PROCESS 'common_scripts.html' ~%]
-
-CACHE:
-[% version('/cobrands/' _ c.cobrand.asset_moniker _ '/base.css') %]
-[% version('/cobrands/' _ c.cobrand.asset_moniker _ '/layout.css') %]
-[% FOR script IN scripts ~%]
- [%- script %]
-[% END %]
-
-NETWORK:
-*
-
-FALLBACK:
-/ [% version('../templates/web/base/offline/appcache.html', '/offline/appcache') %]
diff --git a/templates/web/oxfordshire/header.html b/templates/web/oxfordshire/header.html
index 70d7e4b18..72cba2aec 100644
--- a/templates/web/oxfordshire/header.html
+++ b/templates/web/oxfordshire/header.html
@@ -1,10 +1,7 @@
<!doctype html>
<!--[if IE 8]> <html class="no-js ie8" lang="[% lang_code %]"><![endif]-->
<!--[if IE 9]> <html class="no-js ie9" lang="[% lang_code %]"><![endif]-->
-<!--[if gt IE 9]><!--><html class="no-js" lang="[% lang_code %]"
-[% IF appcache ~%]
- manifest="/offline/appcache.manifest"
-[%~ END %]><!--<![endif]-->
+<!--[if gt IE 9]><!--><html class="no-js" lang="[% lang_code %]"><!--<![endif]-->
<head>
<meta name="viewport" content="initial-scale=1.0">
diff --git a/web/cobrands/fixmystreet/offline.js b/web/cobrands/fixmystreet/offline.js
index 648375afd..d43a5cc2e 100644
--- a/web/cobrands/fixmystreet/offline.js
+++ b/web/cobrands/fixmystreet/offline.js
@@ -308,13 +308,7 @@ fixmystreet.offline = (function() {
}
function showReportFromCache(url) {
- var html = localStorage.getItem(url);
- if (!html) {
- return false;
- }
var map = localStorage.getItem(url + '/map');
- var found = html.match(/<body[^>]*>[\s\S]*<\/body>/);
- document.body.outerHTML = found[0];
$('#map_box').html('<img src="' + map + '">').css({ textAlign: 'center', height: 'auto' });
replaceImages('img');
@@ -375,49 +369,36 @@ fixmystreet.offline = (function() {
if ($('#offline_list').length) {
// We are OFFLINE
- var success = false;
- if (location.pathname.indexOf('/report') === 0) {
- success = fixmystreet.offline.showReportFromCache(location.pathname);
- }
- if (!success) {
- var html = localStorage.getItem('/my/planned');
- if (html) {
- $('#offline_list').before('<h2>'+translation_strings.offline.your_reports+'</h2>');
- $('#offline_list').html(html);
- if (location.search.indexOf('saved=1') > 0) {
- $('#offline_list').before('<p class="form-success">'+translation_strings.offline.update_saved+'</p>');
- }
- fixmystreet.offline.replaceImages('#offline_list img');
- var offlineForms = fixmystreet.offlineData.getForms();
- var savedForms = {};
- offlineForms.forEach(function(form) {
- savedForms[form[0]] = 1;
- });
- $('#offline_list a').each(function(i, a) {
- if (savedForms[a.href]) {
- $(this).find('h3').prepend('<em>'+translation_strings.offline.update_data_saved+'</em> ');
- }
- });
- $('#offline_clear').css('margin-top', '5em').html('<button id="js-clear-localStorage">'+translation_strings.offline.clear_data+'</button>');
- $('#js-clear-localStorage').click(function() {
- if (window.confirm(translation_strings.offline.are_you_sure)) {
- fixmystreet.offline.removeReports(fixmystreet.offlineData.getCachedUrls());
- fixmystreet.offlineData.clearForms();
- localStorage.removeItem('/my/planned');
- alert(translation_strings.offline.data_cleared);
- }
- });
+ var html = localStorage.getItem('/my/planned');
+ if (html) {
+ $('#offline_list').before('<h2>'+translation_strings.offline.your_reports+'</h2>');
+ $('#offline_list').html(html);
+ if (location.search.indexOf('saved=1') > 0) {
+ $('#offline_list').before('<p class="form-success">'+translation_strings.offline.update_saved+'</p>');
}
+ fixmystreet.offline.replaceImages('#offline_list img');
+ var offlineForms = fixmystreet.offlineData.getForms();
+ var savedForms = {};
+ offlineForms.forEach(function(form) {
+ savedForms[form[0]] = 1;
+ });
+ $('#offline_list a').each(function(i, a) {
+ if (savedForms[a.href]) {
+ $(this).find('h3').prepend('<em>'+translation_strings.offline.update_data_saved+'</em> ');
+ }
+ });
+ $('#offline_clear').css('margin-top', '5em').html('<button id="js-clear-localStorage">'+translation_strings.offline.clear_data+'</button>');
+ $('#js-clear-localStorage').click(function() {
+ if (window.confirm(translation_strings.offline.are_you_sure)) {
+ fixmystreet.offline.removeReports(fixmystreet.offlineData.getCachedUrls());
+ fixmystreet.offlineData.clearForms();
+ localStorage.removeItem('/my/planned');
+ alert(translation_strings.offline.data_cleared);
+ }
+ });
}
fixmystreet.offlineBanner.make(true);
} else {
- // If we're using appcache, not a service worker, put the appcache manifest
- // in a page in an iframe so that HTML pages aren't cached
- // (thanks to Jake Archibald for documenting this!)
- if (!('serviceWorker' in navigator) && window.applicationCache && window.localStorage) {
- $(document.body).prepend('<iframe src="/offline/appcache" style="position:absolute;top:-999em;visibility:hidden"></iframe>');
- }
-
fixmystreet.offlineBanner.make(false);
// On /my/planned, when online, cache all shortlisted