dropzone_input 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +55 -0
- data/Rakefile +29 -0
- data/app/views/dropzone_input/_dropzone.html.erb +12 -0
- data/lib/dropzone_input.rb +7 -0
- data/lib/dropzone_input/engine.rb +9 -0
- data/lib/dropzone_input/helpers.rb +24 -0
- data/lib/dropzone_input/version.rb +5 -0
- metadata +71 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2b6c88928b59aae6ea99b57c341d4b0be5804bfd4e6c3b9ae1627ff06a31ade9
|
4
|
+
data.tar.gz: '083f0bafaad00984a5ad416fe83ae1f8ab10dbd26ae64c9b8b624ffefbe1b818'
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e4113b589dfbe38c9740cf061e37639627afb7155ce5a8f7ea08a3b824b9d4a4584963ee13ef490a963af2bb305a54a7f815f4332f562a090595bd19c90b25d8
|
7
|
+
data.tar.gz: db76a2c6297fb2cde4b7ad9db4f266a6d1375fb81cc0ffecf6cd3c7d101f3de03341b4eebbdb2517b12348173c1989ed4cc5f85f304063f862f83eec5721ac00
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2020 Trae Robrock
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# Dropzone Input
|
2
|
+
|
3
|
+
A Rails helper and Stimulus Controller that makes adding dropzone to a Rails form dead simple.
|
4
|
+
|
5
|
+
```erb
|
6
|
+
<%= form_with(model: User.new) do |form| %>
|
7
|
+
<%= dropzone form, :image,
|
8
|
+
file_success_event: 'USER_FILE_UPLOADED',
|
9
|
+
queue_complete_event: 'USER_FILE_UPLOAD_DONE' %>
|
10
|
+
<% end %>
|
11
|
+
```
|
12
|
+
|
13
|
+
*NOTE:* This was built for the specific use in https://darkroom.tech and many of the pieces (like
|
14
|
+
specific styles, etc) will be non-configurable at the moment. We will work to generalize this over
|
15
|
+
time and *pull requests are welcome* and will be reviewed quickly.
|
16
|
+
|
17
|
+
## Installation
|
18
|
+
|
19
|
+
Add to your Gemfile
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
gem 'dropzone_input'
|
23
|
+
```
|
24
|
+
|
25
|
+
```sh
|
26
|
+
bundle install
|
27
|
+
yarn add dropzone # If you don't already have this
|
28
|
+
yarn add @darkroom-com/dropzone-input
|
29
|
+
```
|
30
|
+
|
31
|
+
## Development
|
32
|
+
|
33
|
+
To develop this locally you can update your Gemfile to
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
gem 'dropzone_input', path: 'PATH_TO_PROJECT'
|
37
|
+
```
|
38
|
+
|
39
|
+
In this project run
|
40
|
+
|
41
|
+
```sh
|
42
|
+
yarn link
|
43
|
+
```
|
44
|
+
|
45
|
+
In your app project run
|
46
|
+
|
47
|
+
```sh
|
48
|
+
yarn add @darkroom-com/dropzone-input
|
49
|
+
```
|
50
|
+
|
51
|
+
To auto-recompile this project, run
|
52
|
+
|
53
|
+
```sh
|
54
|
+
yarn run dev
|
55
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'RailsPing'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
load 'rails/tasks/statistics.rake'
|
18
|
+
|
19
|
+
require 'bundler/gem_tasks'
|
20
|
+
|
21
|
+
require 'rake/testtask'
|
22
|
+
|
23
|
+
Rake::TestTask.new(:test) do |t|
|
24
|
+
t.libs << 'test'
|
25
|
+
t.pattern = 'test/**/*_test.rb'
|
26
|
+
t.verbose = false
|
27
|
+
end
|
28
|
+
|
29
|
+
task default: :test
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<%= form.file_field field, direct_upload: true, data: { target: 'dropzone.input' } %>
|
2
|
+
<div class="dz-default dz-message">
|
3
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
4
|
+
<svg enable-background="new 0 0 72 43.2" version="1.1" viewBox="0 0 72 43.2" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" class="inline-block w-16 mb-1">
|
5
|
+
<style type="text/css">
|
6
|
+
.st0{fill:none;stroke:#424443;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;}
|
7
|
+
</style>
|
8
|
+
<polyline class="st0" points="28.3 26.3 34.4 20.3 40.4 26.3 34.4 20.3 34.4 42.3"/>
|
9
|
+
<path class="st0" d="m22.1 33c-6.6 0-11.9-5.3-11.9-11.9s5.4-11.9 11.9-11.9c2.4-4.9 7.4-8.3 13.3-8.3 7.6 0 13.9 5.8 14.7 13.2 0.7-0.1 1.3-0.2 2-0.2 5.3 0 9.5 4.3 9.5 9.5s-4.1 9.6-9.4 9.6h-5.6"/>
|
10
|
+
</svg>
|
11
|
+
<h1 class="text-xl text-gray-700">Upload</h1>
|
12
|
+
</div>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DropzoneInput
|
4
|
+
module Helpers
|
5
|
+
def dropzone(form, field, options = {}) # rubocop:disable Style/OptionHash
|
6
|
+
class_list = options.delete(:class)
|
7
|
+
class_list = ['dropzone', class_list].compact.join(' ')
|
8
|
+
|
9
|
+
options[:max_file_size] /= 1.megabyte if options[:max_file_size]
|
10
|
+
|
11
|
+
data = {
|
12
|
+
controller: 'dropzone',
|
13
|
+
dropzone_accepted_files: ActiveStorage.variable_content_types.join(',')
|
14
|
+
}
|
15
|
+
%i( max_files max_file_size file_success_event queue_complete_event ).each do |key|
|
16
|
+
data["dropzone_#{key}".to_sym] = options.delete(key) if options.key?(key)
|
17
|
+
end
|
18
|
+
|
19
|
+
content_tag :div, options.merge(class: class_list, data: data) do
|
20
|
+
render partial: 'dropzone_input/dropzone', locals: { form: form, field: field }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dropzone_input
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Trae Robrock
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-07-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '7'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '5'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '7'
|
33
|
+
description: A rails helper to easily add Dropzone to forms.
|
34
|
+
email:
|
35
|
+
- trobrock@gmail.com
|
36
|
+
executables: []
|
37
|
+
extensions: []
|
38
|
+
extra_rdoc_files: []
|
39
|
+
files:
|
40
|
+
- MIT-LICENSE
|
41
|
+
- README.md
|
42
|
+
- Rakefile
|
43
|
+
- app/views/dropzone_input/_dropzone.html.erb
|
44
|
+
- lib/dropzone_input.rb
|
45
|
+
- lib/dropzone_input/engine.rb
|
46
|
+
- lib/dropzone_input/helpers.rb
|
47
|
+
- lib/dropzone_input/version.rb
|
48
|
+
homepage: https://github.com/darkroom-com/dropzone_input
|
49
|
+
licenses:
|
50
|
+
- MIT
|
51
|
+
metadata: {}
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options: []
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
requirements: []
|
67
|
+
rubygems_version: 3.1.2
|
68
|
+
signing_key:
|
69
|
+
specification_version: 4
|
70
|
+
summary: A rails helper to easily add Dropzone to forms.
|
71
|
+
test_files: []
|