uploader 2.0.0 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -0
- data/VERSION +1 -1
- data/app/helpers/uploader_helper.rb +25 -14
- data/app/views/uploads/_uploadify.html.erb +14 -5
- data/uploader.gemspec +2 -2
- metadata +4 -4
data/README.rdoc
CHANGED
@@ -6,6 +6,7 @@ Uploader makes it easy to integrate multiple file uploads into your application
|
|
6
6
|
SWFUpload hasn't been updated in a while and tends to be buggy. We have added uploadify. We recommend using that instead.
|
7
7
|
|
8
8
|
This branch has been setup to maintain compatibility with Rails2. Future versions of uploader will focus on Rails 3.
|
9
|
+
Note that all 2.x.x versions of uploader will work with Rails 2 while 3.x.x versions are slated for Rails 3.
|
9
10
|
|
10
11
|
== Installation
|
11
12
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.
|
1
|
+
2.0.2
|
@@ -25,16 +25,27 @@ module UploaderHelper
|
|
25
25
|
|
26
26
|
# Output a form capable of uploading multiple files to the server using uploadify.
|
27
27
|
# parent: The object to which the uploads will be attached
|
28
|
-
#
|
29
|
-
#
|
28
|
+
# options:
|
29
|
+
# display_upload_indicators: Indicates whether or not to show the upload progress
|
30
|
+
# container_prefix: Prefixes each id in the html with the specified text. Useful if there is to be more than one form on a page.
|
31
|
+
# format: either js or json. js will fire a callback.
|
32
|
+
# omit_initializer: Remove the call to jQuery('#element').uploadify. If this is set to true the calling code
|
33
|
+
# must call .uploadify for the upload to work.
|
30
34
|
# Options is a hash containing any valid option for uploadify:
|
31
35
|
# http://www.uploadify.com/documentation/
|
32
|
-
|
33
|
-
|
34
|
-
|
36
|
+
def uploadify_form(parent, options = {}, uploadify_options = {})
|
37
|
+
|
38
|
+
options = {
|
39
|
+
:display_upload_indicators => true,
|
40
|
+
:format => 'js',
|
41
|
+
:omit_initializer => false
|
42
|
+
}.merge(options)
|
43
|
+
|
44
|
+
options[:container_prefix] = 'uploadify' if options[:container_prefix].blank?
|
45
|
+
|
35
46
|
uploadify_options = {
|
36
47
|
:uploader => '/swf/uploadify.swf',
|
37
|
-
:script => multiupload_uploads_path({:format => format}),
|
48
|
+
:script => multiupload_uploads_path({:format => options[:format]}),
|
38
49
|
:cancelImg => '/images/uploadify/cancel.png',
|
39
50
|
:fileDesc => "All Files",
|
40
51
|
:fileExt => "*.*",
|
@@ -48,17 +59,17 @@ module UploaderHelper
|
|
48
59
|
"#{session_key}" => 'session_key_replace_',
|
49
60
|
'authenticity_token' => 'authenticity_token_replace_'
|
50
61
|
}.merge(make_parent_params(parent))
|
51
|
-
}.merge(
|
62
|
+
}.merge(uploadify_options)
|
52
63
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
64
|
+
uploadify_options_json = uploadify_options.to_json
|
65
|
+
# This is a bit of a hack but to_json will surround 'encodeURIComponent' with quotes so it won't execute.
|
66
|
+
# We need it to execute. The double encode is required - u on the server and encodeURIComponent on the client.
|
67
|
+
uploadify_options_json.gsub!('"session_key_replace_"', "encodeURIComponent('#{u(cookies[session_key])}')")
|
68
|
+
uploadify_options_json.gsub!('"authenticity_token_replace_"', "encodeURIComponent('#{u(form_authenticity_token)}')")
|
69
|
+
uploadify_options_json.gsub!('"oncomplete_replace_"', 'function(event, queueID, fileObj, response, data){ upload_completed_callback(response); return true; }')
|
59
70
|
|
60
71
|
render :partial => 'uploads/uploadify', :locals => { :parent => parent,
|
61
|
-
:
|
72
|
+
:options => options,
|
62
73
|
:uploadify_options => uploadify_options_json}
|
63
74
|
end
|
64
75
|
|
@@ -6,11 +6,20 @@
|
|
6
6
|
<% end -%>
|
7
7
|
<% end -%>
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
<div id="<%=options[:container_prefix]%>_upload">
|
10
|
+
<% form_for :upload, :url => uploads_path(make_parent_params(parent)), :html => { :multipart => true, :id => "#{options[:container_prefix]}_form" } do |f| -%>
|
11
|
+
<p><%= f.file_field :local, :size => 25 %></p>
|
12
|
+
<%= submit_tag t('uploader.upload_file') %>
|
13
|
+
<% end %>
|
14
|
+
</div>
|
13
15
|
|
14
16
|
<script type='text/javascript'>
|
15
|
-
|
17
|
+
<% if options[:omit_initializer] -%>
|
18
|
+
var <%=options[:container_prefix]%>_options = <%=uploadify_options%>;
|
19
|
+
<% else -%>
|
20
|
+
jQuery(document).ready(function() {
|
21
|
+
jQuery('#<%=options[:container_prefix]%>_upload').uploadify(<%=uploadify_options%>);
|
22
|
+
});
|
23
|
+
<% end -%>
|
16
24
|
</script>
|
25
|
+
|
data/uploader.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{uploader}
|
8
|
-
s.version = "2.0.
|
8
|
+
s.version = "2.0.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Justin Ball", "Joel Duffin", "David South"]
|
12
|
-
s.date = %q{2010-09-
|
12
|
+
s.date = %q{2010-09-03}
|
13
13
|
s.description = %q{Uploader gem that makes it simple add multiple file uploads to your Rails project using SWFUpload, Uploadify and Paperclip}
|
14
14
|
s.email = %q{justinball@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uploader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 2.0.
|
9
|
+
- 2
|
10
|
+
version: 2.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Justin Ball
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2010-09-
|
20
|
+
date: 2010-09-03 00:00:00 -06:00
|
21
21
|
default_executable:
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|