filestack-rails 5.1.0 → 5.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/filestack_rails/configuration.rb +1 -37
- data/lib/filestack_rails/filestack_js.rb +16 -2
- data/lib/filestack_rails/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd152cdc473d7d22147bcdf0955185d00c3c84f3
|
4
|
+
data.tar.gz: 95170d3865def665caf98fc9ecd3ce2ae84076cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 847b2ecceb41ed39fbf3b156f59d3e9f82d2dc86f4712e0abfaa3294a441724e60c4592de64037b443dfa85266b7d1868149b857bafe9a900ec8a414d6434636
|
7
|
+
data.tar.gz: de1e59f571e4b4cd9f42c419995e8a1bfd3565d085ca31c2429484535e3ff95d45ba9650f7bcd55da75e01c0527c248dbc4480cb71b23ea577b685d3177bd1bd
|
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.
|
@@ -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
|
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,15 @@ class Picker
|
|
2
2
|
attr_reader :url
|
3
3
|
|
4
4
|
def initialize
|
5
|
-
@url =
|
5
|
+
@url = filestack_js_url
|
6
|
+
end
|
7
|
+
|
8
|
+
def filestack_js_url
|
9
|
+
"https://static.filestackapi.com/filestack-js/#{version}/filestack.min.js"
|
10
|
+
end
|
11
|
+
|
12
|
+
def version
|
13
|
+
::Rails.application.config.filestack_rails.version
|
6
14
|
end
|
7
15
|
|
8
16
|
def picker(client_name, api_key, options, callback, other_callbacks = nil)
|
@@ -21,6 +29,10 @@ class Picker
|
|
21
29
|
end
|
22
30
|
|
23
31
|
class OutdatedPicker < Picker
|
32
|
+
def filestack_js_url
|
33
|
+
'https://static.filestackapi.com/v3/filestack.js'
|
34
|
+
end
|
35
|
+
|
24
36
|
def picker(client_name, api_key, options, callback, other_callbacks = nil)
|
25
37
|
<<~HTML
|
26
38
|
(function(){
|
@@ -36,8 +48,10 @@ end
|
|
36
48
|
|
37
49
|
module FilestackRails
|
38
50
|
module FilestackJs
|
51
|
+
OUTDATED_VERSION = '0.11.5'
|
52
|
+
|
39
53
|
def get_filestack_js
|
40
|
-
if ::Rails.application.config.filestack_rails.version ==
|
54
|
+
if ::Rails.application.config.filestack_rails.version == OUTDATED_VERSION
|
41
55
|
OutdatedPicker.new
|
42
56
|
else
|
43
57
|
Picker.new
|