remotipart 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,9 @@
1
1
  = History
2
2
 
3
+ === 1.2.1 / 2013-07-07
4
+
5
+ * Added automatic authenticity_token detection and appending to iframe submission.
6
+
3
7
  === 1.2.0 / 2013-07-06
4
8
 
5
9
  * Removed support for older jquery-ujs and jquery < 1.7.
@@ -1,6 +1,6 @@
1
- = Remotipart
1
+ = Remotipart: Rails jQuery File Upload
2
2
 
3
- Remotipart is a Ruby on Rails gem enabling AJAX file uploads with jQuery in Rails 3.0 and Rails 3.1 remote forms.
3
+ Remotipart is a Ruby on Rails gem enabling AJAX file uploads with jQuery in Rails 3 and Rails 4 remote forms.
4
4
  This gem augments the native Rails jQuery remote form functionality enabling asynchronous file uploads with little to no modification to your application.
5
5
 
6
6
  * {Homepage and Demos}[http://www.alfajango.com/blog/remotipart-rails-gem/]
@@ -8,8 +8,8 @@ This gem augments the native Rails jQuery remote form functionality enabling asy
8
8
 
9
9
  == Dependencies
10
10
 
11
- * {Rails 3}[http://github.com/rails/rails]
12
- * {The jquery-rails gem}[http://rubygems.org/gems/jquery-rails], which really just installs {jQuery}[http://jquery.com] and the {Rails jQuery driver (jquery-ujs)}[https://github.com/rails/jquery-ujs]
11
+ * {Rails 3 or Rails 4}[http://github.com/rails/rails]
12
+ * {The jquery-rails gem}[http://rubygems.org/gems/jquery-rails] (included in Rails 3 and Rails 4 by default), which installs {jQuery}[http://jquery.com] and the {Rails jQuery driver (jquery-ujs)}[https://github.com/rails/jquery-ujs]
13
13
 
14
14
  == Installation
15
15
 
@@ -23,7 +23,7 @@ make sure you have a supported jquery-ujs (rails.js or jquery_ujs.js) version fr
23
23
 
24
24
  * Add this line to your GEMFILE (use the appropriate version from the compatibilty chart if needed)
25
25
 
26
- gem 'remotipart', '~> 1.1'
26
+ gem 'remotipart', '~> 1.2'
27
27
 
28
28
  * And run
29
29
 
@@ -11,15 +11,17 @@ module Remotipart
11
11
  # Get request params
12
12
  params = Rack::Request.new(env).params
13
13
 
14
- # This was using an iframe transport, and is therefore an XHR
15
- # This is required if we're going to override the http_accept
16
- if params and params['X-Requested-With'] == 'IFrame'
17
- env['HTTP_X_REQUESTED_WITH'] = 'xmlhttprequest'
18
- end
14
+ if params
15
+ # This was using an iframe transport, and is therefore an XHR
16
+ # This is required if we're going to override the http_accept
17
+ if params['X-Requested-With'] == 'IFrame'
18
+ env['HTTP_X_REQUESTED_WITH'] = 'xmlhttprequest'
19
+ end
19
20
 
20
- # Override the accepted format, because it isn't what we really want
21
- if params and params['X-Http-Accept']
22
- env['HTTP_ACCEPT'] = params['X-Http-Accept']
21
+ # Override the accepted format, because it isn't what we really want
22
+ if params['X-Http-Accept']
23
+ env['HTTP_ACCEPT'] = params['X-Http-Accept']
24
+ end
23
25
  end
24
26
 
25
27
  @app.call(env)
@@ -1,6 +1,6 @@
1
1
  module Remotipart
2
2
  module Rails
3
- VERSION = "1.2.0"
3
+ VERSION = "1.2.1"
4
4
  IFRAMETRANSPORT_VERSION = "02.06.2013"
5
5
  end
6
6
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "remotipart"
8
- s.version = "1.2.0"
8
+ s.version = "1.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Greg Leppert", "Steve Schwartz"]
12
- s.date = "2013-07-06"
12
+ s.date = "2013-07-08"
13
13
  s.description = "Remotipart is a Ruby on Rails gem enabling remote multipart forms (AJAX style file uploads) with jquery-rails.\n This gem augments the native Rails 3 jQuery-UJS remote form function enabling asynchronous file uploads with little to no modification to your application.\n "
14
14
  s.email = ["greg@formasfunction.com", "steve@alfajango.com"]
15
15
  s.extra_rdoc_files = [
@@ -9,7 +9,10 @@
9
9
 
10
10
  setup: function(form) {
11
11
  // Preserve form.data('ujs:submit-button') before it gets nulled by $.ajax.handleRemote
12
- var button = form.data('ujs:submit-button');
12
+ var button = form.data('ujs:submit-button'),
13
+ csrfParam = $('meta[name="csrf-param"]').attr('content'),
14
+ csrfToken = $('meta[name="csrf-token"]').attr('content'),
15
+ csrfInput = form.find('input[name="' + csrfParam + '"]').length;
13
16
 
14
17
  form
15
18
  // Allow setup part of $.rails.handleRemote to setup remote settings before canceling default remote handler
@@ -41,6 +44,9 @@
41
44
  // Modify some settings to integrate JS request with rails helpers and middleware
42
45
  if (settings.dataType === undefined) { settings.dataType = 'script *'; }
43
46
  settings.data.push({name: 'remotipart_submitted', value: true});
47
+ if (csrfToken && csrfParam && !csrfInput) {
48
+ settings.data.push({name: csrfParam, value: csrfToken});
49
+ }
44
50
 
45
51
  // Allow remotipartSubmit to be cancelled if needed
46
52
  if ($.rails.fire(form, 'ajax:remotipartSubmit', [xhr, settings])) {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remotipart
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-07-06 00:00:00.000000000Z
13
+ date: 2013-07-08 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
17
- requirement: &70282875330640 !ruby/object:Gem::Requirement
17
+ requirement: &70170920954340 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *70282875330640
25
+ version_requirements: *70170920954340
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: jeweler
28
- requirement: &70282875329180 !ruby/object:Gem::Requirement
28
+ requirement: &70170920953080 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *70282875329180
36
+ version_requirements: *70170920953080
37
37
  description: ! "Remotipart is a Ruby on Rails gem enabling remote multipart forms
38
38
  (AJAX style file uploads) with jquery-rails.\n This gem augments the native Rails
39
39
  3 jQuery-UJS remote form function enabling asynchronous file uploads with little
@@ -83,7 +83,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
83
83
  version: '0'
84
84
  segments:
85
85
  - 0
86
- hash: -3656035227424558239
86
+ hash: -3061483236240277448
87
87
  required_rubygems_version: !ruby/object:Gem::Requirement
88
88
  none: false
89
89
  requirements: