diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/View/Web.pm | 18 |
2 files changed, 15 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore index ab62f9591..bae1f1576 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ FixMyBarangay.po /web/cobrands/*/*.css /web/cobrands/*/*.css.map /web/cobrands/seesomething +*.auto.min.js # Photo upload cache /web/photo diff --git a/perllib/FixMyStreet/App/View/Web.pm b/perllib/FixMyStreet/App/View/Web.pm index 2a9c69044..2a3948381 100644 --- a/perllib/FixMyStreet/App/View/Web.pm +++ b/perllib/FixMyStreet/App/View/Web.pm @@ -186,15 +186,25 @@ sub html_paragraph { my %version_hash; sub version { my ( $self, $c, $file ) = @_; - unless ($version_hash{$file} && !FixMyStreet->config('STAGING_SITE')) { - my $path = FixMyStreet->path_to('web', $file); - $version_hash{$file} = ( stat( $path ) )[9]; + _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 + (my $file_min = $file) =~ s/\.js$/.auto.min.js/; + _version_get_mtime($file_min); + $file = $file_min if $version_hash{$file_min} >= $version_hash{$file}; } - $version_hash{$file} ||= ''; my $admin = $self->template->context->stash->{admin} ? FixMyStreet->config('ADMIN_BASE_URL') : ''; return "$admin$file?$version_hash{$file}"; } +sub _version_get_mtime { + my $file = shift; + unless ($version_hash{$file} && !FixMyStreet->config('STAGING_SITE')) { + my $path = FixMyStreet->path_to('web', $file); + $version_hash{$file} = ( stat( $path ) )[9] || 0; + } +} + sub decode { my ( $self, $c, $text ) = @_; utf8::decode($text) unless utf8::is_utf8($text); |