From dd9dc7bd7db90e4094b5391fba65c573d292ba60 Mon Sep 17 00:00:00 2001 From: Luc Didry Date: Mon, 7 May 2018 22:16:40 +0200 Subject: [PATCH] Fix #80 Gzip static assets with Mojolicious::Plugin::GzipStatic --- cpanfile | 1 + cpanfile.snapshot | 8 ++++++++ lib/Lutim.pm | 3 +++ lib/Mounter.pm | 3 +++ t/test.t | 5 +++++ themes/default/lib/Lutim/I18N/lutim.pot | 6 +++--- 6 files changed, 23 insertions(+), 3 deletions(-) diff --git a/cpanfile b/cpanfile index a8464a0..c2184d9 100644 --- a/cpanfile +++ b/cpanfile @@ -7,6 +7,7 @@ requires 'Net::Domain::TLD', '>= 1.75'; # Must have the last version to handle ( requires 'Mojolicious::Plugin::I18N'; requires 'Mojolicious::Plugin::DebugDumperHelper'; requires 'Mojolicious::Plugin::StaticCache'; +requires 'Mojolicious::Plugin::GzipStatic'; requires 'Text::Unidecode'; requires 'DateTime'; requires 'Filesys::DiskUsage'; diff --git a/cpanfile.snapshot b/cpanfile.snapshot index 7019eae..d0fa9e2 100644 --- a/cpanfile.snapshot +++ b/cpanfile.snapshot @@ -1933,6 +1933,14 @@ DISTRIBUTIONS requirements: ExtUtils::MakeMaker 0 Mojolicious 6.11 + Mojolicious-Plugin-GzipStatic-0.04 + pathname: L/LD/LDIDRY/Mojolicious-Plugin-GzipStatic-0.04.tar.gz + provides: + Mojolicious::Plugin::GzipStatic 0.04 + requirements: + ExtUtils::MakeMaker 0 + IO::Compress::Gzip 0 + Mojolicious 7.75 Mojolicious-Plugin-I18N-1.6 pathname: S/SH/SHARIFULN/Mojolicious-Plugin-I18N-1.6.tar.gz provides: diff --git a/lib/Lutim.pm b/lib/Lutim.pm index 2652d2d..5d8b729 100644 --- a/lib/Lutim.pm +++ b/lib/Lutim.pm @@ -102,6 +102,9 @@ sub startup { eval qq(use lib "$lib"); $self->plugin('I18N'); + # Static assets gzipping + $self->plugin('GzipStatic'); + # Cache static files $self->plugin('StaticCache'); diff --git a/lib/Mounter.pm b/lib/Mounter.pm index b810564..6cbee76 100644 --- a/lib/Mounter.pm +++ b/lib/Mounter.pm @@ -66,6 +66,9 @@ sub startup { } push @{$self->static->paths}, $self->home->rel_file('themes/default/public'); + # Static assets gzipping + $self->plugin('GzipStatic'); + # Cache static files $self->plugin('StaticCache'); diff --git a/t/test.t b/t/test.t index 31fa1bb..e617168 100644 --- a/t/test.t +++ b/t/test.t @@ -65,6 +65,11 @@ $t->get_ok('/') ->status_is(200) ->content_like(qr/Let's Upload That IMage/i); +# Gzip static assets +$t->get_ok('/css/lutim.css') + ->status_is(200) + ->header_is(Vary => 'Accept-Encoding'); + # Instance settings informations $t->get_ok('/infos') ->status_is(200) diff --git a/themes/default/lib/Lutim/I18N/lutim.pot b/themes/default/lib/Lutim/I18N/lutim.pot index 0d152f3..0102779 100644 --- a/themes/default/lib/Lutim/I18N/lutim.pot +++ b/themes/default/lib/Lutim/I18N/lutim.pot @@ -32,11 +32,11 @@ msgstr "" msgid "-or-" msgstr "" -#: lib/Lutim.pm:214 lib/Lutim/Command/cron/stats.pm:151 lib/Lutim/Command/cron/stats.pm:162 lib/Lutim/Command/cron/stats.pm:179 themes/default/templates/index.html.ep:5 themes/default/templates/raw.html.ep:10 themes/default/templates/raw.html.ep:21 themes/default/templates/raw.html.ep:38 +#: lib/Lutim.pm:217 lib/Lutim/Command/cron/stats.pm:151 lib/Lutim/Command/cron/stats.pm:162 lib/Lutim/Command/cron/stats.pm:179 themes/default/templates/index.html.ep:5 themes/default/templates/raw.html.ep:10 themes/default/templates/raw.html.ep:21 themes/default/templates/raw.html.ep:38 msgid "1 year" msgstr "" -#: lib/Lutim.pm:213 lib/Lutim/Command/cron/stats.pm:148 lib/Lutim/Command/cron/stats.pm:159 lib/Lutim/Command/cron/stats.pm:176 themes/default/templates/index.html.ep:4 themes/default/templates/partial/for_my_delay.html.ep:13 themes/default/templates/partial/lutim.js.ep:151 themes/default/templates/raw.html.ep:18 themes/default/templates/raw.html.ep:35 themes/default/templates/raw.html.ep:7 +#: lib/Lutim.pm:216 lib/Lutim/Command/cron/stats.pm:148 lib/Lutim/Command/cron/stats.pm:159 lib/Lutim/Command/cron/stats.pm:176 themes/default/templates/index.html.ep:4 themes/default/templates/partial/for_my_delay.html.ep:13 themes/default/templates/partial/lutim.js.ep:151 themes/default/templates/raw.html.ep:18 themes/default/templates/raw.html.ep:35 themes/default/templates/raw.html.ep:7 msgid "24 hours" msgstr "" @@ -495,7 +495,7 @@ msgstr "" msgid "core developer" msgstr "" -#: lib/Lutim.pm:212 lib/Lutim/Command/cron/stats.pm:147 lib/Lutim/Command/cron/stats.pm:158 lib/Lutim/Command/cron/stats.pm:175 themes/default/templates/index.html.ep:3 themes/default/templates/raw.html.ep:17 themes/default/templates/raw.html.ep:34 themes/default/templates/raw.html.ep:6 +#: lib/Lutim.pm:215 lib/Lutim/Command/cron/stats.pm:147 lib/Lutim/Command/cron/stats.pm:158 lib/Lutim/Command/cron/stats.pm:175 themes/default/templates/index.html.ep:3 themes/default/templates/raw.html.ep:17 themes/default/templates/raw.html.ep:34 themes/default/templates/raw.html.ep:6 msgid "no time limit" msgstr ""