remotipart 0.2.1 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +21 -0
- data/History.rdoc +7 -1
- data/README.rdoc +23 -5
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/lib/generators/templates/jquery.remotipart.js +20 -8
- data/lib/remotipart.rb +7 -3
- data/remotipart.gemspec +20 -18
- metadata +14 -6
data/.gitignore
ADDED
data/History.rdoc
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
= History
|
2
2
|
|
3
|
+
=== 0.3.0 / 2011-02-24
|
4
|
+
|
5
|
+
* New Features
|
6
|
+
* Added support for all data-type ajax submissions, not just 'script'.
|
7
|
+
* Made a little more flexible, so that separate js.erb response templates are no longer needed between remotipart (i.e. multipart) ajax form submissions and regular ajax form submissions, so multiple versions of the same form can now submit to the same action.
|
8
|
+
|
3
9
|
=== 0.2.1 / 2011-01-16
|
4
10
|
|
5
11
|
* Minor Enhancements
|
@@ -18,4 +24,4 @@
|
|
18
24
|
|
19
25
|
=== 0.1.0 / 2010-04-09
|
20
26
|
|
21
|
-
* Initial Release
|
27
|
+
* Initial Release
|
data/README.rdoc
CHANGED
@@ -7,18 +7,22 @@ This gem augments the native Rails jQuery remote form function enabling asynchro
|
|
7
7
|
|
8
8
|
* {Rails 3}[http://github.com/rails/rails]
|
9
9
|
* {jQuery}[http://jquery.com]
|
10
|
-
* {The Rails jQuery driver}[
|
10
|
+
* {The jquery-rails gem}[http://rubygems.org/gems/jquery-rails], which really just installs {the Rails jQuery driver (jquery-ujs)}[https://github.com/rails/jquery-ujs]
|
11
|
+
|
12
|
+
<b>PLEASE NOTE - DUE TO RECENT REFACTORING IN THE MASTER BRANCH OF JQUERY-UJS, SEE PREREQUISITE BELOW. A FIX IS ON THE WAY.</b>
|
11
13
|
* {The jQuery Form plugin}[http://jquery.malsup.com/form/]
|
12
14
|
|
13
15
|
== Installation
|
14
16
|
|
17
|
+
<b>Prerequisite: Make sure you have a supported jquery-ujs (rails.js) version. To be certain, replace public/javascripts/rails.js with {this version}[https://github.com/rails/jquery-ujs/raw/51272c68714748420d8c35984b3e2532ab14f748/src/rails.js] of rails.js.</b>
|
18
|
+
|
15
19
|
1. Install the Remotipart gem
|
16
20
|
|
17
21
|
gem install remotipart
|
18
22
|
|
19
23
|
2. Run the Remotipart generator to add jquery.remotipart.js to public/javascripts/
|
20
24
|
|
21
|
-
|
25
|
+
rails g remotipart
|
22
26
|
|
23
27
|
3. Add the Javascript files for jQuery, the Rails jQuery driver, jQuery Form plugin, and Remotipart to your template, making sure to include jquery.remotipart.js *after* jQuery and the Rails jQuery driver
|
24
28
|
|
@@ -32,11 +36,25 @@ This gem augments the native Rails jQuery remote form function enabling asynchro
|
|
32
36
|
:format == 'js'
|
33
37
|
* In the JS response template for your controller action, wrap all of your response code in one remotipart_response block:
|
34
38
|
<%= remotipart_response do %> All Javascript response code goes here <% end %>
|
35
|
-
|
36
|
-
== Advanced Usage
|
37
|
-
|
38
39
|
* The options available to the text_area_tag[http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#method-i-text_area_tag] can be passed to remotipart_response for further control over the response. For instance:
|
39
40
|
<%= remotipart_response({:escape => false}) do %> All Javascript response code goes here <% end %>
|
41
|
+
* UPDATE: As of v0.3.0, anything inside the +remotipart_response+ block will be rendered normally, unless the request actually did come from a remotipart-submitted form. So <tt>js.erb</tt> responses can be shared between remotipart and non-remotipart forms.
|
42
|
+
<%= remotipart_response do %>
|
43
|
+
if params[:remotipart_submitted]
|
44
|
+
// do one thing
|
45
|
+
else
|
46
|
+
// do another
|
47
|
+
end
|
48
|
+
<% end %>
|
49
|
+
* If you need to determine if a particular request was made via a remotipart-enabled form...
|
50
|
+
* from your Rails controller or view:
|
51
|
+
|
52
|
+
if params[:remotipart_submitted]
|
53
|
+
* from your javascript:
|
54
|
+
|
55
|
+
$(form).bind("ajax:success", function(){
|
56
|
+
if ( $(this).data('remotipartSubmitted') )
|
57
|
+
});
|
40
58
|
|
41
59
|
=== Example
|
42
60
|
|
data/Rakefile
CHANGED
@@ -10,9 +10,9 @@ begin
|
|
10
10
|
This gem augments the native Rails jQuery remote form function enabling asynchronous file uploads with little to no modification to your application.
|
11
11
|
It requires jQuery (http://jquery.com), the Rails jQuery driver (http://github.com/rails/jquery-ujs), and the jQuery Form plugin (http://jquery.malsup.com/form/).
|
12
12
|
}
|
13
|
-
gem.email =
|
13
|
+
gem.email = %w{greg@formasfunction.com steve@alfajango.com}
|
14
14
|
gem.homepage = "http://github.com/formasfunction/remotipart"
|
15
|
-
gem.authors = ["Greg Leppert"]
|
15
|
+
gem.authors = ["Greg Leppert", "Steve Schwartz"]
|
16
16
|
gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
17
17
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
18
18
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.1
|
@@ -1,24 +1,37 @@
|
|
1
|
-
|
1
|
+
(function ($) {
|
2
2
|
$.fn.extend({
|
3
3
|
/**
|
4
4
|
* Handles execution of remote calls involving file uploads, firing overridable events along the way
|
5
5
|
*/
|
6
6
|
callRemotipart: function () {
|
7
7
|
var el = this,
|
8
|
-
url = el.attr('action')
|
8
|
+
url = el.attr('action'),
|
9
|
+
dataType = el.attr('data-type') || 'script';
|
9
10
|
|
10
11
|
if (url === undefined) {
|
11
12
|
throw "No URL specified for remote call (action must be present).";
|
12
13
|
} else {
|
13
|
-
|
14
|
+
// Since iframe-submitted form is submitted normal-style and cannot set custom headers,
|
15
|
+
// we'll add a custom hidden input to keep track and let the server know this was still
|
16
|
+
// an AJAX form, we'll also make it easy to tell from our jQuery element object.
|
17
|
+
el
|
18
|
+
.append($('<input />', {
|
19
|
+
type: "hidden",
|
20
|
+
name: "remotipart_submitted",
|
21
|
+
value: true
|
22
|
+
}))
|
23
|
+
.data('remotipartSubmitted', dataType);
|
14
24
|
|
25
|
+
if (el.triggerAndReturn('ajax:before')) {
|
26
|
+
if (dataType == 'script') {
|
15
27
|
url = url.split('?'); // split on GET params
|
16
|
-
|
17
|
-
|
28
|
+
if(url[0].substr(-3) != '.js') url[0] += '.js'; // force rails to respond to respond to the request with :format = js
|
29
|
+
url = url.join('?'); // join on GET params
|
30
|
+
}
|
18
31
|
|
19
32
|
el.ajaxSubmit({
|
20
33
|
url: url,
|
21
|
-
dataType:
|
34
|
+
dataType: dataType,
|
22
35
|
beforeSend: function (xhr) {
|
23
36
|
el.trigger('ajax:loading', xhr);
|
24
37
|
},
|
@@ -46,5 +59,4 @@ jQuery(function ($) {
|
|
46
59
|
}
|
47
60
|
}
|
48
61
|
});
|
49
|
-
|
50
|
-
});
|
62
|
+
})(jQuery);
|
data/lib/remotipart.rb
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
module Remotipart
|
2
2
|
def remotipart_response(options = {}, &block)
|
3
|
-
response.content_type = Mime::HTML
|
4
3
|
content = with_output_buffer(&block)
|
5
|
-
|
4
|
+
if params[:remotipart_submitted]
|
5
|
+
response.content_type = Mime::HTML
|
6
|
+
text_area_tag('remotipart_response', String.new(content), options)
|
7
|
+
else
|
8
|
+
content
|
9
|
+
end
|
6
10
|
end
|
7
11
|
end
|
8
12
|
|
9
13
|
class ActionView::Base
|
10
14
|
include Remotipart
|
11
|
-
end
|
15
|
+
end
|
data/remotipart.gemspec
CHANGED
@@ -1,45 +1,47 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{remotipart}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Greg Leppert"]
|
12
|
-
s.date = %q{2011-
|
11
|
+
s.authors = ["Greg Leppert", "Steve Schwartz"]
|
12
|
+
s.date = %q{2011-03-15}
|
13
13
|
s.description = %q{Remotipart is a Ruby on Rails gem enabling remote multipart forms (AJAX style file uploads) with jQuery.
|
14
14
|
This gem augments the native Rails jQuery remote form function enabling asynchronous file uploads with little to no modification to your application.
|
15
15
|
It requires jQuery (http://jquery.com), the Rails jQuery driver (http://github.com/rails/jquery-ujs), and the jQuery Form plugin (http://jquery.malsup.com/form/).
|
16
16
|
}
|
17
|
-
s.email =
|
17
|
+
s.email = ["greg@formasfunction.com", "steve@alfajango.com"]
|
18
18
|
s.extra_rdoc_files = [
|
19
19
|
"LICENSE",
|
20
|
-
|
20
|
+
"README.rdoc"
|
21
21
|
]
|
22
22
|
s.files = [
|
23
23
|
".document",
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
24
|
+
".gitignore",
|
25
|
+
"History.rdoc",
|
26
|
+
"LICENSE",
|
27
|
+
"README.rdoc",
|
28
|
+
"Rakefile",
|
29
|
+
"VERSION",
|
30
|
+
"lib/generators/remotipart_generator.rb",
|
31
|
+
"lib/generators/templates/jquery.remotipart.js",
|
32
|
+
"lib/remotipart.rb",
|
33
|
+
"remotipart.gemspec",
|
34
|
+
"test/helper.rb",
|
35
|
+
"test/test_remotipart.rb"
|
35
36
|
]
|
36
37
|
s.homepage = %q{http://github.com/formasfunction/remotipart}
|
38
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
37
39
|
s.require_paths = ["lib"]
|
38
40
|
s.rubygems_version = %q{1.3.7}
|
39
41
|
s.summary = %q{Remotipart is a Ruby on Rails gem enabling remote multipart forms (AJAX style file uploads) with jQuery.}
|
40
42
|
s.test_files = [
|
41
43
|
"test/helper.rb",
|
42
|
-
|
44
|
+
"test/test_remotipart.rb"
|
43
45
|
]
|
44
46
|
|
45
47
|
if s.respond_to? :specification_version then
|
metadata
CHANGED
@@ -1,20 +1,22 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: remotipart
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 17
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
|
-
-
|
8
|
+
- 3
|
8
9
|
- 1
|
9
|
-
version: 0.
|
10
|
+
version: 0.3.1
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Greg Leppert
|
14
|
+
- Steve Schwartz
|
13
15
|
autorequire:
|
14
16
|
bindir: bin
|
15
17
|
cert_chain: []
|
16
18
|
|
17
|
-
date: 2011-
|
19
|
+
date: 2011-03-15 00:00:00 -04:00
|
18
20
|
default_executable:
|
19
21
|
dependencies:
|
20
22
|
- !ruby/object:Gem::Dependency
|
@@ -25,13 +27,16 @@ dependencies:
|
|
25
27
|
requirements:
|
26
28
|
- - ">="
|
27
29
|
- !ruby/object:Gem::Version
|
30
|
+
hash: 3
|
28
31
|
segments:
|
29
32
|
- 0
|
30
33
|
version: "0"
|
31
34
|
type: :development
|
32
35
|
version_requirements: *id001
|
33
36
|
description: "Remotipart is a Ruby on Rails gem enabling remote multipart forms (AJAX style file uploads) with jQuery.\n This gem augments the native Rails jQuery remote form function enabling asynchronous file uploads with little to no modification to your application.\n It requires jQuery (http://jquery.com), the Rails jQuery driver (http://github.com/rails/jquery-ujs), and the jQuery Form plugin (http://jquery.malsup.com/form/).\n "
|
34
|
-
email:
|
37
|
+
email:
|
38
|
+
- greg@formasfunction.com
|
39
|
+
- steve@alfajango.com
|
35
40
|
executables: []
|
36
41
|
|
37
42
|
extensions: []
|
@@ -41,6 +46,7 @@ extra_rdoc_files:
|
|
41
46
|
- README.rdoc
|
42
47
|
files:
|
43
48
|
- .document
|
49
|
+
- .gitignore
|
44
50
|
- History.rdoc
|
45
51
|
- LICENSE
|
46
52
|
- README.rdoc
|
@@ -57,8 +63,8 @@ homepage: http://github.com/formasfunction/remotipart
|
|
57
63
|
licenses: []
|
58
64
|
|
59
65
|
post_install_message:
|
60
|
-
rdoc_options:
|
61
|
-
|
66
|
+
rdoc_options:
|
67
|
+
- --charset=UTF-8
|
62
68
|
require_paths:
|
63
69
|
- lib
|
64
70
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -66,6 +72,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
66
72
|
requirements:
|
67
73
|
- - ">="
|
68
74
|
- !ruby/object:Gem::Version
|
75
|
+
hash: 3
|
69
76
|
segments:
|
70
77
|
- 0
|
71
78
|
version: "0"
|
@@ -74,6 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
81
|
requirements:
|
75
82
|
- - ">="
|
76
83
|
- !ruby/object:Gem::Version
|
84
|
+
hash: 3
|
77
85
|
segments:
|
78
86
|
- 0
|
79
87
|
version: "0"
|