app/cms/scrivito/binary_routing.rb in scrivito_sdk-1.10.0 vs app/cms/scrivito/binary_routing.rb in scrivito_sdk-1.11.0.rc1
- old
+ new
@@ -1,22 +1,22 @@
module Scrivito
class BinaryRouting < Struct.new(:request, :scrivito_engine)
- def binary_url(binary)
- binary_url_from_cache(binary) || binary_redirect_url(binary)
+ def binary_url(binary, redirect_url_or_path)
+ binary_url_from_cache(binary) || binary_redirect_url(binary, redirect_url_or_path)
end
- def binary_obj_url(obj, binary, image_options = {})
+ def transformed_binary_url(binary, redirect_url_or_path, image_options = {})
binary = if image_options.key?(:transform)
apply_custom_transformation(binary, image_options[:transform])
else
apply_default_transformation(binary)
end
- binary_url(binary)
+ binary_url(binary, redirect_url_or_path)
end
- def resolved_binary_obj_url(obj, binary)
+ def resolved_binary_url(binary)
BinaryRewrite.call(request, apply_default_transformation(binary).url)
end
private
@@ -24,12 +24,12 @@
if url_from_cache = binary.url_from_cache
BinaryRewrite.call(request, url_from_cache)
end
end
- def binary_redirect_url(binary)
+ def binary_redirect_url(binary, url_or_path)
encrypted_params = BinaryParamVerifier.generate(binary)
- scrivito_engine.binary_path(encrypted_params: encrypted_params)
+ scrivito_engine.public_send("binary_#{url_or_path}", encrypted_params: encrypted_params)
end
def apply_custom_transformation(binary, transformation_definition)
if transformation_definition
binary.transform(transformation_definition)