From 020769f403ef4cf1880bd061b6db6b4f4028d3e4 Mon Sep 17 00:00:00 2001
From: Matthew Somerville
Date: Thu, 1 Dec 2016 18:23:54 +0000
Subject: Return 400/500 for some client/server errors.
---
perllib/FixMyStreet/App/Controller/Auth.pm | 13 +++++--------
perllib/FixMyStreet/App/Controller/Dashboard.pm | 4 ++--
perllib/FixMyStreet/App/Controller/Questionnaire.pm | 9 ++++-----
perllib/FixMyStreet/App/Controller/Reports.pm | 7 +++----
perllib/FixMyStreet/App/Controller/Root.pm | 19 +++++++++++++++++--
perllib/FixMyStreet/App/Controller/Tokens.pm | 1 +
t/app/controller/moderate.t | 3 ++-
t/app/controller/questionnaire.t | 6 +++++-
t/app/controller/report_updates.t | 6 ++++--
9 files changed, 43 insertions(+), 25 deletions(-)
diff --git a/perllib/FixMyStreet/App/Controller/Auth.pm b/perllib/FixMyStreet/App/Controller/Auth.pm
index 40cd163cf..c448f8749 100644
--- a/perllib/FixMyStreet/App/Controller/Auth.pm
+++ b/perllib/FixMyStreet/App/Controller/Auth.pm
@@ -271,9 +271,8 @@ sub facebook_callback: Path('/auth/Facebook') : Args(0) {
$access_token = $fb->get_access_token(code => $c->get_param('code'));
};
if ($@) {
- ($c->stash->{message} = $@) =~ s/at [^ ]*Auth.pm.*//;
- $c->stash->{template} = 'errors/generic.html';
- $c->detach;
+ (my $message = $@) =~ s/at [^ ]*Auth.pm.*//;
+ $c->detach('/page_error_500_internal_error', [ $message ]);
}
# save this token in session
@@ -339,9 +338,8 @@ sub twitter_callback: Path('/auth/Twitter') : Args(0) {
$twitter->request_access_token(verifier => $verifier);
};
if ($@) {
- ($c->stash->{message} = $@) =~ s/at [^ ]*Auth.pm.*//;
- $c->stash->{template} = 'errors/generic.html';
- $c->detach;
+ (my $message = $@) =~ s/at [^ ]*Auth.pm.*//;
+ $c->detach('/page_error_500_internal_error', [ $message ]);
}
my $info = $twitter->verify_credentials();
@@ -527,8 +525,7 @@ sub check_csrf_token : Private {
sub no_csrf_token : Private {
my ($self, $c) = @_;
- $c->stash->{message} = _('Unknown error');
- $c->stash->{template} = 'errors/generic.html';
+ $c->detach('/page_error_400_bad_request', []);
}
=head2 sign_out
diff --git a/perllib/FixMyStreet/App/Controller/Dashboard.pm b/perllib/FixMyStreet/App/Controller/Dashboard.pm
index 9189b28e5..fbe5a2dc9 100644
--- a/perllib/FixMyStreet/App/Controller/Dashboard.pm
+++ b/perllib/FixMyStreet/App/Controller/Dashboard.pm
@@ -57,9 +57,9 @@ sub example : Local : Args(0) {
}
};
if ($@) {
- $c->stash->{message} = _("There was a problem showing this page. Please try again later.") . ' ' .
+ my $message = _("There was a problem showing this page. Please try again later.") . ' ' .
sprintf(_('The error was: %s'), $@);
- $c->stash->{template} = 'errors/generic.html';
+ $c->detach('/page_error_500_internal_error', [ $message ]);
}
}
diff --git a/perllib/FixMyStreet/App/Controller/Questionnaire.pm b/perllib/FixMyStreet/App/Controller/Questionnaire.pm
index 017a552db..1b338732b 100755
--- a/perllib/FixMyStreet/App/Controller/Questionnaire.pm
+++ b/perllib/FixMyStreet/App/Controller/Questionnaire.pm
@@ -36,9 +36,8 @@ sub check_questionnaire : Private {
if ( $questionnaire->whenanswered ) {
my $problem_url = $c->cobrand->base_url_for_report( $problem ) . $problem->url;
my $contact_url = $c->uri_for( "/contact" );
- $c->stash->{message} = sprintf(_("You have already answered this questionnaire. If you have a question, please get in touch, or view your problem.\n"), $contact_url, $problem_url);
- $c->stash->{template} = 'errors/generic.html';
- $c->detach;
+ my $message = sprintf(_("You have already answered this questionnaire. If you have a question, please get in touch, or view your problem.\n"), $contact_url, $problem_url);
+ $c->detach('/page_error_400_bad_request', [ $message ]);
}
unless ( $problem->is_visible ) {
@@ -86,8 +85,8 @@ Display couldn't locate problem error message
sub missing_problem : Private {
my ( $self, $c ) = @_;
- $c->stash->{message} = _("I'm afraid we couldn't locate your problem in the database.\n");
- $c->stash->{template} = 'errors/generic.html';
+ my $message = _("I'm afraid we couldn't locate your problem in the database.\n");
+ $c->detach('/page_error_400_bad_request', [ $message ]);
}
sub submit_creator_fixed : Private {
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm
index 813c2052d..f2c43b5ee 100644
--- a/perllib/FixMyStreet/App/Controller/Reports.pm
+++ b/perllib/FixMyStreet/App/Controller/Reports.pm
@@ -76,13 +76,12 @@ sub index : Path : Args(0) {
$c->stash->{open} = $j->{open};
};
if ($@) {
- $c->stash->{message} = _("There was a problem showing the All Reports page. Please try again later.");
+ my $message = _("There was a problem showing the All Reports page. Please try again later.");
if ($c->config->{STAGING_SITE}) {
- $c->stash->{message} .= '
Perhaps the bin/update-all-reports script needs running. Use: bin/update-all-reports
'
+ $message .= '
Perhaps the bin/update-all-reports script needs running. Use: bin/update-all-reports
'
. sprintf(_('The error was: %s'), $@);
}
- $c->stash->{template} = 'errors/generic.html';
- return;
+ $c->detach('/page_error_500_internal_error', [ $message ]);
}
# Down here so that error pages aren't cached.
diff --git a/perllib/FixMyStreet/App/Controller/Root.pm b/perllib/FixMyStreet/App/Controller/Root.pm
index 3d4c6a1ba..1df249999 100644
--- a/perllib/FixMyStreet/App/Controller/Root.pm
+++ b/perllib/FixMyStreet/App/Controller/Root.pm
@@ -103,9 +103,24 @@ sub page_error_410_gone : Private {
sub page_error_403_access_denied : Private {
my ( $self, $c, $error_msg ) = @_;
+ $c->detach('page_error', [ $error_msg || _("Sorry, you don't have permission to do that."), 403 ]);
+}
+
+sub page_error_400_bad_request : Private {
+ my ( $self, $c, $error_msg ) = @_;
+ $c->detach('page_error', [ $error_msg, 400 ]);
+}
+
+sub page_error_500_internal_error : Private {
+ my ( $self, $c, $error_msg ) = @_;
+ $c->detach('page_error', [ $error_msg, 500 ]);
+}
+
+sub page_error : Private {
+ my ($self, $c, $error_msg, $code) = @_;
$c->stash->{template} = 'errors/generic.html';
- $c->stash->{message} = $error_msg || _("Sorry, you don't have permission to do that.");
- $c->response->status(403);
+ $c->stash->{message} = $error_msg || _('Unknown error');
+ $c->response->status($code);
}
=head2 end
diff --git a/perllib/FixMyStreet/App/Controller/Tokens.pm b/perllib/FixMyStreet/App/Controller/Tokens.pm
index da017c57f..a1b0c57ba 100644
--- a/perllib/FixMyStreet/App/Controller/Tokens.pm
+++ b/perllib/FixMyStreet/App/Controller/Tokens.pm
@@ -348,6 +348,7 @@ sub token_too_old : Private {
my ( $self, $c ) = @_;
$c->stash->{token_not_found} = 1;
$c->stash->{template} = 'auth/token.html';
+ $c->response->status(400);
}
__PACKAGE__->meta->make_immutable;
diff --git a/t/app/controller/moderate.t b/t/app/controller/moderate.t
index 0ccfcf2c2..3a3c7a708 100644
--- a/t/app/controller/moderate.t
+++ b/t/app/controller/moderate.t
@@ -67,7 +67,8 @@ subtest 'Auth' => sub {
$mech->get_ok($REPORT_URL);
$mech->content_lacks('Moderat');
- $mech->get_ok('/contact?m=1&id=' . $report->id);
+ $mech->get('/contact?m=1&id=' . $report->id);
+ is $mech->res->code, 400;
$mech->content_lacks('Good bad bad bad');
};
diff --git a/t/app/controller/questionnaire.t b/t/app/controller/questionnaire.t
index b05f74225..f42908a3e 100644
--- a/t/app/controller/questionnaire.t
+++ b/t/app/controller/questionnaire.t
@@ -87,16 +87,19 @@ foreach my $test (
desc => 'User goes to questionnaire URL with a bad token',
token_extra => 'BAD',
content => "Sorry, that wasn’t a valid link",
+ code => 400,
},
{
desc => 'User goes to questionnaire URL for a now-hidden problem',
state => 'hidden',
content => "we couldn't locate your problem",
+ code => 400,
},
{
desc => 'User goes to questionnaire URL for an already answered questionnaire',
answered => \'current_timestamp',
content => 'already answered this questionnaire',
+ code => 400,
},
) {
subtest $test->{desc} => sub {
@@ -106,7 +109,8 @@ foreach my $test (
$questionnaire->update;
(my $token = $token->token);
$token .= $test->{token_extra} if $test->{token_extra};
- $mech->get_ok("/Q/$token");
+ $mech->get("/Q/$token");
+ is $mech->res->code, $test->{code}, "Right status received";
$mech->content_contains( $test->{content} );
# Reset, no matter what test did
$report->state( 'confirmed' );
diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t
index 5a88097fa..f7544f0a1 100644
--- a/t/app/controller/report_updates.t
+++ b/t/app/controller/report_updates.t
@@ -1829,7 +1829,8 @@ for my $test (
subtest 'check have to be logged in for creator fixed questionnaire' => sub {
$mech->log_out_ok();
- $mech->get_ok( "/questionnaire/submit?problem=$report_id&reported=Yes" );
+ $mech->get( "/questionnaire/submit?problem=$report_id&reported=Yes" );
+ is $mech->res->code, 400, "got 400";
$mech->content_contains( "I'm afraid we couldn't locate your problem in the database." )
};
@@ -1838,7 +1839,8 @@ subtest 'check cannot answer other user\'s creator fixed questionnaire' => sub {
$mech->log_out_ok();
$mech->log_in_ok( $user2->email );
- $mech->get_ok( "/questionnaire/submit?problem=$report_id&reported=Yes" );
+ $mech->get( "/questionnaire/submit?problem=$report_id&reported=Yes" );
+ is $mech->res->code, 400, "got 400";
$mech->content_contains( "I'm afraid we couldn't locate your problem in the database." )
};
--
cgit v1.2.3
From 37aaea540af32fd2c40f01471cb9374bc872aa45 Mon Sep 17 00:00:00 2001
From: Matthew Somerville
Date: Thu, 1 Dec 2016 16:13:02 +0000
Subject: Default inspect form to save with public update.
---
t/app/controller/report_inspect.t | 4 ++--
templates/web/base/report/_inspect.html | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/t/app/controller/report_inspect.t b/t/app/controller/report_inspect.t
index 56e6e957f..70b8c9586 100644
--- a/t/app/controller/report_inspect.t
+++ b/t/app/controller/report_inspect.t
@@ -57,7 +57,7 @@ FixMyStreet::override_config {
};
subtest "test basic inspect submission" => sub {
- $mech->submit_form_ok({ button => 'save', with_fields => { traffic_information => 'Yes', state => 'Planned' } });
+ $mech->submit_form_ok({ button => 'save', with_fields => { traffic_information => 'Yes', state => 'Planned', save_inspected => undef } });
$report->discard_changes;
is $report->state, 'planned', 'report state changed';
is $report->get_extra_metadata('traffic_information'), 'Yes', 'report data changed';
@@ -201,7 +201,7 @@ FixMyStreet::override_config {
# which should cause it to be resent. We clear the host because
# otherwise testing stays on host() above.
$mech->clear_host;
- $mech->submit_form(button => 'save', with_fields => { category => 'Horses' });
+ $mech->submit_form(button => 'save', with_fields => { category => 'Horses', save_inspected => undef, });
$report->discard_changes;
is $report->category, "Horses", "Report in correct category";
diff --git a/templates/web/base/report/_inspect.html b/templates/web/base/report/_inspect.html
index ccaa756c5..c83085e59 100644
--- a/templates/web/base/report/_inspect.html
+++ b/templates/web/base/report/_inspect.html
@@ -136,7 +136,7 @@
[% IF permissions.report_inspect %]
--
cgit v1.2.3
From e1f11deee821dd6540a76966731c94d31effa826 Mon Sep 17 00:00:00 2001
From: Matthew Somerville
Date: Wed, 7 Dec 2016 14:14:22 +0000
Subject: Drop unneeded Cancel button on inspect form.
---
templates/web/base/report/_inspect.html | 1 -
1 file changed, 1 deletion(-)
diff --git a/templates/web/base/report/_inspect.html b/templates/web/base/report/_inspect.html
index c83085e59..ba11bbcbd 100644
--- a/templates/web/base/report/_inspect.html
+++ b/templates/web/base/report/_inspect.html
@@ -157,7 +157,6 @@
- [% loc('Cancel') %]
--
cgit v1.2.3
From fddf7f9585e50a60acca01b84bc8f9cfc267dd0b Mon Sep 17 00:00:00 2001
From: Matthew Somerville
Date: Fri, 25 Nov 2016 17:44:05 +0000
Subject: Add offline support of static files/fallback page.
Use a list to store JavaScript files, so it can be shared
between the HTML footer and the appcache manifest.
---
perllib/FixMyStreet/App/Controller/Offline.pm | 32 ++++++++++++++++
perllib/FixMyStreet/App/View/Web.pm | 5 ++-
perllib/FixMyStreet/Cobrand/Base.pm | 14 +++++++
templates/web/angus/maps/fms.html | 22 +++++------
templates/web/base/common_footer_tags.html | 31 ++++-----------
templates/web/base/common_scripts.html | 44 ++++++++++++++++++++++
templates/web/base/front/javascript.html | 19 ++++++----
templates/web/base/header.html | 19 ++++------
templates/web/base/index.html | 2 +-
templates/web/base/maps/bing.html | 16 ++++----
templates/web/base/maps/fms.html | 18 ++++-----
templates/web/base/maps/google-ol.html | 14 ++++---
templates/web/base/maps/google.html | 10 +++--
templates/web/base/maps/mapquest-attribution.html | 17 ++++-----
templates/web/base/maps/osm-streetview.html | 17 ++++-----
templates/web/base/maps/osm-toner-lite.html | 19 +++++-----
templates/web/base/maps/osm.html | 17 ++++-----
templates/web/base/offline/appcache.html | 8 ++++
templates/web/base/offline/manifest.html | 17 +++++++++
templates/web/base/report/photo-js.html | 6 +--
templates/web/base/reports/index.html | 6 +--
templates/web/bristol/footer_extra_js.html | 10 +++--
templates/web/bristol/maps/bristol.html | 14 ++++---
templates/web/bromley/footer_extra_js.html | 4 +-
templates/web/bromley/maps/bromley.html | 19 +++++-----
.../fixmystreet-uk-councils/footer_extra_js.html | 6 ++-
templates/web/fixmystreet.com/about/posters.html | 6 +--
templates/web/fixmystreet.com/footer_extra_js.html | 8 ++--
.../web/fixmystreet.com/front/javascript.html | 19 ++++++----
templates/web/oxfordshire/header.html | 5 ++-
templates/web/zurich/maps/zurich.html | 16 ++++----
web/cobrands/fixmystreet/offline.js | 5 +++
32 files changed, 296 insertions(+), 169 deletions(-)
create mode 100644 perllib/FixMyStreet/App/Controller/Offline.pm
create mode 100644 templates/web/base/common_scripts.html
create mode 100644 templates/web/base/offline/appcache.html
create mode 100644 templates/web/base/offline/manifest.html
create mode 100644 web/cobrands/fixmystreet/offline.js
diff --git a/perllib/FixMyStreet/App/Controller/Offline.pm b/perllib/FixMyStreet/App/Controller/Offline.pm
new file mode 100644
index 000000000..9acb33f7e
--- /dev/null
+++ b/perllib/FixMyStreet/App/Controller/Offline.pm
@@ -0,0 +1,32 @@
+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 manifest : Path("/offline/appcache.manifest") {
+ my ($self, $c) = @_;
+ $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};
+}
+
+__PACKAGE__->meta->make_immutable;
+
+1;
diff --git a/perllib/FixMyStreet/App/View/Web.pm b/perllib/FixMyStreet/App/View/Web.pm
index f0bcad0be..22387f5f6 100644
--- a/perllib/FixMyStreet/App/View/Web.pm
+++ b/perllib/FixMyStreet/App/View/Web.pm
@@ -140,7 +140,8 @@ sub escape_js {
my %version_hash;
sub version {
- my ( $self, $c, $file ) = @_;
+ my ( $self, $c, $file, $url ) = @_;
+ $url ||= $file;
_version_get_mtime($file);
if ($version_hash{$file} && $file =~ /\.js$/) {
# See if there's an auto.min.js version and use that instead if there is
@@ -149,7 +150,7 @@ sub version {
$file = $file_min if $version_hash{$file_min} >= $version_hash{$file};
}
my $admin = $self->template->context->stash->{admin} ? FixMyStreet->config('ADMIN_BASE_URL') : '';
- return "$admin$file?$version_hash{$file}";
+ return "$admin$url?$version_hash{$file}";
}
sub _version_get_mtime {
diff --git a/perllib/FixMyStreet/Cobrand/Base.pm b/perllib/FixMyStreet/Cobrand/Base.pm
index 5a9842233..a9eed0018 100644
--- a/perllib/FixMyStreet/Cobrand/Base.pm
+++ b/perllib/FixMyStreet/Cobrand/Base.pm
@@ -38,6 +38,20 @@ sub moniker {
return $last_part;
}
+=head2 asset_moniker
+
+ $moniker = $cobrand_class->asset_moniker();
+
+Same as moniker, except for the cobrand with the 'fixmystreet' moniker, when it
+returns 'fixmystreet.com', as to avoid confusion that's where its assets are.
+
+=cut
+
+sub asset_moniker {
+ my $self = shift;
+ return $self->moniker eq 'fixmystreet' ? 'fixmystreet.com' : $self->moniker;
+}
+
=head2 is_default
$bool = $cobrand->is_default();
diff --git a/templates/web/angus/maps/fms.html b/templates/web/angus/maps/fms.html
index aed4d1764..1516ae05e 100644
--- a/templates/web/angus/maps/fms.html
+++ b/templates/web/angus/maps/fms.html
@@ -1,11 +1,11 @@
-[% map_js = BLOCK %]
-
-
-
-
-
-
-
-[% END %]
-
-[% map_html = INCLUDE maps/openlayers.html include_key = 1 %]
+[%
+map_js = [
+ version('/js/OpenLayers/OpenLayers.angus.js'),
+ version('/js/map-OpenLayers.js'),
+ version('/js/map-bing-ol.js'),
+ version('/js/map-fms.js'),
+ version('/cobrands/fixmystreet/assets.js'),
+ version('/cobrands/angus/js.js'),
+];
+map_html = INCLUDE maps/openlayers.html include_key = 1
+%]
diff --git a/templates/web/base/common_footer_tags.html b/templates/web/base/common_footer_tags.html
index 45872895b..01420c37d 100644
--- a/templates/web/base/common_footer_tags.html
+++ b/templates/web/base/common_footer_tags.html
@@ -1,28 +1,13 @@
-[% USE date %][% USE Math %]
-
[% TRY %][% PROCESS 'footer_extra.html' %][% CATCH file %][% END %]
-
-
+[% PROCESS 'common_scripts.html' %]
+
-
-
-
-
-
-
-
-
-[% map_js %]
-
-
-[% IF admin %]
-
-
+[% FOR script IN scripts ~%]
+ [% script = script.0 ? script : [ script ] ~%]
+
[% END %]
-
-[% extra_js %]
-
-[% TRY %][% PROCESS 'footer_extra_js.html' %][% CATCH file %][% END %]
diff --git a/templates/web/base/common_scripts.html b/templates/web/base/common_scripts.html
new file mode 100644
index 000000000..1d53f1d51
--- /dev/null
+++ b/templates/web/base/common_scripts.html
@@ -0,0 +1,44 @@
+[%
+
+USE date;
+USE Math;
+
+scripts = [];
+
+scripts.push(
+ start _ "/js/translation_strings." _ lang_code _ ".js?" _ Math.int( date.now / 3600 ),
+ version('/jslib/jquery-1.7.2.min.js'),
+ version('/js/validation_rules.js'),
+ version('/js/jquery.validate.min.js'),
+ version('/js/dropzone.min.js'),
+ version('/js/jquery.multi-select.js'),
+ version('/js/geo.min.js'),
+ version('/cobrands/fixmystreet/fixmystreet.js'),
+);
+
+FOR script IN map_js;
+ scripts.push(script);
+END;
+
+scripts.push(
+ version('/cobrands/fixmystreet/map.js'),
+ version('/cobrands/fixmystreet/offline.js'),
+);
+
+IF admin;
+ scripts.push(
+ version('/js/jquery-ui/js/jquery-ui-1.10.3.custom.min.js'),
+ version('/js/fixmystreet-admin.js'),
+ );
+END;
+
+FOR script IN extra_js;
+ scripts.push(script);
+END;
+
+TRY;
+ PROCESS 'footer_extra_js.html';
+CATCH file;
+END;
+
+~%]
diff --git a/templates/web/base/front/javascript.html b/templates/web/base/front/javascript.html
index 2795829a5..6b8e2a292 100644
--- a/templates/web/base/front/javascript.html
+++ b/templates/web/base/front/javascript.html
@@ -1,7 +1,12 @@
-[%# Assume using OpenStreetMap maps %]
-
-
+[%
+# Assume using OpenStreetMap maps
+map_js = [
+ version('/js/yepnope.js'),
+ [ version('/cobrands/fixmystreet/front.js'), {
+ id = 'script_front',
+ 'data-scripts' = version('/js/OpenLayers/OpenLayers.fixmystreet.js') _ ',' _
+ version('/js/map-OpenLayers.js') _ ',' _
+ version('/js/map-OpenStreetMap.js')
+ } ],
+]
+%]
diff --git a/templates/web/base/header.html b/templates/web/base/header.html
index c11e78b47..4e537a7ec 100644
--- a/templates/web/base/header.html
+++ b/templates/web/base/header.html
@@ -7,7 +7,10 @@
-
+
@@ -16,19 +19,11 @@
[% INCLUDE 'header_opengraph.html' %]
- [%
- # For clarity, the 'fixmystreet' moniker (for fixmystreet.com) puts
- # it stylesheets under fixmystreet.com
- IF c.cobrand.moniker == 'fixmystreet';
- SET css_dir = 'fixmystreet.com';
- ELSE;
- SET css_dir = c.cobrand.moniker;
- END %]
-
-
+
+
[% extra_css %]
[% INCLUDE 'common_header_tags.html' %]
diff --git a/templates/web/base/index.html b/templates/web/base/index.html
index 0441b3efb..8cb127e6a 100644
--- a/templates/web/base/index.html
+++ b/templates/web/base/index.html
@@ -1,4 +1,4 @@
-[% map_js = PROCESS 'front/javascript.html' %]
+[% PROCESS 'front/javascript.html' %]
[% pre_container_extra = PROCESS 'around/postcode_form.html' %]
[% INCLUDE 'header.html', title = '', bodyclass = 'frontpage fullwidthpage' %]
diff --git a/templates/web/base/maps/bing.html b/templates/web/base/maps/bing.html
index 6af4c3562..59d012c4f 100644
--- a/templates/web/base/maps/bing.html
+++ b/templates/web/base/maps/bing.html
@@ -1,8 +1,8 @@
-[% map_js = BLOCK %]
-
-
-
-
-[% END %]
-
-[% map_html = INCLUDE maps/openlayers.html %]
+[%
+map_js = [
+ version('/js/OpenLayers/OpenLayers.fixmystreet.js'),
+ version('/js/map-OpenLayers.js'),
+ version('/js/map-bing-ol.js'),
+];
+map_html = INCLUDE maps/openlayers.html
+%]
diff --git a/templates/web/base/maps/fms.html b/templates/web/base/maps/fms.html
index 03eb843da..e155ff778 100644
--- a/templates/web/base/maps/fms.html
+++ b/templates/web/base/maps/fms.html
@@ -1,9 +1,9 @@
-[% map_js = BLOCK %]
-
-
-
-
-
-[% END %]
-
-[% map_html = INCLUDE maps/openlayers.html include_key = 1 %]
+[%
+map_js = [
+ version('/js/OpenLayers/OpenLayers.fixmystreet.js'),
+ version('/js/map-OpenLayers.js'),
+ version('/js/map-bing-ol.js'),
+ version('/js/map-fms.js'),
+];
+map_html = INCLUDE maps/openlayers.html include_key = 1
+%]
diff --git a/templates/web/base/maps/google-ol.html b/templates/web/base/maps/google-ol.html
index cccea5b24..e326bd713 100644
--- a/templates/web/base/maps/google-ol.html
+++ b/templates/web/base/maps/google-ol.html
@@ -1,9 +1,11 @@
-[% map_js = BLOCK %]
-
-
-
-
-[% END %]
+[%
+map_js = [
+ "https://maps.googleapis.com/maps/api/js?v=3",
+ version('/js/OpenLayers/OpenLayers.google.js'),
+ version('/js/map-OpenLayers.js'),
+ version('/js/map-google-ol.js'),
+]
+%]
[% map_sub_links = BLOCK %]
[% loc('Satellite') %]
diff --git a/templates/web/base/maps/google.html b/templates/web/base/maps/google.html
index eeb4c9837..c86c757fb 100644
--- a/templates/web/base/maps/google.html
+++ b/templates/web/base/maps/google.html
@@ -1,4 +1,3 @@
-[% map_js = BLOCK %]
-
-
-[% END %]
+[%
+map_js = [
+ "http://maps.googleapis.com/maps/api/js?sensor=false",
+ version('/js/map-google.js'),
+]
+%]
[% map_html = BLOCK %]
-
-
-[% END %]
-
-[% map_html = BLOCK %]
-[% INCLUDE maps/openlayers.html %]
-[% END %]
+[%
+map_js = [
+ version('/js/OpenLayers/OpenLayers.fixmystreet.js'),
+ version('/js/map-OpenLayers.js'),
+ version('/js/map-OpenStreetMap.js'),
+];
+map_html = INCLUDE maps/openlayers.html
+%]
diff --git a/templates/web/base/maps/osm-streetview.html b/templates/web/base/maps/osm-streetview.html
index 2ff3b4723..dcf45d3b6 100644
--- a/templates/web/base/maps/osm-streetview.html
+++ b/templates/web/base/maps/osm-streetview.html
@@ -1,9 +1,8 @@
-[% map_js = BLOCK %]
-
-
-
-[% END %]
-
-[% map_html = BLOCK %]
-[% INCLUDE maps/openlayers.html %]
-[% END %]
+[%
+map_js = [
+ version('/js/OpenLayers/OpenLayers.fixmystreet.js'),
+ version('/js/map-OpenLayers.js'),
+ version('/js/map-streetview.js'),
+];
+map_html = INCLUDE maps/openlayers.html
+%]
diff --git a/templates/web/base/maps/osm-toner-lite.html b/templates/web/base/maps/osm-toner-lite.html
index 5e48f7569..6512eaf2c 100644
--- a/templates/web/base/maps/osm-toner-lite.html
+++ b/templates/web/base/maps/osm-toner-lite.html
@@ -1,10 +1,9 @@
-[% map_js = BLOCK %]
-
-
-
-
-[% END %]
-
-[% map_html = BLOCK %]
-[% INCLUDE maps/openlayers.html %]
-[% END %]
+[%
+map_js = [
+ version('/js/OpenLayers/OpenLayers.fixmystreet.js'),
+ "https://stamen-maps.a.ssl.fastly.net/js/tile.stamen.js?v1.3.0",
+ version('/js/map-OpenLayers.js'),
+ version('/js/map-toner-lite.js'),
+];
+map_html = INCLUDE maps/openlayers.html
+%]
diff --git a/templates/web/base/maps/osm.html b/templates/web/base/maps/osm.html
index ab4424cdd..e469901a8 100644
--- a/templates/web/base/maps/osm.html
+++ b/templates/web/base/maps/osm.html
@@ -1,9 +1,8 @@
-[% map_js = BLOCK %]
-
-
-
-[% END %]
-
-[% map_html = BLOCK %]
-[% INCLUDE maps/openlayers.html %]
-[% END %]
+[%
+map_js = [
+ version('/js/OpenLayers/OpenLayers.fixmystreet.js'),
+ version('/js/map-OpenLayers.js'),
+ version('/js/map-OpenStreetMap.js'),
+];
+map_html = INCLUDE maps/openlayers.html
+%]
diff --git a/templates/web/base/offline/appcache.html b/templates/web/base/offline/appcache.html
new file mode 100644
index 000000000..766c27c1a
--- /dev/null
+++ b/templates/web/base/offline/appcache.html
@@ -0,0 +1,8 @@
+[% INCLUDE 'header.html' appcache = 1 bodyclass = "fullwidthpage" %]
+
+Internet glitch
+
+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.
+
+[% INCLUDE 'footer.html' %]
diff --git a/templates/web/base/offline/manifest.html b/templates/web/base/offline/manifest.html
new file mode 100644
index 000000000..f5a9fddcc
--- /dev/null
+++ b/templates/web/base/offline/manifest.html
@@ -0,0 +1,17 @@
+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/base/report/photo-js.html b/templates/web/base/report/photo-js.html
index 05588d085..91b9930e7 100644
--- a/templates/web/base/report/photo-js.html
+++ b/templates/web/base/report/photo-js.html
@@ -1,6 +1,6 @@
[% extra_css = BLOCK %]
[% END %]
-[% extra_js = BLOCK %]
-
-[% END %]
+[% extra_js = [
+ version('/js/fancybox/jquery.fancybox-1.3.4.pack.js')
+] %]
diff --git a/templates/web/base/reports/index.html b/templates/web/base/reports/index.html
index 4a7d5a9c9..b07227144 100755
--- a/templates/web/base/reports/index.html
+++ b/templates/web/base/reports/index.html
@@ -1,6 +1,6 @@
-[% extra_js = BLOCK %]
-
-[% END -%]
+[% extra_js = [
+ version('/js/jquery.fixedthead.js')
+] -%]
[% INCLUDE 'header.html', title = loc('Summary reports'), bodyclass => 'fullwidthpage' %]
[% loc('All Reports') %]
diff --git a/templates/web/bristol/footer_extra_js.html b/templates/web/bristol/footer_extra_js.html
index 6ba5e3100..1cfcf00f6 100644
--- a/templates/web/bristol/footer_extra_js.html
+++ b/templates/web/bristol/footer_extra_js.html
@@ -1,4 +1,6 @@
-
-
-
-
+[% scripts.push(
+ version('/js/OpenLayers.Projection.OrdnanceSurvey.js')
+ version('/cobrands/fixmystreet-uk-councils/js.js'),
+ version('/cobrands/fixmystreet/assets.js'),
+ version('/cobrands/bristol/js.js'),
+) %]
diff --git a/templates/web/bristol/maps/bristol.html b/templates/web/bristol/maps/bristol.html
index f49571a1d..08f6fba1c 100644
--- a/templates/web/bristol/maps/bristol.html
+++ b/templates/web/bristol/maps/bristol.html
@@ -1,9 +1,11 @@
-[% map_js = BLOCK %]
-
-
-
-
-[% END %]
+[%
+map_js = [
+ version('/js/OpenLayers/OpenLayers.bristol.js'),
+ version('/js/map-OpenLayers.js'),
+ version('/js/map-wmts-base.js'),
+ version('/js/map-wmts-bristol.js'),
+]
+%]
[% map_html = BLOCK %]
[% INCLUDE maps/openlayers.html %]
diff --git a/templates/web/bromley/footer_extra_js.html b/templates/web/bromley/footer_extra_js.html
index 57066dbe8..ac03496a8 100644
--- a/templates/web/bromley/footer_extra_js.html
+++ b/templates/web/bromley/footer_extra_js.html
@@ -1 +1,3 @@
-
+[% scripts.push(
+ version('/cobrands/bromley/a-z-nav.js'),
+) %]
diff --git a/templates/web/bromley/maps/bromley.html b/templates/web/bromley/maps/bromley.html
index aa5789c1c..c2ee0273f 100644
--- a/templates/web/bromley/maps/bromley.html
+++ b/templates/web/bromley/maps/bromley.html
@@ -1,9 +1,10 @@
-[% map_js = BLOCK %]
-
-
-
-
-
-[% END %]
-
-[% map_html = INCLUDE maps/openlayers.html include_key = 1 %]
+[%
+map_js = [
+ version('/js/OpenLayers/OpenLayers.fixmystreet.js'),
+ version('/js/map-OpenLayers.js'),
+ version('/js/map-bing-ol.js'),
+ version('/js/map-fms.js'),
+ version('/cobrands/bromley/map.js'),
+];
+map_html = INCLUDE maps/openlayers.html include_key = 1
+%]
diff --git a/templates/web/fixmystreet-uk-councils/footer_extra_js.html b/templates/web/fixmystreet-uk-councils/footer_extra_js.html
index 493902ef0..1e7a38f8a 100644
--- a/templates/web/fixmystreet-uk-councils/footer_extra_js.html
+++ b/templates/web/fixmystreet-uk-councils/footer_extra_js.html
@@ -1,2 +1,4 @@
-
-
+[% scripts.push(
+ version('/js/OpenLayers.Projection.OrdnanceSurvey.js')
+ version('/cobrands/fixmystreet-uk-councils/js.js'),
+) %]
diff --git a/templates/web/fixmystreet.com/about/posters.html b/templates/web/fixmystreet.com/about/posters.html
index 1a9a4400c..c4cf16cd4 100644
--- a/templates/web/fixmystreet.com/about/posters.html
+++ b/templates/web/fixmystreet.com/about/posters.html
@@ -1,6 +1,6 @@
-[% extra_js = BLOCK %]
-
-[% END %]
+[% extra_js = [
+ version('/cobrands/fixmystreet.com/posters.js')
+] %]
[% extra_css = BLOCK %]
[% END %]
diff --git a/templates/web/fixmystreet.com/footer_extra_js.html b/templates/web/fixmystreet.com/footer_extra_js.html
index 0d1cca04d..d03aa8657 100644
--- a/templates/web/fixmystreet.com/footer_extra_js.html
+++ b/templates/web/fixmystreet.com/footer_extra_js.html
@@ -1,3 +1,5 @@
-
-
-
+[% scripts.push(
+ version('/js/OpenLayers.Projection.OrdnanceSurvey.js'),
+ version('/js/jquery.cookie.min.js'),
+ version('/cobrands/fixmystreet.com/js.js'),
+) %]
diff --git a/templates/web/fixmystreet.com/front/javascript.html b/templates/web/fixmystreet.com/front/javascript.html
index ac9faa309..baf7ebb64 100644
--- a/templates/web/fixmystreet.com/front/javascript.html
+++ b/templates/web/fixmystreet.com/front/javascript.html
@@ -1,7 +1,12 @@
-
-
+[%
+map_js = [
+ version('/js/yepnope.js'),
+ [ version('/cobrands/fixmystreet/front.js'), {
+ id = "script_front",
+ 'data-scripts' = version('/js/OpenLayers/OpenLayers.fixmystreet.js') _ ',' _
+ version('/js/map-OpenLayers.js') _ ',' _
+ version('/js/map-bing-ol.js') _ ',' _
+ version('/js/map-fms.js')
+ } ],
+]
+%]
diff --git a/templates/web/oxfordshire/header.html b/templates/web/oxfordshire/header.html
index 042222e1d..d8cb8d4bb 100644
--- a/templates/web/oxfordshire/header.html
+++ b/templates/web/oxfordshire/header.html
@@ -2,7 +2,10 @@
-
+
diff --git a/templates/web/zurich/maps/zurich.html b/templates/web/zurich/maps/zurich.html
index 2f21c91a6..f85be4aef 100644
--- a/templates/web/zurich/maps/zurich.html
+++ b/templates/web/zurich/maps/zurich.html
@@ -1,10 +1,12 @@
-[% map_js = BLOCK %]
-
-
-
-
-
-[% END %]
+[%
+map_js = [
+ version('/js/OpenLayers.2.11.zurich.js'),
+ version('/js/OpenLayers.Projection.CH1903Plus.js'),
+ version('/js/map-OpenLayers.js'),
+ version('/js/map-wmts-base.js'),
+ version('/js/map-wmts-zurich.js'),
+]
+%]
[% map_sub_links = BLOCK %]
Stadtplan
diff --git a/web/cobrands/fixmystreet/offline.js b/web/cobrands/fixmystreet/offline.js
new file mode 100644
index 000000000..4b3373029
--- /dev/null
+++ b/web/cobrands/fixmystreet/offline.js
@@ -0,0 +1,5 @@
+if (!$('#offline_list').length) {
+ if (window.applicationCache && window.localStorage) {
+ $(document.body).prepend('');
+ }
+}
--
cgit v1.2.3
From 34f942d7881451e164431a3231774568421a00f5 Mon Sep 17 00:00:00 2001
From: Matthew Somerville
Date: Tue, 29 Nov 2016 17:44:04 +0000
Subject: Store/show shortlisted reports offline.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This:
* On an online visit to /my/planned, caches all shortlisted reports,
their images and static maps in localStorage, with progress banner;
* When a report is added/removed from the shortlist, caches/de-caches
that report;
* When viewing a report page offline, shows that page from the cache
if present (replacing the dynamic map with the cached static map, and
replacing report images with their cached equivalents – it is a shame
to duplicate, but we cannot rely on the browser cache having these images);
* When viewing another page offline, shows an error message but also the
list of shortlisted reports that are cached (again, replacing their
thumbnail images with the cached versions).
---
templates/web/base/offline/appcache.html | 2 +
templates/web/base/report/_item.html | 3 +-
templates/web/base/report/_main.html | 2 +-
web/cobrands/fixmystreet.com/base.scss | 35 +---
web/cobrands/fixmystreet/fixmystreet.js | 3 +
web/cobrands/fixmystreet/offline.js | 276 ++++++++++++++++++++++++++++++-
web/cobrands/oxfordshire/base.scss | 1 +
web/cobrands/sass/_top-banner.scss | 49 ++++++
8 files changed, 334 insertions(+), 37 deletions(-)
create mode 100644 web/cobrands/sass/_top-banner.scss
diff --git a/templates/web/base/offline/appcache.html b/templates/web/base/offline/appcache.html
index 766c27c1a..6f701321a 100644
--- a/templates/web/base/offline/appcache.html
+++ b/templates/web/base/offline/appcache.html
@@ -5,4 +5,6 @@
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.
+
+
[% INCLUDE 'footer.html' %]
diff --git a/templates/web/base/report/_item.html b/templates/web/base/report/_item.html
index 0f42b00ce..c3e88aed2 100644
--- a/templates/web/base/report/_item.html
+++ b/templates/web/base/report/_item.html
@@ -1,4 +1,5 @@
-