cloudinary 1.0.82 → 1.0.83
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +58 -7
- data/CHANGELOG +13 -0
- data/Gemfile +1 -1
- data/cloudinary.gemspec +13 -3
- data/lib/cloudinary/active_support/core_ext/hash/keys.rb +166 -0
- data/lib/cloudinary/active_support/core_ext/hash/readme.md +1 -0
- data/lib/cloudinary/api.rb +2 -1
- data/lib/cloudinary/carrier_wave/preloaded.rb +1 -1
- data/lib/cloudinary/helper.rb +38 -21
- data/lib/cloudinary/missing.rb +11 -10
- data/lib/cloudinary/uploader.rb +18 -20
- data/lib/cloudinary/utils.rb +187 -75
- data/lib/cloudinary/version.rb +1 -1
- data/lib/cloudinary/video_helper.rb +126 -0
- data/spec/api_spec.rb +23 -22
- data/spec/cloudinary_helper_spec.rb +34 -20
- data/spec/spec_helper.rb +75 -5
- data/spec/uploader_spec.rb +32 -3
- data/spec/utils_methods_spec.rb +18 -0
- data/spec/utils_spec.rb +73 -78
- data/spec/video_tag_spec.rb +186 -0
- data/spec/video_url_spec.rb +169 -0
- data/vendor/assets/html/cloudinary_cors.html +47 -0
- data/vendor/assets/javascripts/cloudinary/canvas-to-blob.min.js +1 -0
- data/vendor/assets/javascripts/cloudinary/index.js +4 -0
- data/vendor/assets/javascripts/cloudinary/jquery.cloudinary.js +898 -0
- data/vendor/assets/javascripts/cloudinary/jquery.fileupload-image.js +315 -0
- data/vendor/assets/javascripts/cloudinary/jquery.fileupload-process.js +172 -0
- data/vendor/assets/javascripts/cloudinary/jquery.fileupload-validate.js +119 -0
- data/vendor/assets/javascripts/cloudinary/jquery.fileupload.js +1460 -0
- data/vendor/assets/javascripts/cloudinary/jquery.iframe-transport.js +214 -0
- data/vendor/assets/javascripts/cloudinary/jquery.ui.widget.js +558 -0
- data/vendor/assets/javascripts/cloudinary/load-image.min.js +1 -0
- data/vendor/assets/javascripts/cloudinary/processing.js +5 -0
- metadata +44 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1503a8d15da201782bf75d145eb7a0f5461f6d4d
|
|
4
|
+
data.tar.gz: 3fae9211b099c7f6da88f4e6b0523b3addc6790f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a90e9c764e5e4b7144f83a3b0efe29056e8b6e55d4609eff20861c0d528b4d38b8262ba20dd36c5ea57ec15896f5ac2ed8620eaae517db921805b6dfced9aa1c
|
|
7
|
+
data.tar.gz: 1c2c516dff172308801556d908dedb2d181a7e5084f3581f0d4012372d97569d5f7d2a3558ad0eed281f48f40917dd5742a64118f842c1d519c1cd35815e1962
|
data/.gitignore
CHANGED
|
@@ -1,8 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
*.gem
|
|
2
|
+
*.rbc
|
|
3
|
+
/.config
|
|
4
|
+
capybara-*.html
|
|
5
|
+
.rspec
|
|
6
|
+
log/
|
|
7
|
+
db/*.sqlite3
|
|
8
|
+
db/*.sqlite3-journal
|
|
9
|
+
/public/system
|
|
10
|
+
/coverage/
|
|
11
|
+
/InstalledFiles
|
|
12
|
+
/pkg/
|
|
13
|
+
/spec/reports/
|
|
14
|
+
/test/tmp/
|
|
15
|
+
/spec/tmp
|
|
16
|
+
/test/version_tmp/
|
|
17
|
+
tmp/
|
|
18
|
+
**.orig
|
|
19
|
+
rerun.txt
|
|
20
|
+
pickle-email-*.html
|
|
21
|
+
|
|
22
|
+
## Specific to RubyMotion:
|
|
23
|
+
config/initializers/secret_token.rb
|
|
24
|
+
config/secrets.yml
|
|
25
|
+
|
|
26
|
+
.dat*
|
|
27
|
+
.repl_history
|
|
28
|
+
build/
|
|
29
|
+
|
|
30
|
+
## Documentation cache and generated files:
|
|
31
|
+
/.yardoc/
|
|
32
|
+
/_yardoc/
|
|
33
|
+
/doc/
|
|
34
|
+
/rdoc/
|
|
35
|
+
|
|
36
|
+
## Environment normalisation:
|
|
37
|
+
/.bundle/
|
|
38
|
+
/vendor/bundle
|
|
39
|
+
/lib/bundler/man/
|
|
40
|
+
|
|
41
|
+
# for a library or gem, you might want to ignore these files since the code is
|
|
42
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
6
43
|
Gemfile.lock
|
|
7
|
-
.
|
|
8
|
-
|
|
44
|
+
.ruby-version*
|
|
45
|
+
.ruby-gemset*
|
|
46
|
+
.rvmrc*
|
|
47
|
+
|
|
48
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
|
49
|
+
.rvmrc
|
|
50
|
+
|
|
51
|
+
# if using bower-rails ignore default bower_components path bower.json files
|
|
52
|
+
vendor/assets/bower_components
|
|
53
|
+
*.bowerrc
|
|
54
|
+
bower.json
|
|
55
|
+
|
|
56
|
+
# Ignore pow environment settings
|
|
57
|
+
.powenv
|
|
58
|
+
|
|
59
|
+
cloudinary.yml
|
data/CHANGELOG
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
= Version 1.0.83 - 2015-03-22
|
|
2
|
+
* Added Video Support
|
|
3
|
+
* `cl_video_tag` creates an HTML video tag with optionally inner `source` tags
|
|
4
|
+
* `cl_video_path` provides a url to the video resource
|
|
5
|
+
* `cl_video_thumbnail_tag` creates an `img` tag with a video thumbnail and
|
|
6
|
+
* `cl_video_thumbnail_path` provides a url to the video resource's thumbnail
|
|
7
|
+
* Added `:zoom` transformation parameter
|
|
8
|
+
* Applied Pull Requests:
|
|
9
|
+
* Fix image closing tags #144
|
|
10
|
+
* Fix callback path. #138
|
|
11
|
+
* Update Cloudinary's jQuery plugin to v1.0.22.
|
|
12
|
+
* Update .gitignore file
|
|
13
|
+
|
|
1
14
|
= Version 1.0.82 - 2015-02-05
|
|
2
15
|
* Solve problem with CarrierWave integration to newer versions on the mongoid and carrierwave-mongoid gems.
|
|
3
16
|
* Enable root path for shared CDN:
|
data/Gemfile
CHANGED
data/cloudinary.gemspec
CHANGED
|
@@ -20,8 +20,18 @@ Gem::Specification.new do |s|
|
|
|
20
20
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
21
21
|
s.require_paths = ["lib"]
|
|
22
22
|
|
|
23
|
-
s.add_dependency "rest-client"
|
|
24
23
|
s.add_dependency "aws_cf_signer"
|
|
25
|
-
s.add_development_dependency "rspec"
|
|
26
|
-
s.add_development_dependency "
|
|
24
|
+
s.add_development_dependency "rspec", '>=2.11'
|
|
25
|
+
s.add_development_dependency "rspec-rails"
|
|
26
|
+
|
|
27
|
+
if RUBY_VERSION > "1.9"
|
|
28
|
+
s.add_dependency "rest-client"
|
|
29
|
+
s.add_development_dependency "actionpack"
|
|
30
|
+
s.add_development_dependency "simplecov"
|
|
31
|
+
else
|
|
32
|
+
s.add_dependency "i18n", "<0.7.0"
|
|
33
|
+
s.add_dependency "rest-client", "<=1.6.8"
|
|
34
|
+
s.add_development_dependency "actionpack", "~>3.2.0"
|
|
35
|
+
end
|
|
36
|
+
|
|
27
37
|
end
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
class Hash
|
|
2
|
+
# Returns a new hash with all keys converted using the block operation.
|
|
3
|
+
#
|
|
4
|
+
# hash = { name: 'Rob', age: '28' }
|
|
5
|
+
#
|
|
6
|
+
# hash.transform_keys{ |key| key.to_s.upcase }
|
|
7
|
+
# # => {"NAME"=>"Rob", "AGE"=>"28"}
|
|
8
|
+
def transform_keys
|
|
9
|
+
return enum_for(:transform_keys) unless block_given?
|
|
10
|
+
result = self.class.new
|
|
11
|
+
each_key do |key|
|
|
12
|
+
result[yield(key)] = self[key]
|
|
13
|
+
end
|
|
14
|
+
result
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Destructively convert all keys using the block operations.
|
|
18
|
+
# Same as transform_keys but modifies +self+.
|
|
19
|
+
def transform_keys!
|
|
20
|
+
return enum_for(:transform_keys!) unless block_given?
|
|
21
|
+
keys.each do |key|
|
|
22
|
+
self[yield(key)] = delete(key)
|
|
23
|
+
end
|
|
24
|
+
self
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Returns a new hash with all keys converted to strings.
|
|
28
|
+
#
|
|
29
|
+
# hash = { name: 'Rob', age: '28' }
|
|
30
|
+
#
|
|
31
|
+
# hash.stringify_keys
|
|
32
|
+
# # => {"name"=>"Rob", "age"=>"28"}
|
|
33
|
+
def stringify_keys
|
|
34
|
+
transform_keys{ |key| key.to_s }
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Destructively convert all keys to strings. Same as
|
|
38
|
+
# +stringify_keys+, but modifies +self+.
|
|
39
|
+
def stringify_keys!
|
|
40
|
+
transform_keys!{ |key| key.to_s }
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Returns a new hash with all keys converted to symbols, as long as
|
|
44
|
+
# they respond to +to_sym+.
|
|
45
|
+
#
|
|
46
|
+
# hash = { 'name' => 'Rob', 'age' => '28' }
|
|
47
|
+
#
|
|
48
|
+
# hash.symbolize_keys
|
|
49
|
+
# # => {:name=>"Rob", :age=>"28"}
|
|
50
|
+
def symbolize_keys
|
|
51
|
+
transform_keys{ |key| key.to_sym rescue key }
|
|
52
|
+
end
|
|
53
|
+
alias_method :to_options, :symbolize_keys
|
|
54
|
+
|
|
55
|
+
# Destructively convert all keys to symbols, as long as they respond
|
|
56
|
+
# to +to_sym+. Same as +symbolize_keys+, but modifies +self+.
|
|
57
|
+
def symbolize_keys!
|
|
58
|
+
transform_keys!{ |key| key.to_sym rescue key }
|
|
59
|
+
end
|
|
60
|
+
alias_method :to_options!, :symbolize_keys!
|
|
61
|
+
|
|
62
|
+
# Validate all keys in a hash match <tt>*valid_keys</tt>, raising
|
|
63
|
+
# ArgumentError on a mismatch.
|
|
64
|
+
#
|
|
65
|
+
# Note that keys are treated differently than HashWithIndifferentAccess,
|
|
66
|
+
# meaning that string and symbol keys will not match.
|
|
67
|
+
#
|
|
68
|
+
# { name: 'Rob', years: '28' }.assert_valid_keys(:name, :age) # => raises "ArgumentError: Unknown key: :years. Valid keys are: :name, :age"
|
|
69
|
+
# { name: 'Rob', age: '28' }.assert_valid_keys('name', 'age') # => raises "ArgumentError: Unknown key: :name. Valid keys are: 'name', 'age'"
|
|
70
|
+
# { name: 'Rob', age: '28' }.assert_valid_keys(:name, :age) # => passes, raises nothing
|
|
71
|
+
def assert_valid_keys(*valid_keys)
|
|
72
|
+
valid_keys.flatten!
|
|
73
|
+
each_key do |k|
|
|
74
|
+
unless valid_keys.include?(k)
|
|
75
|
+
raise ArgumentError.new("Unknown key: #{k.inspect}. Valid keys are: #{valid_keys.map(&:inspect).join(', ')}")
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Returns a new hash with all keys converted by the block operation.
|
|
81
|
+
# This includes the keys from the root hash and from all
|
|
82
|
+
# nested hashes and arrays.
|
|
83
|
+
#
|
|
84
|
+
# hash = { person: { name: 'Rob', age: '28' } }
|
|
85
|
+
#
|
|
86
|
+
# hash.deep_transform_keys{ |key| key.to_s.upcase }
|
|
87
|
+
# # => {"PERSON"=>{"NAME"=>"Rob", "AGE"=>"28"}}
|
|
88
|
+
def deep_transform_keys(&block)
|
|
89
|
+
_deep_transform_keys_in_object(self, &block)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Destructively convert all keys by using the block operation.
|
|
93
|
+
# This includes the keys from the root hash and from all
|
|
94
|
+
# nested hashes and arrays.
|
|
95
|
+
def deep_transform_keys!(&block)
|
|
96
|
+
_deep_transform_keys_in_object!(self, &block)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Returns a new hash with all keys converted to strings.
|
|
100
|
+
# This includes the keys from the root hash and from all
|
|
101
|
+
# nested hashes and arrays.
|
|
102
|
+
#
|
|
103
|
+
# hash = { person: { name: 'Rob', age: '28' } }
|
|
104
|
+
#
|
|
105
|
+
# hash.deep_stringify_keys
|
|
106
|
+
# # => {"person"=>{"name"=>"Rob", "age"=>"28"}}
|
|
107
|
+
def deep_stringify_keys
|
|
108
|
+
deep_transform_keys{ |key| key.to_s }
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# Destructively convert all keys to strings.
|
|
112
|
+
# This includes the keys from the root hash and from all
|
|
113
|
+
# nested hashes and arrays.
|
|
114
|
+
def deep_stringify_keys!
|
|
115
|
+
deep_transform_keys!{ |key| key.to_s }
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# Returns a new hash with all keys converted to symbols, as long as
|
|
119
|
+
# they respond to +to_sym+. This includes the keys from the root hash
|
|
120
|
+
# and from all nested hashes and arrays.
|
|
121
|
+
#
|
|
122
|
+
# hash = { 'person' => { 'name' => 'Rob', 'age' => '28' } }
|
|
123
|
+
#
|
|
124
|
+
# hash.deep_symbolize_keys
|
|
125
|
+
# # => {:person=>{:name=>"Rob", :age=>"28"}}
|
|
126
|
+
def deep_symbolize_keys
|
|
127
|
+
deep_transform_keys{ |key| key.to_sym rescue key }
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
# Destructively convert all keys to symbols, as long as they respond
|
|
131
|
+
# to +to_sym+. This includes the keys from the root hash and from all
|
|
132
|
+
# nested hashes and arrays.
|
|
133
|
+
def deep_symbolize_keys!
|
|
134
|
+
deep_transform_keys!{ |key| key.to_sym rescue key }
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
private
|
|
138
|
+
# support methods for deep transforming nested hashes and arrays
|
|
139
|
+
def _deep_transform_keys_in_object(object, &block)
|
|
140
|
+
case object
|
|
141
|
+
when Hash
|
|
142
|
+
object.each_with_object({}) do |(key, value), result|
|
|
143
|
+
result[yield(key)] = _deep_transform_keys_in_object(value, &block)
|
|
144
|
+
end
|
|
145
|
+
when Array
|
|
146
|
+
object.map {|e| _deep_transform_keys_in_object(e, &block) }
|
|
147
|
+
else
|
|
148
|
+
object
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def _deep_transform_keys_in_object!(object, &block)
|
|
153
|
+
case object
|
|
154
|
+
when Hash
|
|
155
|
+
object.keys.each do |key|
|
|
156
|
+
value = object.delete(key)
|
|
157
|
+
object[yield(key)] = _deep_transform_keys_in_object!(value, &block)
|
|
158
|
+
end
|
|
159
|
+
object
|
|
160
|
+
when Array
|
|
161
|
+
object.map! {|e| _deep_transform_keys_in_object!(e, &block)}
|
|
162
|
+
else
|
|
163
|
+
object
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Files in this folder are taken from Rails 4.
|
data/lib/cloudinary/api.rb
CHANGED
|
@@ -187,11 +187,12 @@ class Cloudinary::Api
|
|
|
187
187
|
cloud_name = options[:cloud_name] || Cloudinary.config.cloud_name || raise("Must supply cloud_name")
|
|
188
188
|
api_key = options[:api_key] || Cloudinary.config.api_key || raise("Must supply api_key")
|
|
189
189
|
api_secret = options[:api_secret] || Cloudinary.config.api_secret || raise("Must supply api_secret")
|
|
190
|
+
timeout = options[:timeout] || Cloudinary.config.timeout || 60
|
|
190
191
|
api_url = [cloudinary, "v1_1", cloud_name, uri].join("/")
|
|
191
192
|
# Add authentication
|
|
192
193
|
api_url.sub!(%r(^(https?://)), "\\1#{api_key}:#{api_secret}@")
|
|
193
194
|
|
|
194
|
-
RestClient::Request.execute(:method => method, :url => api_url, :payload => params.reject{|k, v| v.nil? || v==""}, :timeout=>
|
|
195
|
+
RestClient::Request.execute(:method => method, :url => api_url, :payload => params.reject{|k, v| v.nil? || v==""}, :timeout=> timeout, :headers => {"User-Agent" => Cloudinary::USER_AGENT}) do
|
|
195
196
|
|response, request, tmpresult|
|
|
196
197
|
return Response.new(response) if response.code == 200
|
|
197
198
|
exception_class = case response.code
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Copyright Cloudinary
|
|
2
2
|
# Support for store in CarrierWave files that were preloaded to cloudinary (e.g., by javascript)
|
|
3
3
|
# Field value must be in the format: "image/upload/v<version>/<public_id>.<format>#<signature>"
|
|
4
|
-
# Where signature is the
|
|
4
|
+
# Where signature is the cloudinary API signature on the public_id and version.
|
|
5
5
|
module Cloudinary::CarrierWave
|
|
6
6
|
PRELOADED_CLOUDINARY_PATH = Cloudinary::PreloadedFile::PRELOADED_CLOUDINARY_PATH
|
|
7
7
|
STORED_CLOUDINARY_PATH = /^([^\/]+)\/([^\/]+)\/v(\d+)\/([^#]+)$/
|
data/lib/cloudinary/helper.rb
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
require 'digest/md5'
|
|
2
|
+
require 'cloudinary/video_helper'
|
|
3
|
+
|
|
2
4
|
module CloudinaryHelper
|
|
3
5
|
CL_BLANK = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"
|
|
4
6
|
|
|
@@ -25,34 +27,46 @@ module CloudinaryHelper
|
|
|
25
27
|
#
|
|
26
28
|
# See documentation for more details and options: http://cloudinary.com/documentation/rails_image_manipulation
|
|
27
29
|
def cl_image_tag(source, options = {})
|
|
28
|
-
options
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
cloudinary_tag source, options do |source, options|
|
|
31
|
+
if source
|
|
32
|
+
image_tag_without_cloudinary(source, options)
|
|
33
|
+
else
|
|
34
|
+
tag 'img', options
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def cloudinary_tag(source, options = {})
|
|
41
|
+
tag_options = options.clone
|
|
42
|
+
tag_options[:width] = tag_options.delete(:html_width) if tag_options.include?(:html_width)
|
|
43
|
+
tag_options[:height] = tag_options.delete(:html_height) if tag_options.include?(:html_height)
|
|
44
|
+
tag_options[:size] = tag_options.delete(:html_size) if tag_options.include?(:html_size)
|
|
45
|
+
tag_options[:border] = tag_options.delete(:html_border) if tag_options.include?(:html_border)
|
|
46
|
+
source = cloudinary_url_internal(source, tag_options)
|
|
47
|
+
|
|
48
|
+
responsive_placeholder = Cloudinary::Utils.config_option_consume(tag_options, :responsive_placeholder)
|
|
49
|
+
hidpi = tag_options.delete(:hidpi)
|
|
50
|
+
responsive = tag_options.delete(:responsive)
|
|
37
51
|
if hidpi || responsive
|
|
38
|
-
|
|
52
|
+
tag_options["data-src"] = source
|
|
39
53
|
source = nil
|
|
40
54
|
extra_class = responsive ? "cld-responsive" : "cld-hidpi"
|
|
41
|
-
|
|
55
|
+
tag_options[:class] = [tag_options[:class], extra_class].compact.join(" ")
|
|
42
56
|
responsive_placeholder = CL_BLANK if responsive_placeholder == "blank"
|
|
43
|
-
|
|
57
|
+
tag_options[:src] = responsive_placeholder
|
|
44
58
|
end
|
|
45
|
-
if
|
|
46
|
-
|
|
59
|
+
if block_given?
|
|
60
|
+
yield(source,tag_options)
|
|
47
61
|
else
|
|
48
|
-
|
|
62
|
+
tag('div', tag_options)
|
|
49
63
|
end
|
|
50
64
|
end
|
|
51
65
|
|
|
52
66
|
def cl_blank
|
|
53
67
|
CL_BLANK
|
|
54
68
|
end
|
|
55
|
-
|
|
69
|
+
|
|
56
70
|
# Works similarly to cl_image_tag, however just generates the URL of the image
|
|
57
71
|
def cl_image_path(source, options = {})
|
|
58
72
|
options = options.clone
|
|
@@ -177,7 +191,7 @@ module CloudinaryHelper
|
|
|
177
191
|
def cl_image_upload(object_name, method, options={})
|
|
178
192
|
cl_image_upload_tag("#{object_name}[#{method}]", options)
|
|
179
193
|
end
|
|
180
|
-
|
|
194
|
+
alias_method :cl_upload, :cl_image_upload
|
|
181
195
|
def cl_unsigned_image_upload(object_name, method, upload_preset, options={})
|
|
182
196
|
cl_unsigned_image_upload_tag("#{object_name}[#{method}]", upload_preset, options)
|
|
183
197
|
end
|
|
@@ -212,6 +226,7 @@ module CloudinaryHelper
|
|
|
212
226
|
).reject{|k,v| v.blank?}
|
|
213
227
|
content_tag("input", nil, tag_options)
|
|
214
228
|
end
|
|
229
|
+
alias_method :cl_upload_tag, :cl_image_upload_tag
|
|
215
230
|
|
|
216
231
|
def cl_unsigned_image_upload_tag(field, upload_preset, options={})
|
|
217
232
|
cl_image_upload_tag(field, options.merge(:unsigned => true, :upload_preset => upload_preset))
|
|
@@ -236,8 +251,8 @@ module CloudinaryHelper
|
|
|
236
251
|
include ActionView::Helpers::AssetTagHelper
|
|
237
252
|
end
|
|
238
253
|
if defined?(Rails::version) && !Rails.version.start_with?('2') && Cloudinary.config.enhance_image_tag
|
|
239
|
-
alias_method_chain :image_tag, :cloudinary
|
|
240
|
-
alias_method_chain :image_path, :cloudinary
|
|
254
|
+
alias_method_chain :image_tag, :cloudinary # defines image_tag_without_cloudinary
|
|
255
|
+
alias_method_chain :image_path, :cloudinary # defines image_path_without_cloudinary
|
|
241
256
|
else
|
|
242
257
|
alias_method :image_tag_without_cloudinary, :image_tag
|
|
243
258
|
alias_method :image_path_without_cloudinary, :image_path
|
|
@@ -263,7 +278,9 @@ module CloudinaryHelper
|
|
|
263
278
|
|
|
264
279
|
def build_callback_url(options)
|
|
265
280
|
callback_path = options.delete(:callback_cors) || Cloudinary.config.callback_cors || "/cloudinary_cors.html"
|
|
266
|
-
if
|
|
281
|
+
if callback_path.match(/^https?:\/\//)
|
|
282
|
+
callback_path
|
|
283
|
+
else
|
|
267
284
|
callback_url = request.scheme + "://"
|
|
268
285
|
callback_url << request.host
|
|
269
286
|
if request.scheme == "https" && request.port != 443 ||
|
|
@@ -272,7 +289,6 @@ module CloudinaryHelper
|
|
|
272
289
|
end
|
|
273
290
|
callback_url << callback_path
|
|
274
291
|
end
|
|
275
|
-
callback_url
|
|
276
292
|
end
|
|
277
293
|
end
|
|
278
294
|
|
|
@@ -280,6 +296,7 @@ module Cloudinary::FormBuilder
|
|
|
280
296
|
def cl_image_upload(method, options={})
|
|
281
297
|
@template.cl_image_upload(@object_name, method, objectify_options(options))
|
|
282
298
|
end
|
|
299
|
+
alias_method :cl_upload, :cl_image_upload
|
|
283
300
|
def cl_unsigned_image_upload(method, upload_preset, options={})
|
|
284
301
|
@template.cl_unsigned_image_upload(@object_name, method, upload_preset, objectify_options(options))
|
|
285
302
|
end
|
data/lib/cloudinary/missing.rb
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
unless nil.respond_to?(:blank?)
|
|
2
2
|
class Object
|
|
3
3
|
def blank?
|
|
4
4
|
respond_to?(:empty?) ? empty? : !self
|
|
5
5
|
end
|
|
6
6
|
|
|
7
|
-
if not
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
end
|
|
14
|
-
end
|
|
7
|
+
# An object is present if it's not blank.
|
|
8
|
+
#
|
|
9
|
+
# @return [true, false]
|
|
10
|
+
def present?
|
|
11
|
+
!blank?
|
|
12
|
+
end unless Object.instance_methods.include? :present?
|
|
15
13
|
|
|
14
|
+
def presence
|
|
15
|
+
self if present?
|
|
16
|
+
end unless Object.instance_methods.include? :presence
|
|
16
17
|
end
|
|
17
|
-
|
|
18
|
+
|
|
18
19
|
class NilClass #:nodoc:
|
|
19
20
|
def blank?
|
|
20
21
|
true
|