aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App/Controller/Offline.pm45
-rw-r--r--perllib/FixMyStreet/App/Controller/Root.pm4
-rw-r--r--templates/web/base/common_header_tags.html3
3 files changed, 34 insertions, 18 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Offline.pm b/perllib/FixMyStreet/App/Controller/Offline.pm
index 57cbe201c..d5af7e047 100644
--- a/perllib/FixMyStreet/App/Controller/Offline.pm
+++ b/perllib/FixMyStreet/App/Controller/Offline.pm
@@ -43,8 +43,32 @@ sub manifest: Path("/.well-known/manifest.webmanifest") {
});
}
+ $c->forward("_stash_manifest_icons", [ $c->cobrand->moniker ]);
+
+ my $data = {
+ name => $theme->name,
+ short_name => $theme->short_name,
+ background_color => $theme->background_colour,
+ theme_color => $theme->theme_colour,
+ icons => $c->stash->{manifest_icons},
+ lang => $c->stash->{lang_code},
+ display => "minimal-ui",
+ start_url => "/?pwa",
+ scope => "/",
+ };
+ if ($c->cobrand->can('manifest')) {
+ $data = { %$data, %{$c->cobrand->manifest} };
+ }
+
+ my $json = encode_json($data);
+ $c->res->body($json);
+}
+
+sub _stash_manifest_icons : Private {
+ my ($self, $c, $cobrand, $skip_defaults) = @_;
+
my @icons;
- my $uri = '/theme/' . $c->cobrand->moniker;
+ my $uri = '/theme/' . $cobrand;
my $theme_path = path(FixMyStreet->path_to('web' . $uri));
$theme_path->visit(
sub {
@@ -57,29 +81,14 @@ sub manifest: Path("/.well-known/manifest.webmanifest") {
}
);
- unless (@icons) {
+ unless (@icons || $skip_defaults) {
push @icons,
{ src => "/cobrands/fixmystreet/images/192.png", sizes => "192x192", type => "image/png" },
{ src => "/cobrands/fixmystreet/images/512.png", sizes => "512x512", type => "image/png" };
}
- my $data = {
- name => $theme->name,
- short_name => $theme->short_name,
- background_color => $theme->background_colour,
- theme_color => $theme->theme_colour,
- icons => \@icons,
- lang => $c->stash->{lang_code},
- display => "minimal-ui",
- start_url => "/?pwa",
- scope => "/",
- };
- if ($c->cobrand->can('manifest')) {
- $data = { %$data, %{$c->cobrand->manifest} };
- }
+ $c->stash->{manifest_icons} = \@icons;
- my $json = encode_json($data);
- $c->res->body($json);
}
__PACKAGE__->meta->make_immutable;
diff --git a/perllib/FixMyStreet/App/Controller/Root.pm b/perllib/FixMyStreet/App/Controller/Root.pm
index caaa260ff..8128d8c9d 100644
--- a/perllib/FixMyStreet/App/Controller/Root.pm
+++ b/perllib/FixMyStreet/App/Controller/Root.pm
@@ -77,6 +77,10 @@ sub index : Path : Args(0) {
$c->detach;
}
+ # TODO: Not sure we want to hammer the FS for every front page request,
+ # might need a smarter way to tell iOS about the icons
+ $c->forward('/offline/_stash_manifest_icons', [ $c->cobrand->moniker ]);
+
$c->forward('/auth/get_csrf_token');
}
diff --git a/templates/web/base/common_header_tags.html b/templates/web/base/common_header_tags.html
index 279f561df..cf485c7b9 100644
--- a/templates/web/base/common_header_tags.html
+++ b/templates/web/base/common_header_tags.html
@@ -2,6 +2,9 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<link rel="manifest" href="/.well-known/manifest.webmanifest">
+[% FOREACH icon IN manifest_icons %]
+ <link rel="apple-touch-icon" sizes="[% icon.sizes %]" href="[% icon.src %]">
+[% END %]
[% IF csrf_token %]
<meta content="[% csrf_token %]" name="csrf-token" />