jack_up 0.1.1 → 0.2.0
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/LICENSE +1 -1
- data/README.md +18 -6
- data/Rakefile +3 -13
- data/lib/assets/javascripts/jack_up/drag_and_drop.coffee +5 -4
- data/lib/assets/javascripts/jack_up/file_uploader.coffee +1 -9
- data/lib/jack_up/version.rb +1 -1
- metadata +16 -21
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 32677dc1d4a6172fccd5051dbcf567217786e7e2
|
4
|
+
data.tar.gz: 902c1086a3e02f9be386c178245d252d9395463d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e448f3b4bace51a50c8f2357fe90b69dfcb8f782e2b23eb8c7809bf7c3e442f1e576a36bf6f9616d3cd6ef178418b670ee6da2711011c295c764b645c7db6d43
|
7
|
+
data.tar.gz: 57bc93c243af535df9fac0d52aa49aeea9cd7d4aaae902a7088efc88f53d0fa0a504a7b969713b5620379655cb82218e4e47ba13dd73dbceccadc788580a738b
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -23,7 +23,7 @@ Modify your `application.js` manifest:
|
|
23
23
|
|
24
24
|
### Requirements
|
25
25
|
|
26
|
-
Rails
|
26
|
+
Rails 4.0+, CoffeeScript, and both jQuery and
|
27
27
|
Underscore.js included in your `application.js` manifest.
|
28
28
|
|
29
29
|
### Usage
|
@@ -99,13 +99,12 @@ uploads.
|
|
99
99
|
# app/models/asset.rb
|
100
100
|
class Asset < ActiveRecord::Base
|
101
101
|
has_attached_file :photo
|
102
|
-
attr_accessible :photo
|
103
102
|
end
|
104
103
|
|
105
104
|
# app/controllers/assets_controller.rb
|
106
105
|
class AssetsController < ApplicationController
|
107
106
|
def create
|
108
|
-
@asset = Asset.new(photo:
|
107
|
+
@asset = Asset.new(photo: asset_params[:file])
|
109
108
|
|
110
109
|
if @asset.save
|
111
110
|
render json: @asset
|
@@ -113,6 +112,12 @@ class AssetsController < ApplicationController
|
|
113
112
|
head :bad_request
|
114
113
|
end
|
115
114
|
end
|
115
|
+
|
116
|
+
private
|
117
|
+
|
118
|
+
def asset_params
|
119
|
+
params.permit(:file)
|
120
|
+
end
|
116
121
|
end
|
117
122
|
```
|
118
123
|
|
@@ -125,6 +130,8 @@ This view code could be placed anywhere for immediate uploading:
|
|
125
130
|
%input.standard-attachment{ name: 'standard_attachment', accept: 'image/*', type: :file, multiple: :multiple }
|
126
131
|
```
|
127
132
|
|
133
|
+
Anything with a data-placeholder attribute will be hidden when an file is successfully dropped.
|
134
|
+
|
128
135
|
If attaching assets to a different model, additionally use:
|
129
136
|
|
130
137
|
```ruby
|
@@ -132,7 +139,6 @@ If attaching assets to a different model, additionally use:
|
|
132
139
|
class Post < ActiveRecord::Base
|
133
140
|
has_many :assets, dependent: :destroy
|
134
141
|
|
135
|
-
attr_accessible :asset_ids, :assets_attributes
|
136
142
|
accepts_nested_attributes_for :assets
|
137
143
|
end
|
138
144
|
|
@@ -144,10 +150,16 @@ class PostsController < ApplicationController
|
|
144
150
|
end
|
145
151
|
|
146
152
|
def create
|
147
|
-
@post = Post.new(
|
153
|
+
@post = Post.new(post_params)
|
148
154
|
@post.save
|
149
155
|
respond_with @post
|
150
156
|
end
|
157
|
+
|
158
|
+
private
|
159
|
+
|
160
|
+
def post_params
|
161
|
+
params.require(:post).permit(:asset_ids, :assets_attributes)
|
162
|
+
end
|
151
163
|
end
|
152
164
|
```
|
153
165
|
|
@@ -185,4 +197,4 @@ jackUp.on "upload:success", (e, options) ->
|
|
185
197
|
|
186
198
|
## License
|
187
199
|
|
188
|
-
JackUp is copyright 2012 Josh Steiner, Josh Clayton, and thoughtbot, inc., and may be redistributed under the terms specified in the LICENSE file.
|
200
|
+
JackUp is copyright 2012-2013 Josh Steiner, Josh Clayton, and thoughtbot, inc., and may be redistributed under the terms specified in the LICENSE file.
|
data/Rakefile
CHANGED
@@ -20,21 +20,11 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|
20
20
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
21
|
end
|
22
22
|
|
23
|
-
APP_RAKEFILE = File.expand_path("../
|
23
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
24
24
|
load 'rails/tasks/engine.rake'
|
25
25
|
|
26
|
-
|
27
|
-
|
28
26
|
Bundler::GemHelper.install_tasks
|
29
27
|
|
30
|
-
|
31
|
-
|
32
|
-
Rake::TestTask.new(:test) do |t|
|
33
|
-
t.libs << 'lib'
|
34
|
-
t.libs << 'test'
|
35
|
-
t.pattern = 'test/**/*_test.rb'
|
36
|
-
t.verbose = false
|
37
|
-
end
|
38
|
-
|
28
|
+
RSpec::Core::RakeTask.new(:spec)
|
39
29
|
|
40
|
-
task :default => :
|
30
|
+
task :default => :spec
|
@@ -5,20 +5,21 @@ ignoreEvent = (event) ->
|
|
5
5
|
class @JackUp.DragAndDrop
|
6
6
|
constructor: (@droppableElement, @processor) ->
|
7
7
|
@droppableElement
|
8
|
-
.bind("dragenter", @
|
8
|
+
.bind("dragenter", @_dragEnter)
|
9
|
+
.bind("dragleave", @_dragLeave)
|
9
10
|
.bind("drop", @_drop)
|
10
|
-
.bind("drop", @_dragOut)
|
11
11
|
|
12
|
-
|
12
|
+
_dragEnter: (event) =>
|
13
13
|
ignoreEvent event
|
14
14
|
event.originalEvent.dataTransfer.dropEffect = "copy"
|
15
15
|
@droppableElement.addClass("hover")
|
16
16
|
|
17
|
-
|
17
|
+
_dragLeave: (event) =>
|
18
18
|
ignoreEvent event
|
19
19
|
@droppableElement.removeClass("hover")
|
20
20
|
|
21
21
|
_drop: (event) =>
|
22
22
|
ignoreEvent event
|
23
|
+
@droppableElement.removeClass("hover")
|
23
24
|
@droppableElement.find('[data-placeholder]').hide()
|
24
25
|
@processor.processFilesForEvent(event)
|
@@ -1,11 +1,3 @@
|
|
1
|
-
railsCSRFData = ->
|
2
|
-
csrfParam = $('meta[name=csrf-param]').attr('content')
|
3
|
-
csrfToken = $('meta[name=csrf-token]').attr('content')
|
4
|
-
|
5
|
-
formData = {}
|
6
|
-
formData[csrfParam] = csrfToken
|
7
|
-
JSON.stringify formData
|
8
|
-
|
9
1
|
class @JackUp.FileUploader
|
10
2
|
constructor: (@options) ->
|
11
3
|
@path = @options.path
|
@@ -49,7 +41,7 @@ class @JackUp.FileUploader
|
|
49
41
|
|
50
42
|
xhr.setRequestHeader 'Content-Type', file.type
|
51
43
|
xhr.setRequestHeader 'X-File-Name', file.name
|
52
|
-
xhr.setRequestHeader 'X-
|
44
|
+
xhr.setRequestHeader 'X-CSRF-Token', $('meta[name=csrf-token]').attr('content')
|
53
45
|
|
54
46
|
@trigger 'upload:start', file: file
|
55
47
|
xhr.send file
|
data/lib/jack_up/version.rb
CHANGED
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jack_up
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Josh Steiner
|
@@ -10,24 +9,22 @@ authors:
|
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date:
|
12
|
+
date: 2014-07-31 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: rails
|
17
16
|
requirement: !ruby/object:Gem::Requirement
|
18
|
-
none: false
|
19
17
|
requirements:
|
20
|
-
- - ~>
|
18
|
+
- - "~>"
|
21
19
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
20
|
+
version: '4.0'
|
23
21
|
type: :runtime
|
24
22
|
prerelease: false
|
25
23
|
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
none: false
|
27
24
|
requirements:
|
28
|
-
- - ~>
|
25
|
+
- - "~>"
|
29
26
|
- !ruby/object:Gem::Version
|
30
|
-
version: '
|
27
|
+
version: '4.0'
|
31
28
|
description: Easy AJAX file uploading in Rails
|
32
29
|
email:
|
33
30
|
- josh@jsteiner.me
|
@@ -36,42 +33,40 @@ executables: []
|
|
36
33
|
extensions: []
|
37
34
|
extra_rdoc_files: []
|
38
35
|
files:
|
36
|
+
- LICENSE
|
37
|
+
- README.md
|
38
|
+
- Rakefile
|
39
|
+
- lib/assets/javascripts/jack_up.js
|
39
40
|
- lib/assets/javascripts/jack_up/base.coffee
|
40
41
|
- lib/assets/javascripts/jack_up/drag_and_drop.coffee
|
41
42
|
- lib/assets/javascripts/jack_up/events.coffee
|
42
43
|
- lib/assets/javascripts/jack_up/file_uploader.coffee
|
43
44
|
- lib/assets/javascripts/jack_up/jquery.coffee
|
44
45
|
- lib/assets/javascripts/jack_up/processor.coffee
|
45
|
-
- lib/
|
46
|
+
- lib/jack_up.rb
|
46
47
|
- lib/jack_up/engine.rb
|
47
48
|
- lib/jack_up/version.rb
|
48
|
-
- lib/jack_up.rb
|
49
|
-
- LICENSE
|
50
|
-
- Rakefile
|
51
|
-
- README.md
|
52
49
|
homepage: http://github.com/thoughtbot/jack_up
|
53
50
|
licenses: []
|
51
|
+
metadata: {}
|
54
52
|
post_install_message:
|
55
53
|
rdoc_options: []
|
56
54
|
require_paths:
|
57
55
|
- lib
|
58
56
|
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
-
none: false
|
60
57
|
requirements:
|
61
|
-
- -
|
58
|
+
- - ">="
|
62
59
|
- !ruby/object:Gem::Version
|
63
60
|
version: '0'
|
64
61
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
62
|
requirements:
|
67
|
-
- -
|
63
|
+
- - ">="
|
68
64
|
- !ruby/object:Gem::Version
|
69
65
|
version: '0'
|
70
66
|
requirements: []
|
71
67
|
rubyforge_project:
|
72
|
-
rubygems_version:
|
68
|
+
rubygems_version: 2.2.2
|
73
69
|
signing_key:
|
74
|
-
specification_version:
|
70
|
+
specification_version: 4
|
75
71
|
summary: Easy AJAX file uploading in Rails
|
76
72
|
test_files: []
|
77
|
-
has_rdoc:
|