filestack-rails 3.2.2 → 4.0.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 +11 -1
- data/app/helpers/filestack_rails/application_helper.rb +13 -5
- data/lib/filestack_rails/configuration.rb +5 -1
- data/lib/filestack_rails/version.rb +22 -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: 1fd7670b87d71c303e240dd8c0c1665368d59874
|
4
|
+
data.tar.gz: 37b6bd6ce8c568ddfb63dc0829050f938fe103f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18fed1f0cd5ea2c2171e175776a333ec21732e2d178d7a7fc7840473803b2770e949e2e93321d2a2575d721682f9db194aefbabaed31cdd166fa2cb30f3caa3d
|
7
|
+
data.tar.gz: 0543564f423fcafbf9d919a3f242b44589473cedcf356d5f186dc836a8e252a989a598b84b4e20a541c71c29cbf57554194d8290368c69ff1398b4fdf3f4cfd1
|
data/README.md
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
Rails SDK for Filestack API and content management system.
|
13
13
|
</p>
|
14
14
|
|
15
|
-
**Important: This is the readme for
|
15
|
+
**Important: This is the readme for 4.0.0+.**
|
16
16
|
|
17
17
|
Note that the [Filestack::Ruby](https://github.com/filestack/filestack-ruby/) dependency has been updated to no longer interfere with namespace. However, if you were using that dependency in your Rails application, you will need to change any `Client` and `Filelink` class declarations to `FilestackClient` and `FilestackFilelink`, as per documented [here](https://github.com/filestack/filestack-ruby/blob/master/README.md).
|
18
18
|
|
@@ -54,6 +54,16 @@ config.filestack_rails.client_name = 'custom_client_name'
|
|
54
54
|
```
|
55
55
|
The client name defaults to `"filestack_client"` and is injected into your client-side Javascript. This is because v3 of the File Picker lives in the Javascript of your web application.
|
56
56
|
|
57
|
+
### Filestack Picker Version
|
58
|
+
|
59
|
+
For Filestack Rails SDK v.4.0.0+, the picker `version` is setup by default to `v3`. It means that Javascript version is 1.x.x. If you want to use older Javascript version (0.11.5), you have to configure `version` to `v2` in `config/application.rb`:
|
60
|
+
```ruby
|
61
|
+
# filestack-js (0.11.5)
|
62
|
+
config.filestack_rails.version = 'v2'
|
63
|
+
|
64
|
+
# filestack-js (1.x.x)
|
65
|
+
config.filestack_rails.version = 'v3'
|
66
|
+
```
|
57
67
|
### CNAME
|
58
68
|
|
59
69
|
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,13 @@
|
|
1
1
|
include FilestackRails::Transform
|
2
|
+
include FilestackRails::Version
|
2
3
|
|
3
4
|
module FilestackRails
|
4
5
|
module ApplicationHelper
|
5
6
|
def filestack_js_include_tag
|
6
|
-
javascript_include_tag(
|
7
|
-
|
8
|
-
|
7
|
+
v2 = -> { javascript_include_tag('https://static.filestackapi.com/v3/filestack.js', type: 'text/javascript') }
|
8
|
+
v3 = -> { javascript_include_tag('https://static.filestackapi.com/filestack-js/1.x.x/filestack.min.js', type: 'text/javascript') }
|
9
|
+
|
10
|
+
get_filestack_js_result(v2: v2, v3: v3)
|
9
11
|
end
|
10
12
|
|
11
13
|
def filestack_js_init_tag
|
@@ -52,9 +54,15 @@ module FilestackRails
|
|
52
54
|
else
|
53
55
|
options.to_json
|
54
56
|
end
|
55
|
-
"(function(){
|
57
|
+
v2 = -> { "(function(){
|
56
58
|
#{client_name}.pick(#{json_string}).then(function(data){#{callback}(data)})
|
57
|
-
})()"
|
59
|
+
})()" }
|
60
|
+
|
61
|
+
v3 = -> { json_string = "#{json_string}".slice!(1, json_string.length-2) # removed curly brackets help to generate pickerOptions in js
|
62
|
+
"(function(){
|
63
|
+
#{client_name}.picker({#{json_string}, onUploadDone: data => #{callback}(data)}).open()
|
64
|
+
})()" }
|
65
|
+
get_filestack_js_result(v2: v2, v3: v3)
|
58
66
|
end
|
59
67
|
|
60
68
|
def get_client_and_api_key
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module FilestackRails
|
2
2
|
class Configuration
|
3
|
-
attr_accessor :api_key, :client_name, :secret_key, :security, :expiry, :app_secret, :cname
|
3
|
+
attr_accessor :api_key, :client_name, :secret_key, :security, :expiry, :app_secret, :cname, :version
|
4
4
|
|
5
5
|
def api_key
|
6
6
|
@api_key or raise "Set config.filestack_rails.api_key"
|
@@ -10,6 +10,10 @@ module FilestackRails
|
|
10
10
|
@client_name or 'filestack_client'
|
11
11
|
end
|
12
12
|
|
13
|
+
def version
|
14
|
+
@version or 'v3'
|
15
|
+
end
|
16
|
+
|
13
17
|
def expiry
|
14
18
|
@expiry or ( Time.zone.now.to_i + 600 )
|
15
19
|
end
|
@@ -1,3 +1,24 @@
|
|
1
|
+
class FilestackVersion
|
2
|
+
def initialize(results)
|
3
|
+
@version = ::Rails.application.config.filestack_rails.version
|
4
|
+
@results = results
|
5
|
+
end
|
6
|
+
|
7
|
+
def determine_filestack_js_result
|
8
|
+
begin
|
9
|
+
@results[@version.to_sym].call
|
10
|
+
rescue
|
11
|
+
raise 'Set correct version in config.filestack_rails.version'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
1
16
|
module FilestackRails
|
2
|
-
VERSION = '
|
17
|
+
VERSION = '4.0.0'
|
18
|
+
|
19
|
+
module Version
|
20
|
+
def get_filestack_js_result(results)
|
21
|
+
FilestackVersion.new(results).determine_filestack_js_result
|
22
|
+
end
|
23
|
+
end
|
3
24
|
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:
|
4
|
+
version: 4.0.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-01-
|
11
|
+
date: 2019-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|