filepicker-rails 1.2.0 → 1.3.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/app/helpers/filepicker_rails/application_helper.rb +44 -12
- data/lib/filepicker_rails/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 807acef7a7f487b4db552bebc8c084641e4f2730
|
4
|
+
data.tar.gz: fc310857861c323da6c123b00ee22a216c976017
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a76e4bb901b528dd717e92a85fe10e9237e209824bc4b020d682de42c3cda743a1b9c33b103874ccd33f05f4e2297ced454a7991f83fdcb9b82f9a24eb489fa1
|
7
|
+
data.tar.gz: da50efe1cd0c2b9cd7a8354a78dcbe19bf6f482aaad5470138c98923a19ce1441cdc05f2c439b0d711539912013419cd893655fcf5581116982ebca388e6f8e0
|
@@ -29,18 +29,33 @@ module FilepickerRails
|
|
29
29
|
# # => <button data-fp-apikey="..." data-fp-mimetype="image/jpg" data-fp-url="https://www.filepicker.io/api/file/hFHUCB3iTxyMzseuWOgG" name="button" type="submit">save</button>
|
30
30
|
#
|
31
31
|
def filepicker_save_button(text, url, mimetype, options = {})
|
32
|
-
options
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
32
|
+
export_widget(text, url, mimetype, options) do
|
33
|
+
button_tag(text, options)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# Creates a link allowing the user to download a file
|
38
|
+
# (or upload it to any of the supported services). Set the content of
|
39
|
+
# the link on the `text` parameter. The `url` of the content you want the user to save.
|
40
|
+
# Define the `mimetype` of the content. Accepts a optional `options` parameter.
|
41
|
+
#
|
42
|
+
# #### Options
|
43
|
+
#
|
44
|
+
# - `:container` - Where to show the file picker dialog can be `modal`,
|
45
|
+
# `window` or the id of an iframe on the page.
|
46
|
+
# - `:services` - What services your users can upload to. Ex: `BOX, COMPUTER, FACEBOOK`.
|
47
|
+
# - `:save_as_name` - A recommended file name. The user can override this.
|
48
|
+
#
|
49
|
+
# #### Examples
|
50
|
+
#
|
51
|
+
# filepicker_save_link "Save", @user.filepicker_url, "image/jpg"
|
52
|
+
# # => <a data-fp-apikey="..." data-fp-mimetype="image/jpg" data-fp-url="https://www.filepicker.io/api/file/hFHUCB3iTxyMzseuWOgG" href="#" id="filepicker_export_widget_link">save</a>
|
53
|
+
#
|
54
|
+
def filepicker_save_link(text, url, mimetype, options = {})
|
55
|
+
export_widget(text, url, mimetype, options) do
|
56
|
+
options[:id] = options.fetch(:id, 'filepicker_export_widget_link')
|
57
|
+
link_to text, '#', options
|
58
|
+
end
|
44
59
|
end
|
45
60
|
|
46
61
|
# Creates a image tag of the `url`. Accepts the options to work on filepicker.io,
|
@@ -168,5 +183,22 @@ module FilepickerRails
|
|
168
183
|
end
|
169
184
|
end
|
170
185
|
private_constant :FilepickerImageUrl
|
186
|
+
|
187
|
+
private
|
188
|
+
|
189
|
+
def export_widget(text, url, mimetype, options, &block)
|
190
|
+
options[:data] ||= {}
|
191
|
+
container = options.delete(:container)
|
192
|
+
services = options.delete(:services)
|
193
|
+
save_as = options.delete(:save_as_name)
|
194
|
+
|
195
|
+
options[:data]['fp-url'] = url
|
196
|
+
options[:data]['fp-apikey'] = ::Rails.application.config.filepicker_rails.api_key
|
197
|
+
options[:data]['fp-mimetype'] = mimetype
|
198
|
+
options[:data]['fp-option-container'] = container if container
|
199
|
+
options[:data]['fp-option-services'] = Array(services).join(",") if services
|
200
|
+
options[:data]['fp-option-defaultSaveasName'] = save_as if save_as
|
201
|
+
block.call
|
202
|
+
end
|
171
203
|
end
|
172
204
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: filepicker-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Max Tilford
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -173,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
173
173
|
version: '0'
|
174
174
|
requirements: []
|
175
175
|
rubyforge_project:
|
176
|
-
rubygems_version: 2.
|
176
|
+
rubygems_version: 2.4.5
|
177
177
|
signing_key:
|
178
178
|
specification_version: 4
|
179
179
|
summary: Makes integrating filepicker.io with rails 4 easy
|