Skip to content

Commit

Permalink
Support multipart upload
Browse files Browse the repository at this point in the history
  • Loading branch information
galetahub committed Dec 13, 2011
1 parent 708d153 commit 0829742
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 69 deletions.
20 changes: 20 additions & 0 deletions MIT-LICENSE
@@ -0,0 +1,20 @@
Copyright 2011 Aimbulance

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
6 changes: 4 additions & 2 deletions README.rdoc
Expand Up @@ -28,8 +28,8 @@ Find asset by foreign key or guid:

=== Views

<%= stylesheet_link_tag "fileupload/jquery.fileupload-ui.css" %>
<%= javascript_include_tag :fileupload %>
<%= stylesheet_link_tag "/javascripts/fileupload/fileuploader.css" %>
<%= javascript_include_tag :fileupload, "jquery.tmpl.min" %>

<%= form.fileupload :picture %>
<%= form.hidden_field :fileupload_guid if form.object.new_record? %>
Expand All @@ -41,3 +41,5 @@ Find asset by foreign key or guid:
<ul class="fileupload-list" style="display:none;"></ul>
</div>
</script>

Copyright (c) 2011 Aimbulance, released under the MIT license
20 changes: 0 additions & 20 deletions Rakefile
Expand Up @@ -2,7 +2,6 @@
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require File.join(File.dirname(__FILE__), 'lib', 'sunrise', 'file_upload', 'version')

desc 'Default: run unit tests.'
task :default => :test
Expand All @@ -23,22 +22,3 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_files.include('README')
rdoc.rdoc_files.include('lib/**/*.rb')
end

begin
require 'jeweler'
Jeweler::Tasks.new do |s|
s.name = "sunrise-file-upload"
s.version = Sunrise::FileUpload::VERSION.dup
s.summary = "Rails FileUpload"
s.description = "Sunrise is a Aimbulance CMS"
s.email = "galeta.igor@gmail.com"
s.homepage = "https://github.com/galetahub/sunrise-file-upload"
s.authors = ["Igor Galeta", "Pavlo Galeta"]
s.files = FileList["[A-Z]*", "{app,config,lib}/**/*"]
s.extra_rdoc_files = FileList["[A-Z]*"] - %w(Gemfile Rakefile)
end

Jeweler::GemcutterTasks.new
rescue LoadError
puts "Jeweler not available. Install it with: gem install jeweler"
end
2 changes: 1 addition & 1 deletion lib/sunrise/file_upload/version.rb
@@ -1,5 +1,5 @@
module Sunrise
module FileUpload
VERSION = "0.1.2".freeze
VERSION = "0.1.3".freeze
end
end
7 changes: 5 additions & 2 deletions lib/sunrise/file_upload/view_helper.rb
Expand Up @@ -44,8 +44,11 @@ def fileupload_script(element_id, value = nil, options = {})
formatted_options = options.inspect.gsub('=>', ':')
js = [ "new qq.FileUploaderInput(#{formatted_options});" ]

if value && !value.new_record?
js << "qq.FileUploader.instances['#{element_id}']._updatePreview(#{value.to_json});"
if value
Array.wrap(value).each do |asset|
next unless asset.persisted?
js << "qq.FileUploader.instances['#{element_id}']._updatePreview(#{asset.to_json});"
end
end

"$(document).ready(function(){ #{js.join} });"
Expand Down
58 changes: 14 additions & 44 deletions sunrise-file-upload.gemspec
@@ -1,50 +1,20 @@
# Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "sunrise/file_upload/version"

Gem::Specification.new do |s|
s.name = %q{sunrise-file-upload}
s.version = "0.1.2"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.name = "sunrise-file-upload"
s.version = Sunrise::FileUpload::VERSION.dup
s.platform = Gem::Platform::RUBY
s.summary = "Rails HTML5 FileUpload helpers"
s.description = "Sunrise is a Aimbulance CMS"
s.authors = ["Igor Galeta", "Pavlo Galeta"]
s.date = %q{2011-05-23}
s.description = %q{Sunrise is a Aimbulance CMS}
s.email = %q{galeta.igor@gmail.com}
s.extra_rdoc_files = [
"README.rdoc"
]
s.files = [
"README.rdoc",
"Rakefile",
"lib/generators/sunrise/file_upload/USAGE",
"lib/generators/sunrise/file_upload/install_generator.rb",
"lib/generators/sunrise/file_upload/templates/fileuploader-input.js",
"lib/sunrise-file-upload.rb",
"lib/sunrise/file_upload.rb",
"lib/sunrise/file_upload/active_record.rb",
"lib/sunrise/file_upload/callbacks.rb",
"lib/sunrise/file_upload/engine.rb",
"lib/sunrise/file_upload/form_builder.rb",
"lib/sunrise/file_upload/http.rb",
"lib/sunrise/file_upload/manager.rb",
"lib/sunrise/file_upload/request.rb",
"lib/sunrise/file_upload/version.rb",
"lib/sunrise/file_upload/view_helper.rb"
]
s.homepage = %q{https://github.com/galetahub/sunrise-file-upload}
s.email = "galeta.igor@gmail.com"
s.rubyforge_project = "sunrise-core"
s.homepage = "https://github.com/galetahub/sunrise-file-upload"

s.files = Dir["{app,lib,config}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"]
s.test_files = Dir["{spec}/**/*"]
s.extra_rdoc_files = ["README.rdoc"]
s.require_paths = ["lib"]
s.rubygems_version = %q{1.6.2}
s.summary = %q{Rails FileUpload}

if s.respond_to? :specification_version then
s.specification_version = 3

if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
else
end
else
end
end

0 comments on commit 0829742

Please sign in to comment.