filestack-rails 5.1.0 → 5.3.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c631c08561aa591604aaf478a36bc704b89fcc27
4
- data.tar.gz: cc82fc8b32042d9bc09df2501106df1f045944ce
2
+ SHA256:
3
+ metadata.gz: 5552cc2bca2433a129013994ca3cc84a87a9921faf22bf1736546b3c07211f6e
4
+ data.tar.gz: a3714640635244fe1dfc03b0789f2aea8492755037df7ba0eeff27979b3d77bc
5
5
  SHA512:
6
- metadata.gz: 578f21e06f6656f44c97592abae5f44d7c99460e0cdec830edde22a99f4fdcd5255e9511508d59868da74e9b5e23633ecfe7180de2aa84a196511ba1f84ac0ea
7
- data.tar.gz: 8e4205702a128597afef8e334a839b43ad431a9f7944bfeeec5150e52a7cf374090a9854e439f76c6dbd0a89dd8c2ff1f46abee993fc861c70db0d012a3e99d7
6
+ metadata.gz: 2e42dc9c415471c880f29c8df4ae26d9320c90bf31384777418a80e987210ea9a4f72dceaae758aedc3f11015b4486aad860a800d63daf60b3b2bcf0a67bd582
7
+ data.tar.gz: bfd1fe7db0cb0f86017eb2a9bb38beabbc18e895adc71b93b5cefc52e76467bc230329c264a1eae12cd00fa409bf8f20caeb9415582f5fa8be2e21608a63c39b
data/README.md CHANGED
@@ -77,6 +77,8 @@ config.filestack_rails.version = '1.x.x'
77
77
  config.filestack_rails.version = '3.x.x'
78
78
  ```
79
79
 
80
+ Please take a look on available versions in [filestack-js](https://github.com/filestack/filestack-js) repository.
81
+
80
82
  ### CNAME
81
83
 
82
84
  If you have set up a custom CNAME, you can add it to your configuration file. The Picker will modify all assets to formatted with your domain origin instead of Filestack's.
@@ -180,6 +182,19 @@ Filestack::Rails now has access to the full list of image transforms through our
180
182
  ```erb
181
183
  <%= filestack_image @user.filepicker_url, transform: filestack_transform.resize(width:100, height:100).flip.enhance %>
182
184
  ```
185
+
186
+ You can also add attributes to `image_tag`, for instance:
187
+ ```erb
188
+ <%= filestack_image @user.filepicker_url, size: "160x100", alt: "Picture" %>
189
+ ```
190
+
191
+ ### Fetching a converted Filestack image URL with Filestack Transformations:
192
+ The `filestack_image_url` method accepts the original Filestack image URL and an optional `filestack_transform` chain:
193
+
194
+ ```erb
195
+ <%= image_tag @user.filepicker_url, data: { transformed_image_url: filestack_image_url(@user.filepicker_url, filestack_transform.resize(width: 100, height: 100).flip.enhance) } %>
196
+ ```
197
+
183
198
  ## Migrating from 2.x to 3.x
184
199
  Filestack::Rails 3.x is a significant and breaking change. Users wishing to upgrade will need to change their current implementation in order to use the plugin correctly.
185
200
 
@@ -199,6 +214,7 @@ The `filestack_image` tag wraps the generic Rails `image_tag` and generates a ne
199
214
  ```erb
200
215
  <%= @user.filestack_url, transform: filestack_transform.resize(width:100, height:100).enhance %>
201
216
  ```
217
+ For a list of valid transformations, please see [here](https://www.filestack.com/docs/api/processing/).
202
218
 
203
219
  ### Ruby SDK
204
220
  Filestack::Rails injects the Filestack Ruby SDK into your application for use anywhere. You can use it to access the rest of the Filestack API and find its documentation [here](https://github.com/filestack/filestack-ruby).
@@ -29,14 +29,15 @@ module FilestackRails
29
29
  end
30
30
 
31
31
  def filestack_image(url, options = {})
32
- transform_object = options[:transform]
33
- options.delete(:transform)
34
- if transform_object
35
- transform_object.add_external_url url
36
- image_tag transform_object.fs_url, options
37
- else
38
- image_tag url
39
- end
32
+ transform_object = options.delete(:transform)
33
+
34
+ image_tag(filestack_image_url(url, transform_object), options)
35
+ end
36
+
37
+ def filestack_image_url(url, transform_object = nil)
38
+ return url unless transform_object
39
+ transform_object.add_external_url(url)
40
+ transform_object.fs_url
40
41
  end
41
42
 
42
43
  private
@@ -78,11 +79,11 @@ module FilestackRails
78
79
  signature = security.signature
79
80
  policy = security.policy
80
81
  end
81
- [signature, policy]
82
+ [policy, signature]
82
83
  end
83
84
 
84
85
  def get_policy_and_signature_string
85
- signature, policy = get_policy_and_signature
86
+ policy, signature = get_policy_and_signature
86
87
 
87
88
  if policy && signature
88
89
  get_filestack_js.security(signature, policy)
@@ -3,6 +3,8 @@ require "filestack_rails/transform"
3
3
  require "filestack_rails/engine"
4
4
  require "filestack_rails/version"
5
5
  require "filestack_rails/filestack_js"
6
+ require_relative "../app/helpers/filestack_rails/application_helper"
7
+ require_relative "../app/helpers/filestack_rails/form_helper"
6
8
 
7
9
  module FilestackRails
8
10
  # Your code goes here...
@@ -1,8 +1,6 @@
1
1
  require 'net/http'
2
2
 
3
3
  module FilestackRails
4
- OUTDATED_VERSION = '0.11.5'
5
-
6
4
  class Configuration
7
5
  attr_accessor :api_key, :client_name, :secret_key, :security, :expiry, :app_secret, :cname, :version
8
6
 
@@ -15,10 +13,7 @@ module FilestackRails
15
13
  end
16
14
 
17
15
  def version
18
- @version ||= '3.x.x'
19
-
20
- raise 'Incorrect config.filestack_rails.version' unless version_exists?
21
- @version
16
+ @version or '3.x.x'
22
17
  end
23
18
 
24
19
  def expiry
@@ -35,36 +30,5 @@ module FilestackRails
35
30
  def app_secret
36
31
  @app_secret or nil
37
32
  end
38
-
39
- def url
40
- @url
41
- end
42
-
43
- def version_exists?
44
- @url = filestack_js_url
45
-
46
- if @version == OUTDATED_VERSION
47
- @url = outdated_filestack_js_url
48
- end
49
-
50
- url_exists?(@url)
51
- end
52
-
53
- def url_exists?(url)
54
- uri = URI(url)
55
- request = Net::HTTP.new(uri.host)
56
- response = request.request_head(uri.path)
57
- response.code.to_i == 200
58
- rescue
59
- raise 'Invalid URI'
60
- end
61
-
62
- def outdated_filestack_js_url
63
- 'https://static.filestackapi.com/v3/filestack.js'
64
- end
65
-
66
- def filestack_js_url
67
- "https://static.filestackapi.com/filestack-js/#{@version}/filestack.min.js"
68
- end
69
33
  end
70
34
  end
@@ -2,7 +2,19 @@ class Picker
2
2
  attr_reader :url
3
3
 
4
4
  def initialize
5
- @url = ::Rails.application.config.filestack_rails.url
5
+ @url = filestack_js_url
6
+ end
7
+
8
+ def filestack_js_url
9
+ "https://static.#{domain}/filestack-js/#{version}/filestack.min.js"
10
+ end
11
+
12
+ def version
13
+ ::Rails.application.config.filestack_rails.version
14
+ end
15
+
16
+ def domain
17
+ ::Rails.application.config.filestack_rails.cname || 'filestackapi.com'
6
18
  end
7
19
 
8
20
  def picker(client_name, api_key, options, callback, other_callbacks = nil)
@@ -21,6 +33,10 @@ class Picker
21
33
  end
22
34
 
23
35
  class OutdatedPicker < Picker
36
+ def filestack_js_url
37
+ 'https://static.filestackapi.com/v3/filestack.js'
38
+ end
39
+
24
40
  def picker(client_name, api_key, options, callback, other_callbacks = nil)
25
41
  <<~HTML
26
42
  (function(){
@@ -36,8 +52,10 @@ end
36
52
 
37
53
  module FilestackRails
38
54
  module FilestackJs
55
+ OUTDATED_VERSION = '0.11.5'
56
+
39
57
  def get_filestack_js
40
- if ::Rails.application.config.filestack_rails.version == FilestackRails::OUTDATED_VERSION
58
+ if ::Rails.application.config.filestack_rails.version == OUTDATED_VERSION
41
59
  OutdatedPicker.new
42
60
  else
43
61
  Picker.new
@@ -1,3 +1,3 @@
1
1
  module FilestackRails
2
- VERSION = '5.1.0'
2
+ VERSION = '5.3.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filestack-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.0
4
+ version: 5.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - filestack
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-02 00:00:00.000000000 Z
11
+ date: 2020-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 2.6.0
33
+ version: 2.8.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 2.6.0
40
+ version: 2.8.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: coveralls
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -57,6 +57,9 @@ dependencies:
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.3'
62
+ - - ">="
60
63
  - !ruby/object:Gem::Version
61
64
  version: 1.3.6
62
65
  type: :development
@@ -64,6 +67,9 @@ dependencies:
64
67
  version_requirements: !ruby/object:Gem::Requirement
65
68
  requirements:
66
69
  - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: '1.3'
72
+ - - ">="
67
73
  - !ruby/object:Gem::Version
68
74
  version: 1.3.6
69
75
  - !ruby/object:Gem::Dependency
@@ -117,7 +123,7 @@ homepage: https://www.filestack.com
117
123
  licenses:
118
124
  - MIT
119
125
  metadata: {}
120
- post_install_message:
126
+ post_install_message:
121
127
  rdoc_options: []
122
128
  require_paths:
123
129
  - lib
@@ -132,9 +138,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
138
  - !ruby/object:Gem::Version
133
139
  version: '0'
134
140
  requirements: []
135
- rubyforge_project:
136
- rubygems_version: 2.6.14
137
- signing_key:
141
+ rubygems_version: 3.0.8
142
+ signing_key:
138
143
  specification_version: 4
139
144
  summary: Filestack plugin for Rails 4+
140
145
  test_files: []