filepicker-rails 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 979f8cfcf39dc753cf3ce5c4894c41e22f4f3e8e
4
- data.tar.gz: 58f4a611ca888ae433e3ccc0053e75797b52a22d
3
+ metadata.gz: bdbbd40e9ca36cb245058decb551050c07409f09
4
+ data.tar.gz: 18ed7a4fef1e29641a14c3fe44f5b3d53da5da13
5
5
  SHA512:
6
- metadata.gz: af2f3c5751a991c5f92f4e7f1351b1ea98dabde485dd4eae557f9a1ea1bfabf4039bfba84cea899eef3627bbf2ef93b89be8e81da1c9cc9a22e29937b0148d12
7
- data.tar.gz: c4cc2ebe154f5c6fef316fd3a115c5c08d0ebd7c67842ebe0a80c5e370c0992ef5e087c49decc459ed79ac15f1e8cc33d1581e31f4f447bbec80cc4641a5568c
6
+ metadata.gz: d78b7710a6a81288be4d5e29cfe06c469ecd64cafffabf983fea1f25b4f10ce22b750a7b632b67b0cdafcc1d78fc6df74360031cf9b25629e6ab63ba1bf5c35c
7
+ data.tar.gz: b3e3f5984ab5b101a1e4f5560066a3e9775b926b46353f97accf3b06e77e0b917bf47b37c7926e44cd1b0ce5da10a70e765c65ec9b38b2051b555db4a7204ced
data/README.md CHANGED
@@ -34,8 +34,22 @@ Set your API Key in config/application.rb:
34
34
  config.filepicker_rails.api_key = "Your filepicker.io API Key"
35
35
  ```
36
36
 
37
+ Set your Secret Key in config/application.rb for signed request support:
38
+
39
+ ```ruby
40
+ config.filepicker_rails.secret_key = "Your filepicker.io Secret Key"
41
+ ```
42
+
43
+ Set your CDN Path in config/production.rb ([CDN usage](https://developers.inkfilepicker.com/docs/cdn/)):
44
+
45
+ ```ruby
46
+ config.filepicker_rails.cdn_host = "Your CDN host name"
47
+ ```
48
+
37
49
  ## Usage
50
+
38
51
  ### First create a migration to add the field that will hold your filepicker.io URL
52
+
39
53
  Run the Rails migration generator from the command line:
40
54
 
41
55
  $ rails g migration AddNameOfAttrForFilepickerUrlToUser
@@ -54,7 +68,6 @@ class AddNameOfAttrForFilepickerUrlToUser < ActiveRecord::Migration
54
68
  end
55
69
  ```
56
70
 
57
-
58
71
  ### Adding an upload field to your form:
59
72
 
60
73
  ```erb
@@ -67,6 +80,7 @@ end
67
80
  <%= f.submit %>
68
81
  <% end %>
69
82
  ```
83
+
70
84
  Full options list:
71
85
 
72
86
  * button_text - The text of the upload button.
@@ -87,7 +101,22 @@ of an iframe on the page.
87
101
 
88
102
  ### Accessing FilePicker File with OnChange:
89
103
 
90
- When the dialog finishes uploading the file, the javascript code in the onchange field will be run with a special 'event' variable. The variable has a fpfiles (or if not multiple, also fpfile) attribute with information about the files (jQuery users: look under event.originalEvent).
104
+ Javascript code in the onchange field acts as a callback, which is
105
+ called on upload completion. You can specify onchange either in the ERB
106
+ template (as shown below), or unobtrusively via jQuery's change event.
107
+
108
+ ```erb
109
+ <%= form_for @user do |f| %>
110
+ <div>
111
+ <%= f.label :filepicker_url, "Upload Your Avatar:" %>
112
+ <%= f.filepicker_field :filepicker_url, onchange: 'onPhotoUpload(event)' %>
113
+ </div>
114
+
115
+ <%= f.submit %>
116
+ <% end %>
117
+ ```
118
+
119
+ The callback is called with a special 'event' variable. The variable has a fpfiles (or if not multiple, also fpfile) attribute with information about the files (jQuery users: look under event.originalEvent).
91
120
 
92
121
  Example fpfiles object:
93
122
  ```javascript
@@ -116,7 +145,6 @@ Example fpfiles object:
116
145
 
117
146
  See [the filepicker.io documentation](https://developers.filepicker.io/docs/web/#fpurl-images) for the full options list.
118
147
 
119
-
120
148
  ### Allowing the user to download a file (or upload it to any of the supported services)
121
149
 
122
150
  ```erb
@@ -153,7 +181,7 @@ Thank you to all the [contributors](https://github.com/Ink/filepicker-rails/grap
153
181
  [gem_version_badge]: https://badge.fury.io/rb/filepicker-rails.png
154
182
  [ruby_gems]: http://rubygems.org/gems/filepicker-rails
155
183
  [travis_ci]: http://travis-ci.org/Ink/filepicker-rails
156
- [travis_ci_badge]: https://secure.travis-ci.org/Ink/filepicker-rails.png
184
+ [travis_ci_badge]: https://travis-ci.org/Ink/filepicker-rails.svg?branch=master
157
185
  [code_climate]: https://codeclimate.com/github/Ink/filepicker-rails
158
186
  [code_climate_badge]: https://codeclimate.com/github/Ink/filepicker-rails.png
159
187
  [coveralls]: https://coveralls.io/r/Ink/filepicker-rails
data/Rakefile CHANGED
@@ -1,5 +1,6 @@
1
1
  begin
2
2
  require 'bundler/setup'
3
+ require 'appraisal'
3
4
  rescue LoadError
4
5
  puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
6
  end
@@ -42,6 +42,10 @@ module FilepickerRails
42
42
  # align - Determines how the image is aligned when resizing and using the "fit" parameter.
43
43
  # Check API for details.
44
44
  #
45
+ # rotate - Rotate the image. Default is no rotation.
46
+ # rotate="exif" will rotate the image automatically based on the exif data in the image.
47
+ # Other valid values are integers between 0 and 359, for degrees of rotation.
48
+ #
45
49
  # cache - Specifies if the image should be cached or not.
46
50
  #
47
51
  # crop - Crops the image to a specified rectangle. The input to this parameter
@@ -69,8 +73,18 @@ module FilepickerRails
69
73
  # and horizontal with a comma. The default behavior
70
74
  # is bottom,right
71
75
  def filepicker_image_url(url, options = {})
72
- query_params = options.slice(:w, :h, :fit, :align, :cache, :crop, :format, :quality, :watermark, :watersize, :waterposition).to_query
73
- [url, "/convert?", query_params].join
76
+ query_params = options.slice(:w, :h, :fit, :align, :rotate, :cache, :crop, :format, :quality, :watermark, :watersize, :waterposition).to_query
77
+
78
+ if ::Rails.application.config.filepicker_rails.cdn_host
79
+ uri = URI.parse(url)
80
+ url.gsub!("#{uri.scheme}://#{uri.host}", ::Rails.application.config.filepicker_rails.cdn_host)
81
+ end
82
+
83
+ if query_params.blank?
84
+ [url, query_params]
85
+ else
86
+ [url, "/convert?", query_params]
87
+ end.join
74
88
  end
75
89
  end
76
90
  end
@@ -4,7 +4,7 @@ module FilepickerRails
4
4
  def filepicker_field(method, options = {})
5
5
  type = options.delete(:dragdrop) ? 'filepicker-dragdrop' : 'filepicker'
6
6
 
7
- input_options = retrive_legacy_filepicker_options(options)
7
+ input_options = retrieve_legacy_filepicker_options(options)
8
8
  input_options['data-fp-apikey'] ||= ::Rails.application.config.filepicker_rails.api_key
9
9
  input_options.merge!(secure_filepicker) unless input_options['data-fp-policy'].present?
10
10
  input_options['type'] = type
@@ -20,7 +20,7 @@ module FilepickerRails
20
20
 
21
21
  private
22
22
 
23
- def retrive_legacy_filepicker_options(options)
23
+ def retrieve_legacy_filepicker_options(options)
24
24
  mappings = {
25
25
  :button_text => 'data-fp-button-text',
26
26
  :button_class => 'data-fp-button-class',
@@ -34,6 +34,7 @@ module FilepickerRails
34
34
  :store_location => 'data-fp-store-location',
35
35
  :store_access => 'data-fp-store-access',
36
36
  :multiple => 'data-fp-multiple',
37
+ :max_size => 'data-fp-maxSize',
37
38
  :onchange => 'onchange',
38
39
  :class => 'class',
39
40
  :value => 'value'
@@ -1,15 +1,12 @@
1
1
  module FilepickerRails
2
2
  class Configuration
3
- attr_writer :api_key, :secret_key, :default_expiry
3
+ attr_writer :api_key, :default_expiry
4
+ attr_accessor :secret_key, :cdn_host
4
5
 
5
6
  def api_key
6
7
  @api_key or raise "Set config.filepicker_rails.api_key"
7
8
  end
8
9
 
9
- def secret_key
10
- @secret_key
11
- end
12
-
13
10
  def default_expiry
14
11
  @default_expiry ||= 600
15
12
  end
@@ -1,3 +1,3 @@
1
1
  module FilepickerRails
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,83 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filepicker-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.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: 2013-09-20 00:00:00.000000000 Z
11
+ date: 2014-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: coveralls
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: sqlite3
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec-rails
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: timecop
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: appraisal
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: capybara
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
81
109
  - !ruby/object:Gem::Version
82
110
  version: '0'
83
111
  description: Makes integrating filepicker.io with rails 4 easy
@@ -87,6 +115,9 @@ executables: []
87
115
  extensions: []
88
116
  extra_rdoc_files: []
89
117
  files:
118
+ - MIT-LICENSE
119
+ - README.md
120
+ - Rakefile
90
121
  - app/helpers/filepicker_rails/application_helper.rb
91
122
  - app/helpers/filepicker_rails/form_helper.rb
92
123
  - lib/filepicker-rails.rb
@@ -94,11 +125,9 @@ files:
94
125
  - lib/filepicker_rails/engine.rb
95
126
  - lib/filepicker_rails/policy.rb
96
127
  - lib/filepicker_rails/version.rb
97
- - MIT-LICENSE
98
- - Rakefile
99
- - README.md
100
128
  homepage: https://github.com/Ink/filepicker-rails
101
- licenses: []
129
+ licenses:
130
+ - MIT
102
131
  metadata: {}
103
132
  post_install_message:
104
133
  rdoc_options: []
@@ -106,17 +135,17 @@ require_paths:
106
135
  - lib
107
136
  required_ruby_version: !ruby/object:Gem::Requirement
108
137
  requirements:
109
- - - '>='
138
+ - - ">="
110
139
  - !ruby/object:Gem::Version
111
140
  version: '0'
112
141
  required_rubygems_version: !ruby/object:Gem::Requirement
113
142
  requirements:
114
- - - '>='
143
+ - - ">="
115
144
  - !ruby/object:Gem::Version
116
145
  version: '0'
117
146
  requirements: []
118
147
  rubyforge_project:
119
- rubygems_version: 2.0.5
148
+ rubygems_version: 2.2.2
120
149
  signing_key:
121
150
  specification_version: 4
122
151
  summary: Makes integrating filepicker.io with rails 4 easy