remotipart 1.3.1 → 1.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +35 -0
- data/Appraisals +25 -0
- data/Gemfile +14 -1
- data/History.rdoc +23 -0
- data/README.rdoc +2 -0
- data/Rakefile +5 -7
- data/gemfiles/rails_3.2.gemfile +26 -0
- data/gemfiles/rails_4.2.gemfile +24 -0
- data/gemfiles/rails_5.2.gemfile +24 -0
- data/gemfiles/rails_6.0.gemfile +24 -0
- data/lib/remotipart/middleware.rb +2 -2
- data/lib/remotipart/rails/engine.rb +8 -4
- data/lib/remotipart/rails/railtie.rb +8 -4
- data/lib/remotipart/rails/version.rb +2 -2
- data/lib/remotipart/render_overrides.rb +28 -8
- data/lib/remotipart/request_helper.rb +2 -0
- data/lib/remotipart/view_helper.rb +2 -0
- data/remotipart.gemspec +94 -18
- data/spec/dummy_app/.gitignore +17 -0
- data/spec/dummy_app/Rakefile +7 -0
- data/spec/dummy_app/app/assets/config/manifest.js +4 -0
- data/spec/dummy_app/app/assets/images/rails.png +0 -0
- data/spec/dummy_app/app/assets/javascripts/application.js.erb +8 -0
- data/spec/dummy_app/app/assets/javascripts/comments.js +28 -0
- data/spec/dummy_app/app/assets/stylesheets/application.css +6 -0
- data/spec/dummy_app/app/assets/stylesheets/scaffold.css +65 -0
- data/spec/dummy_app/app/controllers/application_controller.rb +3 -0
- data/spec/dummy_app/app/controllers/comments_controller.rb +72 -0
- data/spec/dummy_app/app/controllers/prepended_controller.rb +9 -0
- data/spec/dummy_app/app/helpers/application_helper.rb +2 -0
- data/spec/dummy_app/app/helpers/comments_helper.rb +2 -0
- data/spec/dummy_app/app/models/comment.rb +7 -0
- data/spec/dummy_app/app/views/comments/_comment.html.erb +9 -0
- data/spec/dummy_app/app/views/comments/_form.html.erb +40 -0
- data/spec/dummy_app/app/views/comments/_new_comment_links.html.erb +5 -0
- data/spec/dummy_app/app/views/comments/create.html.erb +7 -0
- data/spec/dummy_app/app/views/comments/create.js.erb +20 -0
- data/spec/dummy_app/app/views/comments/destroy.js.erb +1 -0
- data/spec/dummy_app/app/views/comments/edit.html.erb +6 -0
- data/spec/dummy_app/app/views/comments/escape_test.html.erb +1 -0
- data/spec/dummy_app/app/views/comments/index.html.erb +19 -0
- data/spec/dummy_app/app/views/comments/new.html.erb +7 -0
- data/spec/dummy_app/app/views/comments/show.html.erb +15 -0
- data/spec/dummy_app/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy_app/app/views/prepended/show.html.erb +1 -0
- data/spec/dummy_app/bin/bundle +3 -0
- data/spec/dummy_app/bin/rails +4 -0
- data/spec/dummy_app/bin/rake +4 -0
- data/spec/dummy_app/bin/setup +34 -0
- data/spec/dummy_app/bin/update +29 -0
- data/spec/dummy_app/config/application.rb +18 -0
- data/spec/dummy_app/config/boot.rb +3 -0
- data/spec/dummy_app/config/database.yml +7 -0
- data/spec/dummy_app/config/environment.rb +5 -0
- data/spec/dummy_app/config/environments/development.rb +54 -0
- data/spec/dummy_app/config/environments/test.rb +53 -0
- data/spec/dummy_app/config/initializers/secret_token.rb +3 -0
- data/spec/dummy_app/config/routes.rb +7 -0
- data/spec/dummy_app/config/secrets.yml +5 -0
- data/spec/dummy_app/config.ru +4 -0
- data/spec/dummy_app/db/migrate/20110209210252_create_comments.rb +14 -0
- data/spec/dummy_app/db/migrate/20110209210315_add_attachment_to_comment.rb +15 -0
- data/spec/dummy_app/db/migrate/20110714205346_add_other_attachment_to_comment.rb +8 -0
- data/spec/dummy_app/db/schema.rb +31 -0
- data/spec/dummy_app/db/seeds.rb +7 -0
- data/spec/features/comments_spec.rb +414 -0
- data/spec/features/prepended_spec.rb +9 -0
- data/spec/fixtures/hi.txt +1 -0
- data/spec/fixtures/qr.jpg +0 -0
- data/spec/spec_helper.rb +40 -0
- data/spec/support/arel_helper.rb +15 -0
- data/spec/support/connection_helper.rb +12 -0
- data/spec/support/integration_helper.rb +28 -0
- data/vendor/assets/javascripts/jquery.iframe-transport.js +38 -27
- data/vendor/assets/javascripts/jquery.remotipart.js +1 -1
- metadata +134 -4
@@ -1,12 +1,12 @@
|
|
1
|
-
// This [jQuery](
|
2
|
-
// [transport](
|
1
|
+
// This [jQuery](https://jquery.com/) plugin implements an `<iframe>`
|
2
|
+
// [transport](https://api.jquery.com/jQuery.ajax/#extending-ajax) so that
|
3
3
|
// `$.ajax()` calls support the uploading of files using standard HTML file
|
4
4
|
// input fields. This is done by switching the exchange from `XMLHttpRequest`
|
5
5
|
// to a hidden `iframe` element containing a form that is submitted.
|
6
6
|
|
7
|
-
// The [source for the plugin](
|
8
|
-
// is available on [Github](
|
9
|
-
//
|
7
|
+
// The [source for the plugin](https://github.com/cmlenz/jquery-iframe-transport)
|
8
|
+
// is available on [Github](https://github.com/) and licensed under the [MIT
|
9
|
+
// license](https://github.com/cmlenz/jquery-iframe-transport/blob/master/LICENSE).
|
10
10
|
|
11
11
|
// ## Usage
|
12
12
|
|
@@ -70,9 +70,9 @@
|
|
70
70
|
// impossible for the javascript code to determine the HTTP status code of the
|
71
71
|
// servers response. Effectively, all of the calls you make will look like they
|
72
72
|
// are getting successful responses, and thus invoke the `done()` or
|
73
|
-
// `complete()`
|
74
|
-
//
|
75
|
-
//
|
73
|
+
// `complete()` callbacks. You can only communicate problems using the content
|
74
|
+
// of the response payload. For example, consider using a JSON response such as
|
75
|
+
// the following to indicate a problem with an uploaded file:
|
76
76
|
|
77
77
|
// <textarea data-type="application/json">
|
78
78
|
// {"ok": false, "message": "Please only upload reasonably sized files."}
|
@@ -96,6 +96,7 @@
|
|
96
96
|
// switches to the "iframe" data type if it is `true`.
|
97
97
|
$.ajaxPrefilter(function(options, origOptions, jqXHR) {
|
98
98
|
if (options.iframe) {
|
99
|
+
options.originalURL = options.url;
|
99
100
|
return "iframe";
|
100
101
|
}
|
101
102
|
});
|
@@ -109,18 +110,18 @@
|
|
109
110
|
name = "iframe-" + $.now(),
|
110
111
|
files = $(options.files).filter(":file:enabled"),
|
111
112
|
markers = null,
|
112
|
-
accepts;
|
113
|
+
accepts = null;
|
113
114
|
|
114
115
|
// This function gets called after a successful submission or an abortion
|
115
116
|
// and should revert all changes made to the page to enable the
|
116
117
|
// submission via this transport.
|
117
118
|
function cleanUp() {
|
118
|
-
|
119
|
-
$(
|
120
|
-
|
119
|
+
files.each(function(i, file) {
|
120
|
+
var $file = $(file);
|
121
|
+
$file.data("clone").replaceWith($file);
|
121
122
|
});
|
122
123
|
form.remove();
|
123
|
-
iframe.
|
124
|
+
iframe.one("load", function() { iframe.remove(); });
|
124
125
|
iframe.attr("src", "about:blank");
|
125
126
|
}
|
126
127
|
|
@@ -129,9 +130,14 @@
|
|
129
130
|
// (unsupported) conversion from "iframe" to the actual type.
|
130
131
|
options.dataTypes.shift();
|
131
132
|
|
133
|
+
// Use the data from the original AJAX options, as it doesn't seem to be
|
134
|
+
// copied over since jQuery 1.7.
|
135
|
+
// See https://github.com/cmlenz/jquery-iframe-transport/issues/6
|
136
|
+
options.data = origOptions.data;
|
137
|
+
|
132
138
|
if (files.length) {
|
133
139
|
form = $("<form enctype='multipart/form-data' method='post'></form>").
|
134
|
-
hide().attr({action: options.
|
140
|
+
hide().attr({action: options.originalURL, target: name});
|
135
141
|
|
136
142
|
// If there is any additional data specified via the `data` option,
|
137
143
|
// we add it as hidden fields to the form. This (currently) requires
|
@@ -155,21 +161,27 @@
|
|
155
161
|
$("<input type='hidden' value='IFrame' name='X-Requested-With' />").
|
156
162
|
appendTo(form);
|
157
163
|
|
158
|
-
// Borrowed straight from the JQuery source
|
159
|
-
// Provides a way of specifying the accepted data type similar to
|
160
|
-
|
161
|
-
|
162
|
-
options.accepts[
|
163
|
-
|
164
|
-
|
165
|
-
.
|
164
|
+
// Borrowed straight from the JQuery source.
|
165
|
+
// Provides a way of specifying the accepted data type similar to the
|
166
|
+
// HTTP "Accept" header
|
167
|
+
if (options.dataTypes[0] && options.accepts[options.dataTypes[0]]) {
|
168
|
+
accepts = options.accepts[options.dataTypes[0]] +
|
169
|
+
(options.dataTypes[0] !== "*" ? ", */*; q=0.01" : "");
|
170
|
+
} else {
|
171
|
+
accepts = options.accepts["*"];
|
172
|
+
}
|
173
|
+
$("<input type='hidden' name='X-HTTP-Accept'>").
|
174
|
+
attr("value", accepts).appendTo(form);
|
166
175
|
|
167
176
|
// Move the file fields into the hidden form, but first remember their
|
168
177
|
// original locations in the document by replacing them with disabled
|
169
178
|
// clones. This should also avoid introducing unwanted changes to the
|
170
179
|
// page layout during submission.
|
171
180
|
markers = files.after(function(idx) {
|
172
|
-
|
181
|
+
var $this = $(this),
|
182
|
+
$clone = $this.clone().prop("disabled", true);
|
183
|
+
$this.data("clone", $clone);
|
184
|
+
return $clone;
|
173
185
|
}).next();
|
174
186
|
files.appendTo(form);
|
175
187
|
|
@@ -183,13 +195,13 @@
|
|
183
195
|
|
184
196
|
// The first load event gets fired after the iframe has been injected
|
185
197
|
// into the DOM, and is used to prepare the actual submission.
|
186
|
-
iframe.
|
198
|
+
iframe.one("load", function() {
|
187
199
|
|
188
200
|
// The second load event gets fired when the response to the form
|
189
201
|
// submission is received. The implementation detects whether the
|
190
202
|
// actual payload is embedded in a `<textarea>` element, and
|
191
203
|
// prepares the required conversions to be made in that case.
|
192
|
-
iframe.
|
204
|
+
iframe.one("load", function() {
|
193
205
|
var doc = this.contentWindow ? this.contentWindow.document :
|
194
206
|
(this.contentDocument ? this.contentDocument : this.document),
|
195
207
|
root = doc.documentElement ? doc.documentElement : doc.body,
|
@@ -198,7 +210,6 @@
|
|
198
210
|
status = textarea && textarea.getAttribute("data-status") || 200,
|
199
211
|
statusText = textarea && textarea.getAttribute("data-statusText") || "OK",
|
200
212
|
content = {
|
201
|
-
html: root.innerHTML,
|
202
213
|
text: type ?
|
203
214
|
textarea.value :
|
204
215
|
root ? (root.textContent || root.innerText) : null
|
@@ -226,7 +237,7 @@
|
|
226
237
|
// aborted.
|
227
238
|
abort: function() {
|
228
239
|
if (iframe !== null) {
|
229
|
-
iframe.unbind("load").attr("src", "
|
240
|
+
iframe.unbind("load").attr("src", "about:blank");
|
230
241
|
cleanUp();
|
231
242
|
}
|
232
243
|
}
|
@@ -51,7 +51,7 @@
|
|
51
51
|
// Allow remotipartSubmit to be cancelled if needed
|
52
52
|
if ($.rails.fire(form, 'ajax:remotipartSubmit', [xhr, settings])) {
|
53
53
|
// Second verse, same as the first
|
54
|
-
$.rails.ajax(settings).
|
54
|
+
$.rails.ajax(settings).always(function(data){
|
55
55
|
$.rails.fire(form, 'ajax:remotipartComplete', [data]);
|
56
56
|
});
|
57
57
|
setTimeout(function(){ $.rails.disableFormElements(form); }, 20);
|
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.
|
4
|
+
version: 1.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Leppert
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2019-12-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -39,6 +39,76 @@ dependencies:
|
|
39
39
|
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: appraisal
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: jquery-rails
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: sqlite3
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: paperclip
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: remotipart
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
42
112
|
description: "Remotipart is a Ruby on Rails gem enabling remote multipart forms (AJAX
|
43
113
|
style file uploads) with jquery-rails.\n This gem augments the native Rails 3
|
44
114
|
jQuery-UJS remote form function enabling asynchronous file uploads with little to
|
@@ -53,6 +123,8 @@ extra_rdoc_files:
|
|
53
123
|
- README.rdoc
|
54
124
|
files:
|
55
125
|
- ".document"
|
126
|
+
- ".travis.yml"
|
127
|
+
- Appraisals
|
56
128
|
- CONTRIBUTING.md
|
57
129
|
- Gemfile
|
58
130
|
- History.rdoc
|
@@ -60,6 +132,10 @@ files:
|
|
60
132
|
- README.rdoc
|
61
133
|
- Rakefile
|
62
134
|
- VERSION_COMPATIBILITY.rdoc
|
135
|
+
- gemfiles/rails_3.2.gemfile
|
136
|
+
- gemfiles/rails_4.2.gemfile
|
137
|
+
- gemfiles/rails_5.2.gemfile
|
138
|
+
- gemfiles/rails_6.0.gemfile
|
63
139
|
- lib/generators/remotipart/install/install_generator.rb
|
64
140
|
- lib/remotipart.rb
|
65
141
|
- lib/remotipart/middleware.rb
|
@@ -71,6 +147,61 @@ files:
|
|
71
147
|
- lib/remotipart/request_helper.rb
|
72
148
|
- lib/remotipart/view_helper.rb
|
73
149
|
- remotipart.gemspec
|
150
|
+
- spec/dummy_app/.gitignore
|
151
|
+
- spec/dummy_app/Rakefile
|
152
|
+
- spec/dummy_app/app/assets/config/manifest.js
|
153
|
+
- spec/dummy_app/app/assets/images/rails.png
|
154
|
+
- spec/dummy_app/app/assets/javascripts/application.js.erb
|
155
|
+
- spec/dummy_app/app/assets/javascripts/comments.js
|
156
|
+
- spec/dummy_app/app/assets/stylesheets/application.css
|
157
|
+
- spec/dummy_app/app/assets/stylesheets/scaffold.css
|
158
|
+
- spec/dummy_app/app/controllers/application_controller.rb
|
159
|
+
- spec/dummy_app/app/controllers/comments_controller.rb
|
160
|
+
- spec/dummy_app/app/controllers/prepended_controller.rb
|
161
|
+
- spec/dummy_app/app/helpers/application_helper.rb
|
162
|
+
- spec/dummy_app/app/helpers/comments_helper.rb
|
163
|
+
- spec/dummy_app/app/models/comment.rb
|
164
|
+
- spec/dummy_app/app/views/comments/_comment.html.erb
|
165
|
+
- spec/dummy_app/app/views/comments/_form.html.erb
|
166
|
+
- spec/dummy_app/app/views/comments/_new_comment_links.html.erb
|
167
|
+
- spec/dummy_app/app/views/comments/create.html.erb
|
168
|
+
- spec/dummy_app/app/views/comments/create.js.erb
|
169
|
+
- spec/dummy_app/app/views/comments/destroy.js.erb
|
170
|
+
- spec/dummy_app/app/views/comments/edit.html.erb
|
171
|
+
- spec/dummy_app/app/views/comments/escape_test.html.erb
|
172
|
+
- spec/dummy_app/app/views/comments/index.html.erb
|
173
|
+
- spec/dummy_app/app/views/comments/new.html.erb
|
174
|
+
- spec/dummy_app/app/views/comments/show.html.erb
|
175
|
+
- spec/dummy_app/app/views/layouts/application.html.erb
|
176
|
+
- spec/dummy_app/app/views/prepended/show.html.erb
|
177
|
+
- spec/dummy_app/bin/bundle
|
178
|
+
- spec/dummy_app/bin/rails
|
179
|
+
- spec/dummy_app/bin/rake
|
180
|
+
- spec/dummy_app/bin/setup
|
181
|
+
- spec/dummy_app/bin/update
|
182
|
+
- spec/dummy_app/config.ru
|
183
|
+
- spec/dummy_app/config/application.rb
|
184
|
+
- spec/dummy_app/config/boot.rb
|
185
|
+
- spec/dummy_app/config/database.yml
|
186
|
+
- spec/dummy_app/config/environment.rb
|
187
|
+
- spec/dummy_app/config/environments/development.rb
|
188
|
+
- spec/dummy_app/config/environments/test.rb
|
189
|
+
- spec/dummy_app/config/initializers/secret_token.rb
|
190
|
+
- spec/dummy_app/config/routes.rb
|
191
|
+
- spec/dummy_app/config/secrets.yml
|
192
|
+
- spec/dummy_app/db/migrate/20110209210252_create_comments.rb
|
193
|
+
- spec/dummy_app/db/migrate/20110209210315_add_attachment_to_comment.rb
|
194
|
+
- spec/dummy_app/db/migrate/20110714205346_add_other_attachment_to_comment.rb
|
195
|
+
- spec/dummy_app/db/schema.rb
|
196
|
+
- spec/dummy_app/db/seeds.rb
|
197
|
+
- spec/features/comments_spec.rb
|
198
|
+
- spec/features/prepended_spec.rb
|
199
|
+
- spec/fixtures/hi.txt
|
200
|
+
- spec/fixtures/qr.jpg
|
201
|
+
- spec/spec_helper.rb
|
202
|
+
- spec/support/arel_helper.rb
|
203
|
+
- spec/support/connection_helper.rb
|
204
|
+
- spec/support/integration_helper.rb
|
74
205
|
- vendor/assets/javascripts/jquery.iframe-transport.js
|
75
206
|
- vendor/assets/javascripts/jquery.remotipart.js
|
76
207
|
homepage: http://opensource.alfajango.com/remotipart/
|
@@ -91,8 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
222
|
- !ruby/object:Gem::Version
|
92
223
|
version: '0'
|
93
224
|
requirements: []
|
94
|
-
|
95
|
-
rubygems_version: 2.5.1
|
225
|
+
rubygems_version: 3.0.3
|
96
226
|
signing_key:
|
97
227
|
specification_version: 4
|
98
228
|
summary: Remotipart is a Ruby on Rails gem enabling remote multipart forms (AJAX style
|