diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2018-03-04 11:20:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-04 11:20:54 +0100 |
commit | e137831726c20b50fd0b1b280f17d3fdf338c690 (patch) | |
tree | 8db635773878ae88556162cc34ecc244c83cb7b8 /activestorage/app | |
parent | 6932998fc7aecba6ade04f8d799f07b494dd402c (diff) | |
parent | 0f302b897022b68793e102efa90a2819ff4e107a (diff) | |
download | rails-e137831726c20b50fd0b1b280f17d3fdf338c690.tar.gz rails-e137831726c20b50fd0b1b280f17d3fdf338c690.tar.bz2 rails-e137831726c20b50fd0b1b280f17d3fdf338c690.zip |
Merge pull request #32162 from kaspth/ast-unify-preview-variant-routes-and-controllers
Merge Previews/Variants controller into one Representations controller.
Diffstat (limited to 'activestorage/app')
-rw-r--r-- | activestorage/app/controllers/active_storage/previews_controller.rb | 10 | ||||
-rw-r--r-- | activestorage/app/controllers/active_storage/representations_controller.rb (renamed from activestorage/app/controllers/active_storage/variants_controller.rb) | 6 | ||||
-rw-r--r-- | activestorage/app/models/active_storage/blob/representable.rb | 4 |
3 files changed, 5 insertions, 15 deletions
diff --git a/activestorage/app/controllers/active_storage/previews_controller.rb b/activestorage/app/controllers/active_storage/previews_controller.rb deleted file mode 100644 index aa7ef58ca4..0000000000 --- a/activestorage/app/controllers/active_storage/previews_controller.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -class ActiveStorage::PreviewsController < ActionController::Base - include ActiveStorage::SetBlob - - def show - expires_in ActiveStorage::Blob.service.url_expires_in - redirect_to ActiveStorage::Preview.new(@blob, params[:variation_key]).processed.service_url(disposition: params[:disposition]) - end -end diff --git a/activestorage/app/controllers/active_storage/variants_controller.rb b/activestorage/app/controllers/active_storage/representations_controller.rb index e8f8dd592d..e0e944dc9c 100644 --- a/activestorage/app/controllers/active_storage/variants_controller.rb +++ b/activestorage/app/controllers/active_storage/representations_controller.rb @@ -1,14 +1,14 @@ # frozen_string_literal: true -# Take a signed permanent reference for a variant and turn it into an expiring service URL for download. +# Take a signed permanent reference for a blob representation and turn it into an expiring service URL for download. # Note: These URLs are publicly accessible. If you need to enforce access protection beyond the # security-through-obscurity factor of the signed blob and variation reference, you'll need to implement your own # authenticated redirection controller. -class ActiveStorage::VariantsController < ActionController::Base +class ActiveStorage::RepresentationsController < ActionController::Base include ActiveStorage::SetBlob def show expires_in ActiveStorage::Blob.service.url_expires_in - redirect_to ActiveStorage::Variant.new(@blob, params[:variation_key]).processed.service_url(disposition: params[:disposition]) + redirect_to @blob.representation(params[:variation_key]).processed.service_url(disposition: params[:disposition]) end end diff --git a/activestorage/app/models/active_storage/blob/representable.rb b/activestorage/app/models/active_storage/blob/representable.rb index 0ad2e2fd77..88fc25b7ae 100644 --- a/activestorage/app/models/active_storage/blob/representable.rb +++ b/activestorage/app/models/active_storage/blob/representable.rb @@ -27,7 +27,7 @@ module ActiveStorage::Blob::Representable # variable, call ActiveStorage::Blob#variable?. def variant(transformations) if variable? - ActiveStorage::Variant.new(self, ActiveStorage::Variation.wrap(transformations)) + ActiveStorage::Variant.new(self, transformations) else raise ActiveStorage::InvariableError end @@ -55,7 +55,7 @@ module ActiveStorage::Blob::Representable # whether a blob is accepted by any previewer, call ActiveStorage::Blob#previewable?. def preview(transformations) if previewable? - ActiveStorage::Preview.new(self, ActiveStorage::Variation.wrap(transformations)) + ActiveStorage::Preview.new(self, transformations) else raise ActiveStorage::UnpreviewableError end |