h5_uploader 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,47 @@
1
+ require "h5_uploader/version"
2
+ require "h5_uploader/railtie" if defined?(Rails)
3
+
4
+ module Fg
5
+
6
+ module H5Uploader
7
+
8
+ class ActionView::Helpers::FormBuilder
9
+
10
+ def uploader(method,*args)
11
+ options = args.extract_options!
12
+ options[:id] = field_id(method)
13
+ options[:action] ||= '/public/system/'
14
+ options[:allowedExtensions] ||= []
15
+
16
+ jss = "var uploader = new qq.FileUploader({"
17
+ jss = jss << "element: document.getElementById('#{options[:id]}'),"
18
+ jss = jss << "allowedExtensions: #{options[:allowedExtensions].to_s}"
19
+
20
+ options.each do |key,value| next if [:id,:allowedExtensions].include?(key)
21
+ jss = jss << ",#{key} : '#{value}'"
22
+ end
23
+
24
+ jss = jss << "});"
25
+
26
+ js_tag = @template.javascript_tag do
27
+ jss
28
+ end
29
+
30
+ @template.content_tag(:div,:id => options[:id]) do
31
+ @template.content_tag(:noscript) do
32
+ @template.file_field @object_name,method
33
+ end
34
+ end << js_tag
35
+
36
+ end
37
+
38
+ def field_id(label)
39
+ "field-uploader_#{label}"
40
+ end
41
+
42
+ end
43
+
44
+ end
45
+
46
+ end
47
+
@@ -0,0 +1,10 @@
1
+ require 'rails'
2
+ module Fg
3
+ module H5Uploader
4
+ class Railtie < Rails::Railtie
5
+ rake_tasks do
6
+ require_relative '../task/rake.task'
7
+ end
8
+ end
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  module Uploader
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -0,0 +1,12 @@
1
+ require 'rake'
2
+ require 'fileutils'
3
+
4
+ namespace :h5_uploader do
5
+ task :install do
6
+ FileUtils.cp File.expand_path('../../assets/fileuploader.js',__FILE__), File.expand_path('public/javascripts/')
7
+ puts "Copied fileuploader.js to public/javascripts"
8
+ FileUtils.cp File.expand_path('../../assets/fileuploader.css',__FILE__), File.expand_path('public/stylesheets/')
9
+ puts "Copied fileuploader.css to public/stylesheets"
10
+ puts "******Open config/application.rb and add middleware configurations. See README.md in gem folder******."
11
+ end
12
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: h5_uploader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rack-raw-upload
17
- requirement: &2164795160 !ruby/object:Gem::Requirement
17
+ requirement: &2153032480 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,7 +22,7 @@ dependencies:
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *2164795160
25
+ version_requirements: *2153032480
26
26
  description: Gem add a form builder called uploader that shows a button for multiple
27
27
  file uploads usign html5 techniques
28
28
  email:
@@ -35,9 +35,13 @@ files:
35
35
  - Gemfile
36
36
  - README.md
37
37
  - Rakefile
38
- - lib/uploader.rb
39
- - lib/uploader/version.rb
40
- - uploader.gemspec
38
+ - h5_uploader.gemspec
39
+ - lib/assets/fileuploader.css
40
+ - lib/assets/fileuploader.js
41
+ - lib/h5_uploader.rb
42
+ - lib/h5_uploader/railtie.rb
43
+ - lib/h5_uploader/version.rb
44
+ - lib/task/rake.task.rb
41
45
  has_rdoc: true
42
46
  homepage: ''
43
47
  licenses: []
@@ -1,37 +0,0 @@
1
- require "uploader/version"
2
-
3
- class ActionView::Helpers::FormBuilder
4
-
5
- def uploader(method,*args)
6
- options = args.extract_options!
7
- options[:id] = field_id(method)
8
- options[:action] ||= '/public/system/'
9
- options[:allowedExtensions] ||= []
10
-
11
- jss = "var uploader = new qq.FileUploader({"
12
- jss = jss << "element: document.getElementById('#{options[:id]}'),"
13
- jss = jss << "allowedExtensions: #{options[:allowedExtensions].to_s}"
14
-
15
- options.each do |key,value| next if [:id,:allowedExtensions].include?(key)
16
- jss = jss << ",#{key} : '#{value}'"
17
- end
18
-
19
- jss = jss << "});"
20
-
21
- js_tag = @template.javascript_tag do
22
- jss
23
- end
24
-
25
- @template.content_tag(:div,:id => options[:id]) do
26
- @template.content_tag(:noscript) do
27
- "no javascript"
28
- end
29
- end << js_tag
30
-
31
- end
32
-
33
- def field_id(label)
34
- "field-uploader_#{label}"
35
- end
36
-
37
- end