filestack-rails 5.0.0 → 5.1.0
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/README.md +0 -2
- data/lib/filestack_rails/configuration.rb +37 -3
- data/lib/filestack_rails/filestack_js.rb +5 -31
- data/lib/filestack_rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c631c08561aa591604aaf478a36bc704b89fcc27
|
4
|
+
data.tar.gz: cc82fc8b32042d9bc09df2501106df1f045944ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 578f21e06f6656f44c97592abae5f44d7c99460e0cdec830edde22a99f4fdcd5255e9511508d59868da74e9b5e23633ecfe7180de2aa84a196511ba1f84ac0ea
|
7
|
+
data.tar.gz: 8e4205702a128597afef8e334a839b43ad431a9f7944bfeeec5150e52a7cf374090a9854e439f76c6dbd0a89dd8c2ff1f46abee993fc861c70db0d012a3e99d7
|
data/README.md
CHANGED
@@ -77,8 +77,6 @@ config.filestack_rails.version = '1.x.x'
|
|
77
77
|
config.filestack_rails.version = '3.x.x'
|
78
78
|
```
|
79
79
|
|
80
|
-
You can find all available filestack-js versions in [`lib/filestack_rails/version.rb`](./lib/filestack_rails/version.rb)
|
81
|
-
|
82
80
|
### CNAME
|
83
81
|
|
84
82
|
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.
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
|
3
3
|
module FilestackRails
|
4
|
+
OUTDATED_VERSION = '0.11.5'
|
5
|
+
|
4
6
|
class Configuration
|
5
7
|
attr_accessor :api_key, :client_name, :secret_key, :security, :expiry, :app_secret, :cname, :version
|
6
8
|
|
7
|
-
OUTDATED_VERSION = '0.11.5'
|
8
|
-
|
9
9
|
def api_key
|
10
10
|
@api_key or raise "Set config.filestack_rails.api_key"
|
11
11
|
end
|
@@ -15,7 +15,10 @@ module FilestackRails
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def version
|
18
|
-
@version
|
18
|
+
@version ||= '3.x.x'
|
19
|
+
|
20
|
+
raise 'Incorrect config.filestack_rails.version' unless version_exists?
|
21
|
+
@version
|
19
22
|
end
|
20
23
|
|
21
24
|
def expiry
|
@@ -32,5 +35,36 @@ module FilestackRails
|
|
32
35
|
def app_secret
|
33
36
|
@app_secret or nil
|
34
37
|
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
|
35
69
|
end
|
36
70
|
end
|
@@ -1,23 +1,8 @@
|
|
1
|
-
require 'net/http'
|
2
|
-
|
3
1
|
class Picker
|
4
2
|
attr_reader :url
|
5
3
|
|
6
4
|
def initialize
|
7
|
-
|
8
|
-
@url = filestack_js_url
|
9
|
-
end
|
10
|
-
|
11
|
-
def version
|
12
|
-
::Rails.application.config.filestack_rails.version
|
13
|
-
end
|
14
|
-
|
15
|
-
def security(signature, policy)
|
16
|
-
{ security: { signature: signature, policy: policy } }.to_json
|
17
|
-
end
|
18
|
-
|
19
|
-
def filestack_js_url
|
20
|
-
"https://static.filestackapi.com/filestack-js/#{version}/filestack.min.js"
|
5
|
+
@url = ::Rails.application.config.filestack_rails.url
|
21
6
|
end
|
22
7
|
|
23
8
|
def picker(client_name, api_key, options, callback, other_callbacks = nil)
|
@@ -30,21 +15,12 @@ class Picker
|
|
30
15
|
HTML
|
31
16
|
end
|
32
17
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
response = request.request_head(uri.path)
|
37
|
-
response.code.to_i == 200
|
38
|
-
rescue
|
39
|
-
false
|
40
|
-
end
|
18
|
+
def security(signature, policy)
|
19
|
+
{ security: { signature: signature, policy: policy } }.to_json
|
20
|
+
end
|
41
21
|
end
|
42
22
|
|
43
23
|
class OutdatedPicker < Picker
|
44
|
-
def filestack_js_url
|
45
|
-
'https://static.filestackapi.com/v3/filestack.js'
|
46
|
-
end
|
47
|
-
|
48
24
|
def picker(client_name, api_key, options, callback, other_callbacks = nil)
|
49
25
|
<<~HTML
|
50
26
|
(function(){
|
@@ -60,10 +36,8 @@ end
|
|
60
36
|
|
61
37
|
module FilestackRails
|
62
38
|
module FilestackJs
|
63
|
-
OUTDATED_VERSION = '0.11.5'
|
64
|
-
|
65
39
|
def get_filestack_js
|
66
|
-
if ::Rails.application.config.filestack_rails.version == OUTDATED_VERSION
|
40
|
+
if ::Rails.application.config.filestack_rails.version == FilestackRails::OUTDATED_VERSION
|
67
41
|
OutdatedPicker.new
|
68
42
|
else
|
69
43
|
Picker.new
|
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.
|
4
|
+
version: 5.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- filestack
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-08-
|
11
|
+
date: 2019-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|