fileclip 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +5 -1
- data/Gemfile.lock +116 -1
- data/README.md +37 -3
- data/Rakefile +8 -2
- data/fileclip.gemspec +12 -4
- data/lib/fileclip.rb +117 -0
- data/lib/fileclip/version.rb +1 -1
- metadata +103 -6
- data/VERSION +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a311561e6048d53367ee57f3cb9165b36e41567e
|
4
|
+
data.tar.gz: beb839f1783d207d72117ca7c7be8787f56ba80a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0df75a25ec21f9abdf48960c62bcb7384cb1f6c47e004a52c9b4ff12ce59b8d2611349709123d2b5b72e51c66305e1cbb68a3a8d149c4f8a37d39a762ba03391
|
7
|
+
data.tar.gz: 75aab020685e28fb4871a49b5cb43d3e8b95e6b185a69a1af68cb18ff31d256b246d91d5ba3a80f4e419b31ed263c40179695a55cf30f7c40974e9bdde0212d2
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,10 +1,125 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
fileclip (0.0.2)
|
5
|
+
paperclip
|
6
|
+
paperclip (>= 3.3.0)
|
7
|
+
railties (>= 3.0)
|
8
|
+
|
1
9
|
GEM
|
2
10
|
remote: http://rubygems.org/
|
3
11
|
specs:
|
12
|
+
actionmailer (3.2.14)
|
13
|
+
actionpack (= 3.2.14)
|
14
|
+
mail (~> 2.5.4)
|
15
|
+
actionpack (3.2.14)
|
16
|
+
activemodel (= 3.2.14)
|
17
|
+
activesupport (= 3.2.14)
|
18
|
+
builder (~> 3.0.0)
|
19
|
+
erubis (~> 2.7.0)
|
20
|
+
journey (~> 1.0.4)
|
21
|
+
rack (~> 1.4.5)
|
22
|
+
rack-cache (~> 1.2)
|
23
|
+
rack-test (~> 0.6.1)
|
24
|
+
sprockets (~> 2.2.1)
|
25
|
+
activemodel (3.2.14)
|
26
|
+
activesupport (= 3.2.14)
|
27
|
+
builder (~> 3.0.0)
|
28
|
+
activerecord (3.2.14)
|
29
|
+
activemodel (= 3.2.14)
|
30
|
+
activesupport (= 3.2.14)
|
31
|
+
arel (~> 3.0.2)
|
32
|
+
tzinfo (~> 0.3.29)
|
33
|
+
activeresource (3.2.14)
|
34
|
+
activemodel (= 3.2.14)
|
35
|
+
activesupport (= 3.2.14)
|
36
|
+
activesupport (3.2.14)
|
37
|
+
i18n (~> 0.6, >= 0.6.4)
|
38
|
+
multi_json (~> 1.0)
|
39
|
+
arel (3.0.2)
|
40
|
+
builder (3.0.4)
|
41
|
+
byebug (1.6.1)
|
42
|
+
columnize (~> 0.3.6)
|
43
|
+
debugger-linecache (~> 1.2.0)
|
44
|
+
climate_control (0.0.3)
|
45
|
+
activesupport (>= 3.0)
|
46
|
+
cocaine (0.5.1)
|
47
|
+
climate_control (>= 0.0.3, < 1.0)
|
48
|
+
columnize (0.3.6)
|
49
|
+
debugger-linecache (1.2.0)
|
50
|
+
diff-lcs (1.2.4)
|
51
|
+
erubis (2.7.0)
|
52
|
+
hike (1.2.3)
|
53
|
+
i18n (0.6.4)
|
54
|
+
journey (1.0.4)
|
55
|
+
json (1.8.0)
|
56
|
+
mail (2.5.4)
|
57
|
+
mime-types (~> 1.16)
|
58
|
+
treetop (~> 1.4.8)
|
59
|
+
mime-types (1.23)
|
60
|
+
multi_json (1.7.7)
|
61
|
+
paperclip (3.5.0)
|
62
|
+
activemodel (>= 3.0.0)
|
63
|
+
activesupport (>= 3.0.0)
|
64
|
+
cocaine (~> 0.5.0)
|
65
|
+
mime-types
|
66
|
+
polyglot (0.3.3)
|
67
|
+
rack (1.4.5)
|
68
|
+
rack-cache (1.2)
|
69
|
+
rack (>= 0.4)
|
70
|
+
rack-ssl (1.3.3)
|
71
|
+
rack
|
72
|
+
rack-test (0.6.2)
|
73
|
+
rack (>= 1.0)
|
74
|
+
rails (3.2.14)
|
75
|
+
actionmailer (= 3.2.14)
|
76
|
+
actionpack (= 3.2.14)
|
77
|
+
activerecord (= 3.2.14)
|
78
|
+
activeresource (= 3.2.14)
|
79
|
+
activesupport (= 3.2.14)
|
80
|
+
bundler (~> 1.0)
|
81
|
+
railties (= 3.2.14)
|
82
|
+
railties (3.2.14)
|
83
|
+
actionpack (= 3.2.14)
|
84
|
+
activesupport (= 3.2.14)
|
85
|
+
rack-ssl (~> 1.3.2)
|
86
|
+
rake (>= 0.8.7)
|
87
|
+
rdoc (~> 3.4)
|
88
|
+
thor (>= 0.14.6, < 2.0)
|
4
89
|
rake (10.1.0)
|
90
|
+
rdoc (3.12.2)
|
91
|
+
json (~> 1.4)
|
92
|
+
rest-client (1.6.7)
|
93
|
+
mime-types (>= 1.16)
|
94
|
+
rspec (2.14.1)
|
95
|
+
rspec-core (~> 2.14.0)
|
96
|
+
rspec-expectations (~> 2.14.0)
|
97
|
+
rspec-mocks (~> 2.14.0)
|
98
|
+
rspec-core (2.14.4)
|
99
|
+
rspec-expectations (2.14.0)
|
100
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
101
|
+
rspec-mocks (2.14.1)
|
102
|
+
sprockets (2.2.2)
|
103
|
+
hike (~> 1.2)
|
104
|
+
multi_json (~> 1.0)
|
105
|
+
rack (~> 1.0)
|
106
|
+
tilt (~> 1.1, != 1.3.0)
|
107
|
+
sqlite3 (1.3.7)
|
108
|
+
thor (0.18.1)
|
109
|
+
tilt (1.4.1)
|
110
|
+
treetop (1.4.14)
|
111
|
+
polyglot
|
112
|
+
polyglot (>= 0.3.1)
|
113
|
+
tzinfo (0.3.37)
|
5
114
|
|
6
115
|
PLATFORMS
|
7
116
|
ruby
|
8
117
|
|
9
118
|
DEPENDENCIES
|
10
|
-
|
119
|
+
byebug
|
120
|
+
fileclip!
|
121
|
+
paperclip
|
122
|
+
rails (= 3.2.14)
|
123
|
+
rest-client
|
124
|
+
rspec
|
125
|
+
sqlite3
|
data/README.md
CHANGED
@@ -1,8 +1,42 @@
|
|
1
1
|
fileclip
|
2
2
|
========
|
3
3
|
|
4
|
-
A FilePicker / PaperClip mashup. Use Filepicker for uploads and paperclip to process them.
|
5
|
-
|
4
|
+
A FilePicker / PaperClip mashup. Use Filepicker for uploads and paperclip to process them.
|
6
5
|
|
7
6
|
TODO:
|
8
|
-
|
7
|
+
|
8
|
+
Backend:
|
9
|
+
* It should be unobtrusive. Normal paperclip uploads should work
|
10
|
+
* If filepicker_url is present it should process it
|
11
|
+
* If filepicker_url changes, it should process it
|
12
|
+
* First version should be minimal
|
13
|
+
* Handle skipping validations of attachment seamlessly
|
14
|
+
* Configuration accepts config key
|
15
|
+
|
16
|
+
Frontend:
|
17
|
+
* Allow overriding of filepicker options
|
18
|
+
* Fileclip link to automatically set fields and call it
|
19
|
+
* link should act like a normal link helper
|
20
|
+
* Minimal amount of JS
|
21
|
+
* Loader for filepicker js if needed
|
22
|
+
* Eliminate need for jQuery
|
23
|
+
|
24
|
+
Extra features:
|
25
|
+
* Work with Delayed Paperclip
|
26
|
+
* Work with Resque
|
27
|
+
* Work with DelayedJob
|
28
|
+
* Work with Sidekiq
|
29
|
+
* Handle multiple attachments on the same model
|
30
|
+
* Fallback to filepicker url if paperclip url doesn't exist
|
31
|
+
* Filepicker converts to match paperclip styles
|
32
|
+
* Configure Filepicker options
|
33
|
+
* FilePicker droppane support
|
34
|
+
|
35
|
+
#### Current FilePicker options hardcoded
|
36
|
+
* mimetypes are image/*
|
37
|
+
* container modal
|
38
|
+
* service Computer
|
39
|
+
* maxsize is 20 mb
|
40
|
+
* location is S3
|
41
|
+
* path is "/fileclip"
|
42
|
+
* access is public
|
data/Rakefile
CHANGED
data/fileclip.gemspec
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "fileclip"
|
3
|
-
s.version = "0.0.
|
3
|
+
s.version = "0.0.3"
|
4
4
|
|
5
5
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
6
6
|
s.authors = ["Scott Carleton"]
|
7
7
|
s.date = "2013-07-26"
|
8
|
-
s.description = "
|
8
|
+
s.description = "A FilePicker / PaperClip mashup. Use Filepicker for uploads and paperclip to process them."
|
9
9
|
s.email = "scott@artsicle.com"
|
10
10
|
s.extra_rdoc_files = [
|
11
11
|
"LICENSE",
|
@@ -18,7 +18,6 @@ Gem::Specification.new do |s|
|
|
18
18
|
"LICENSE",
|
19
19
|
"README.md",
|
20
20
|
"Rakefile",
|
21
|
-
"VERSION",
|
22
21
|
"fileclip.gemspec",
|
23
22
|
"lib/fileclip.rb",
|
24
23
|
"lib/fileclip/version.rb"
|
@@ -29,6 +28,15 @@ Gem::Specification.new do |s|
|
|
29
28
|
s.rubygems_version = "2.0.3"
|
30
29
|
s.summary = "A FilePicker / PaperClip mashup."
|
31
30
|
|
32
|
-
s.add_dependency
|
31
|
+
s.add_dependency 'paperclip', [">= 3.3.0"]
|
32
|
+
|
33
|
+
s.add_development_dependency "rspec"
|
34
|
+
s.add_development_dependency 'sqlite3'
|
35
|
+
s.add_development_dependency "rails"
|
36
|
+
s.add_development_dependency "paperclip"
|
37
|
+
s.add_development_dependency "rest-client"
|
38
|
+
s.add_runtime_dependency(%q<railties>, [">= 3.0"])
|
39
|
+
|
40
|
+
s.add_runtime_dependency "paperclip"
|
33
41
|
end
|
34
42
|
|
data/lib/fileclip.rb
CHANGED
@@ -0,0 +1,117 @@
|
|
1
|
+
# TODO
|
2
|
+
#
|
3
|
+
# Allowance for normal attached images through file_field:
|
4
|
+
# only do attachment validation if it's there if remote url is not present
|
5
|
+
# only do process_in_background if remote_url is not present
|
6
|
+
#
|
7
|
+
# Expose FilePicked to all classes that have Paperclip images
|
8
|
+
#
|
9
|
+
# Handle multiple attachments in single model
|
10
|
+
# Crux of this is finding the name of the attachment we're dealing with
|
11
|
+
#
|
12
|
+
# Fallback if none are defined
|
13
|
+
#
|
14
|
+
# What can we separate out into it's own class
|
15
|
+
# What should be a part of attachment
|
16
|
+
#
|
17
|
+
# Migration generator
|
18
|
+
#
|
19
|
+
# Configuration to take Filepicker API key
|
20
|
+
#
|
21
|
+
# Javascript inclusion
|
22
|
+
#
|
23
|
+
# Add delayed aspect
|
24
|
+
#
|
25
|
+
# Queue job for image assignment
|
26
|
+
require "fileclip/configuration"
|
27
|
+
require 'fileclip/action_view/helpers'
|
28
|
+
require 'fileclip/railtie'
|
29
|
+
require 'rest-client'
|
30
|
+
|
31
|
+
module FileClip
|
32
|
+
|
33
|
+
module Glue
|
34
|
+
def self.included(base)
|
35
|
+
base.extend(ClassMethods)
|
36
|
+
base.send :include, InstanceMethods
|
37
|
+
base.add_callbacks
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
module ClassMethods
|
42
|
+
def add_callbacks
|
43
|
+
attr_accessible :filepicker_url
|
44
|
+
|
45
|
+
# if respond_to?(:after_commit)
|
46
|
+
after_commit :update_from_filepicker!
|
47
|
+
# else
|
48
|
+
# after_save :update_from_filepicker!
|
49
|
+
# end
|
50
|
+
|
51
|
+
# TODO:
|
52
|
+
# skip validates_attachment_presence if filepicker url present
|
53
|
+
# Save without this particular vaildation
|
54
|
+
end
|
55
|
+
|
56
|
+
def paperclip_definitions
|
57
|
+
@paperclip_definitions ||= if respond_to? :attachment_definitions
|
58
|
+
attachment_definitions
|
59
|
+
else
|
60
|
+
Paperclip::Tasks::Attachments.definitions_for(self)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
module InstanceMethods
|
66
|
+
|
67
|
+
# TODO: can't handle multiples, just first
|
68
|
+
def attachment_name
|
69
|
+
@attachment_name ||= self.class.paperclip_definitions.keys.first
|
70
|
+
end
|
71
|
+
|
72
|
+
def attachment_object
|
73
|
+
self.send(attachment_name)
|
74
|
+
end
|
75
|
+
|
76
|
+
def update_from_filepicker!
|
77
|
+
process_from_filepicker if update_from_filepicker?
|
78
|
+
end
|
79
|
+
|
80
|
+
def process_from_filepicker
|
81
|
+
self.class.skip_callback :commit, :after, :update_from_filepicker!
|
82
|
+
self.send(:"#{attachment_name}=", URI.parse(filepicker_url))
|
83
|
+
self.set_metadata
|
84
|
+
self.save
|
85
|
+
self.class.set_callback :commit, :after, :update_from_filepicker!
|
86
|
+
end
|
87
|
+
|
88
|
+
def set_metadata
|
89
|
+
metadata = JSON.parse(::RestClient.get filepicker_url + "/metadata")
|
90
|
+
|
91
|
+
self.send(:"#{attachment_name}_content_type=", metadata["mimetype"])
|
92
|
+
self.send(:"#{attachment_name}_file_name=", metadata["filename"])
|
93
|
+
self.send(:"#{attachment_name}_file_size=", metadata["size"])
|
94
|
+
end
|
95
|
+
|
96
|
+
def update_from_filepicker?
|
97
|
+
filepicker_url_previously_changed? &&
|
98
|
+
filepicker_url.present? &&
|
99
|
+
!filepicker_only?
|
100
|
+
end
|
101
|
+
|
102
|
+
def filepicker_url_not_present?
|
103
|
+
!filepicker_url.present?
|
104
|
+
end
|
105
|
+
|
106
|
+
def filepicker_url_previously_changed?
|
107
|
+
previous_changes.keys.include?('filepicker_url')
|
108
|
+
end
|
109
|
+
|
110
|
+
# To be overridden in model if specific logic for not
|
111
|
+
# processing the image
|
112
|
+
def filepicker_only?
|
113
|
+
false
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
data/lib/fileclip/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fileclip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Carleton
|
@@ -11,7 +11,105 @@ cert_chain: []
|
|
11
11
|
date: 2013-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: paperclip
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.3.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.3.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sqlite3
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: paperclip
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rest-client
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: railties
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: paperclip
|
15
113
|
requirement: !ruby/object:Gem::Requirement
|
16
114
|
requirements:
|
17
115
|
- - '>='
|
@@ -24,8 +122,8 @@ dependencies:
|
|
24
122
|
- - '>='
|
25
123
|
- !ruby/object:Gem::Version
|
26
124
|
version: '0'
|
27
|
-
description:
|
28
|
-
|
125
|
+
description: A FilePicker / PaperClip mashup. Use Filepicker for uploads and paperclip
|
126
|
+
to process them.
|
29
127
|
email: scott@artsicle.com
|
30
128
|
executables: []
|
31
129
|
extensions: []
|
@@ -39,7 +137,6 @@ files:
|
|
39
137
|
- LICENSE
|
40
138
|
- README.md
|
41
139
|
- Rakefile
|
42
|
-
- VERSION
|
43
140
|
- fileclip.gemspec
|
44
141
|
- lib/fileclip.rb
|
45
142
|
- lib/fileclip/version.rb
|
@@ -63,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
63
160
|
version: '0'
|
64
161
|
requirements: []
|
65
162
|
rubyforge_project:
|
66
|
-
rubygems_version: 2.0.
|
163
|
+
rubygems_version: 2.0.6
|
67
164
|
signing_key:
|
68
165
|
specification_version: 4
|
69
166
|
summary: A FilePicker / PaperClip mashup.
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.0.1
|