Steam was not using Dragonfly in its middleware stack (+ fix a bug about Dragonfly not able to retrieve a local file)
did
committed Oct 21, 2015
commit 25e68524b9ca6e20ce1d48a9e512d6c003a6dde5
Showing 5
changed files with
10 additions
and 8 deletions
locomotive/steam/initializers/dragonfly.rb b/lib/locomotive/steam/initializers/dragonfly.rb
+1
-1
| @@ | @@ -19,7 +19,7 @@ module Locomotive |
| secret Locomotive::Steam.configuration.image_resizer_secret | |
| - | url_format '/images/dynamic/:job/:basename.:ext' |
| + | url_format '/images/steam/dynamic/:job/:sha/:basename.:ext' |
| fetch_file_whitelist /public/ | |
locomotive/steam/server.rb b/lib/locomotive/steam/server.rb
+2
-0
| @@ | @@ -40,6 +40,8 @@ module Locomotive::Steam |
| } | |
| end | |
| + | use Dragonfly::Middleware, :steam |
| + | |
| use Rack::Lint | |
| use Rack::Session::Moneta, configuration.moneta | |
locomotive/steam/services/image_resizer_service.rb b/lib/locomotive/steam/services/image_resizer_service.rb
+1
-1
| @@ | @@ -29,7 +29,7 @@ module Locomotive |
| resizer.fetch_url(url_or_path) | |
| else | |
| path = url_or_path.sub(/(\?.*)$/, '') | |
| - | resizer.fetch_file(File.join(asset_path || '', 'public', path)) |
| + | resizer.fetch_file(File.join(asset_path || '', path)) |
| end | |
| end | |
spec/unit/liquid/filters/resize_spec.rb
+1
-1
| @@ | @@ -27,7 +27,7 @@ describe Locomotive::Steam::Liquid::Filters::Resize do |
| let(:geometry) { '30x40#' } | |
| - | it { is_expected.to match /images\/dynamic\/.*\/240px-Metropolitan_railway_steam_locomotive_2781022036.png/ } |
| + | it { is_expected.to match /images\/steam\/dynamic\/.*\/240px-Metropolitan_railway_steam_locomotive_2781022036.png/ } |
| end | |
spec/unit/services/image_resizer_service_spec.rb
+5
-5
| @@ | @@ -31,33 +31,33 @@ describe Locomotive::Steam::ImageResizerService do |
| it { is_expected.to eq nil } | |
| end | |
| - | it { is_expected.to match /images\/dynamic\/.*\/240px-Metropolitan_railway_steam_locomotive_2781022036.png/ } |
| + | it { is_expected.to match /images\/steam\/dynamic\/.*\/240px-Metropolitan_railway_steam_locomotive_2781022036.png/ } |
| describe 'a local asset' do | |
| let(:input) { '/sites/42/theme/images/banner.png' } | |
| - | it { is_expected.to match /images\/dynamic\/.*\/banner.png/ } |
| + | it { is_expected.to match /images\/steam\/dynamic\/.*\/banner.png/ } |
| end | |
| describe 'a hash' do | |
| let(:input) { { 'url' => '/sites/42/theme/images/banner.png' } } | |
| - | it { is_expected.to match /images\/dynamic\/.*\/banner.png/ } |
| + | it { is_expected.to match /images\/steam\/dynamic\/.*\/banner.png/ } |
| end | |
| describe 'an object responding to the url method (Carrierwave uploaded file)' do | |
| let(:input) { instance_double('UploadedFile', url: '/sites/42/theme/acme.png') } | |
| - | it { is_expected.to match /images\/dynamic\/.*\/acme.png/ } |
| + | it { is_expected.to match /images\/steam\/dynamic\/.*\/acme.png/ } |
| end | |
| describe 'an url with a timestamp' do | |
| let(:input) { '/sites/42/theme/images/banner.png?24e29997bcb00e97d8252cdd29d14e2d' } | |
| - | it { is_expected.to match /images\/dynamic\/.*\/banner.png\?sha=[a-z0-9]+/ } |
| + | it { is_expected.to match /images\/steam\/dynamic\/.*\/[a-z0-9]+\/banner.png/ } |
| end | |