simple_form_bs5_file_input 0.0.3 → 0.0.6
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 +4 -4
- data/.gitignore +2 -0
- data/Gemfile.lock +110 -87
- data/README.md +15 -4
- data/lib/has_one_attached_deletable.rb +2 -2
- data/lib/simple_form_bs5_file_input/single_deletable_file_input.rb +8 -6
- data/lib/simple_form_bs5_file_input/version.rb +1 -1
- data/pkg/simple_form_bs5_file_input-0.0.3.gem +0 -0
- metadata +8 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9b00aca895432b5130fad571666763a588ed10615d80319ae50a797eac704031
|
|
4
|
+
data.tar.gz: 167cc07867256c4b1bf2043578b9cd158a4b9356982eef823e54c7cf48e39d3a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 06acfb0828ebe32f582004073ca34c8d9a136d7dad56f1da3ea22909fd591d70184a6e05415313bb12c8b7fcffe84033700d14906ccfe06044afe384dce17dcb
|
|
7
|
+
data.tar.gz: 6d243229507b7e0fdee145b2c3d156c7d6aaefb3b3628b51d7a4537a5ba76fd113c2bfd4b47222a8e451a08242925966d7639a8b623778aa9f2c28f364b4a70c
|
data/.gitignore
ADDED
data/Gemfile.lock
CHANGED
|
@@ -1,105 +1,112 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
simple_form_bs5_file_input (0.0.
|
|
4
|
+
simple_form_bs5_file_input (0.0.6)
|
|
5
5
|
rails
|
|
6
6
|
simple_form
|
|
7
7
|
|
|
8
8
|
GEM
|
|
9
9
|
remote: https://rubygems.org/
|
|
10
10
|
specs:
|
|
11
|
-
actioncable (
|
|
12
|
-
actionpack (=
|
|
13
|
-
activesupport (=
|
|
11
|
+
actioncable (7.0.3)
|
|
12
|
+
actionpack (= 7.0.3)
|
|
13
|
+
activesupport (= 7.0.3)
|
|
14
14
|
nio4r (~> 2.0)
|
|
15
15
|
websocket-driver (>= 0.6.1)
|
|
16
|
-
actionmailbox (
|
|
17
|
-
actionpack (=
|
|
18
|
-
activejob (=
|
|
19
|
-
activerecord (=
|
|
20
|
-
activestorage (=
|
|
21
|
-
activesupport (=
|
|
16
|
+
actionmailbox (7.0.3)
|
|
17
|
+
actionpack (= 7.0.3)
|
|
18
|
+
activejob (= 7.0.3)
|
|
19
|
+
activerecord (= 7.0.3)
|
|
20
|
+
activestorage (= 7.0.3)
|
|
21
|
+
activesupport (= 7.0.3)
|
|
22
22
|
mail (>= 2.7.1)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
net-imap
|
|
24
|
+
net-pop
|
|
25
|
+
net-smtp
|
|
26
|
+
actionmailer (7.0.3)
|
|
27
|
+
actionpack (= 7.0.3)
|
|
28
|
+
actionview (= 7.0.3)
|
|
29
|
+
activejob (= 7.0.3)
|
|
30
|
+
activesupport (= 7.0.3)
|
|
28
31
|
mail (~> 2.5, >= 2.5.4)
|
|
32
|
+
net-imap
|
|
33
|
+
net-pop
|
|
34
|
+
net-smtp
|
|
29
35
|
rails-dom-testing (~> 2.0)
|
|
30
|
-
actionpack (
|
|
31
|
-
actionview (=
|
|
32
|
-
activesupport (=
|
|
33
|
-
rack (~> 2.0, >= 2.0
|
|
36
|
+
actionpack (7.0.3)
|
|
37
|
+
actionview (= 7.0.3)
|
|
38
|
+
activesupport (= 7.0.3)
|
|
39
|
+
rack (~> 2.0, >= 2.2.0)
|
|
34
40
|
rack-test (>= 0.6.3)
|
|
35
41
|
rails-dom-testing (~> 2.0)
|
|
36
42
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
|
37
|
-
actiontext (
|
|
38
|
-
actionpack (=
|
|
39
|
-
activerecord (=
|
|
40
|
-
activestorage (=
|
|
41
|
-
activesupport (=
|
|
43
|
+
actiontext (7.0.3)
|
|
44
|
+
actionpack (= 7.0.3)
|
|
45
|
+
activerecord (= 7.0.3)
|
|
46
|
+
activestorage (= 7.0.3)
|
|
47
|
+
activesupport (= 7.0.3)
|
|
48
|
+
globalid (>= 0.6.0)
|
|
42
49
|
nokogiri (>= 1.8.5)
|
|
43
|
-
actionview (
|
|
44
|
-
activesupport (=
|
|
50
|
+
actionview (7.0.3)
|
|
51
|
+
activesupport (= 7.0.3)
|
|
45
52
|
builder (~> 3.1)
|
|
46
53
|
erubi (~> 1.4)
|
|
47
54
|
rails-dom-testing (~> 2.0)
|
|
48
55
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
|
49
|
-
activejob (
|
|
50
|
-
activesupport (=
|
|
56
|
+
activejob (7.0.3)
|
|
57
|
+
activesupport (= 7.0.3)
|
|
51
58
|
globalid (>= 0.3.6)
|
|
52
|
-
activemodel (
|
|
53
|
-
activesupport (=
|
|
54
|
-
activerecord (
|
|
55
|
-
activemodel (=
|
|
56
|
-
activesupport (=
|
|
57
|
-
activestorage (
|
|
58
|
-
actionpack (=
|
|
59
|
-
activejob (=
|
|
60
|
-
activerecord (=
|
|
61
|
-
activesupport (=
|
|
62
|
-
marcel (~> 1.0
|
|
59
|
+
activemodel (7.0.3)
|
|
60
|
+
activesupport (= 7.0.3)
|
|
61
|
+
activerecord (7.0.3)
|
|
62
|
+
activemodel (= 7.0.3)
|
|
63
|
+
activesupport (= 7.0.3)
|
|
64
|
+
activestorage (7.0.3)
|
|
65
|
+
actionpack (= 7.0.3)
|
|
66
|
+
activejob (= 7.0.3)
|
|
67
|
+
activerecord (= 7.0.3)
|
|
68
|
+
activesupport (= 7.0.3)
|
|
69
|
+
marcel (~> 1.0)
|
|
63
70
|
mini_mime (>= 1.1.0)
|
|
64
|
-
activesupport (
|
|
71
|
+
activesupport (7.0.3)
|
|
65
72
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
66
73
|
i18n (>= 1.6, < 2)
|
|
67
74
|
minitest (>= 5.1)
|
|
68
75
|
tzinfo (~> 2.0)
|
|
69
|
-
|
|
70
|
-
autoprefixer-rails (10.3.3.0)
|
|
76
|
+
autoprefixer-rails (10.4.7.0)
|
|
71
77
|
execjs (~> 2)
|
|
72
|
-
bcrypt (3.1.
|
|
73
|
-
bootsnap (1.
|
|
74
|
-
msgpack (~> 1.
|
|
75
|
-
bootstrap (5.1.
|
|
78
|
+
bcrypt (3.1.18)
|
|
79
|
+
bootsnap (1.11.1)
|
|
80
|
+
msgpack (~> 1.2)
|
|
81
|
+
bootstrap (5.1.3)
|
|
76
82
|
autoprefixer-rails (>= 9.1.0)
|
|
77
83
|
popper_js (>= 2.9.3, < 3)
|
|
78
84
|
sassc-rails (>= 2.0.0)
|
|
79
85
|
builder (3.2.4)
|
|
80
|
-
concurrent-ruby (1.1.
|
|
86
|
+
concurrent-ruby (1.1.10)
|
|
81
87
|
crass (1.0.6)
|
|
82
|
-
devise (4.8.
|
|
88
|
+
devise (4.8.1)
|
|
83
89
|
bcrypt (~> 3.0)
|
|
84
90
|
orm_adapter (~> 0.1)
|
|
85
91
|
railties (>= 4.1.0)
|
|
86
92
|
responders
|
|
87
93
|
warden (~> 1.2.3)
|
|
94
|
+
digest (3.1.0)
|
|
88
95
|
erubi (1.10.0)
|
|
89
96
|
execjs (2.8.1)
|
|
90
|
-
ffi (1.15.
|
|
91
|
-
globalid (0.
|
|
97
|
+
ffi (1.15.5)
|
|
98
|
+
globalid (1.0.0)
|
|
92
99
|
activesupport (>= 5.0)
|
|
93
|
-
i18n (1.
|
|
100
|
+
i18n (1.10.0)
|
|
94
101
|
concurrent-ruby (~> 1.0)
|
|
95
|
-
jquery-rails (4.
|
|
102
|
+
jquery-rails (4.5.0)
|
|
96
103
|
rails-dom-testing (>= 1, < 3)
|
|
97
104
|
railties (>= 4.2.0)
|
|
98
105
|
thor (>= 0.14, < 2.0)
|
|
99
|
-
listen (3.7.
|
|
106
|
+
listen (3.7.1)
|
|
100
107
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
|
101
108
|
rb-inotify (~> 0.9, >= 0.9.10)
|
|
102
|
-
loofah (2.
|
|
109
|
+
loofah (2.18.0)
|
|
103
110
|
crass (~> 1.0.2)
|
|
104
111
|
nokogiri (>= 1.5.9)
|
|
105
112
|
mail (2.7.1)
|
|
@@ -107,48 +114,62 @@ GEM
|
|
|
107
114
|
marcel (1.0.2)
|
|
108
115
|
method_source (1.0.0)
|
|
109
116
|
mini_mime (1.1.2)
|
|
110
|
-
mini_portile2 (2.
|
|
111
|
-
minitest (5.
|
|
112
|
-
msgpack (1.
|
|
117
|
+
mini_portile2 (2.8.0)
|
|
118
|
+
minitest (5.15.0)
|
|
119
|
+
msgpack (1.5.2)
|
|
120
|
+
net-imap (0.2.3)
|
|
121
|
+
digest
|
|
122
|
+
net-protocol
|
|
123
|
+
strscan
|
|
124
|
+
net-pop (0.1.1)
|
|
125
|
+
digest
|
|
126
|
+
net-protocol
|
|
127
|
+
timeout
|
|
128
|
+
net-protocol (0.1.3)
|
|
129
|
+
timeout
|
|
130
|
+
net-smtp (0.3.1)
|
|
131
|
+
digest
|
|
132
|
+
net-protocol
|
|
133
|
+
timeout
|
|
113
134
|
nio4r (2.5.8)
|
|
114
|
-
nokogiri (1.
|
|
115
|
-
mini_portile2 (~> 2.
|
|
135
|
+
nokogiri (1.13.6)
|
|
136
|
+
mini_portile2 (~> 2.8.0)
|
|
116
137
|
racc (~> 1.4)
|
|
117
138
|
orm_adapter (0.5.0)
|
|
118
|
-
pg (1.
|
|
139
|
+
pg (1.3.5)
|
|
119
140
|
popper_js (2.9.3)
|
|
120
|
-
racc (1.
|
|
121
|
-
rack (2.2.3)
|
|
141
|
+
racc (1.6.0)
|
|
142
|
+
rack (2.2.3.1)
|
|
122
143
|
rack-test (1.1.0)
|
|
123
144
|
rack (>= 1.0, < 3)
|
|
124
|
-
rails (
|
|
125
|
-
actioncable (=
|
|
126
|
-
actionmailbox (=
|
|
127
|
-
actionmailer (=
|
|
128
|
-
actionpack (=
|
|
129
|
-
actiontext (=
|
|
130
|
-
actionview (=
|
|
131
|
-
activejob (=
|
|
132
|
-
activemodel (=
|
|
133
|
-
activerecord (=
|
|
134
|
-
activestorage (=
|
|
135
|
-
activesupport (=
|
|
145
|
+
rails (7.0.3)
|
|
146
|
+
actioncable (= 7.0.3)
|
|
147
|
+
actionmailbox (= 7.0.3)
|
|
148
|
+
actionmailer (= 7.0.3)
|
|
149
|
+
actionpack (= 7.0.3)
|
|
150
|
+
actiontext (= 7.0.3)
|
|
151
|
+
actionview (= 7.0.3)
|
|
152
|
+
activejob (= 7.0.3)
|
|
153
|
+
activemodel (= 7.0.3)
|
|
154
|
+
activerecord (= 7.0.3)
|
|
155
|
+
activestorage (= 7.0.3)
|
|
156
|
+
activesupport (= 7.0.3)
|
|
136
157
|
bundler (>= 1.15.0)
|
|
137
|
-
railties (=
|
|
138
|
-
sprockets-rails (>= 2.0.0)
|
|
158
|
+
railties (= 7.0.3)
|
|
139
159
|
rails-dom-testing (2.0.3)
|
|
140
160
|
activesupport (>= 4.2.0)
|
|
141
161
|
nokogiri (>= 1.6)
|
|
142
162
|
rails-html-sanitizer (1.4.2)
|
|
143
163
|
loofah (~> 2.3)
|
|
144
|
-
railties (
|
|
145
|
-
actionpack (=
|
|
146
|
-
activesupport (=
|
|
164
|
+
railties (7.0.3)
|
|
165
|
+
actionpack (= 7.0.3)
|
|
166
|
+
activesupport (= 7.0.3)
|
|
147
167
|
method_source
|
|
148
|
-
rake (>=
|
|
168
|
+
rake (>= 12.2)
|
|
149
169
|
thor (~> 1.0)
|
|
170
|
+
zeitwerk (~> 2.5)
|
|
150
171
|
rake (13.0.6)
|
|
151
|
-
rb-fsevent (0.11.
|
|
172
|
+
rb-fsevent (0.11.1)
|
|
152
173
|
rb-inotify (0.10.1)
|
|
153
174
|
ffi (~> 1.0)
|
|
154
175
|
responders (3.0.1)
|
|
@@ -165,16 +186,18 @@ GEM
|
|
|
165
186
|
simple_form (5.1.0)
|
|
166
187
|
actionpack (>= 5.2)
|
|
167
188
|
activemodel (>= 5.2)
|
|
168
|
-
sprockets (4.0.
|
|
189
|
+
sprockets (4.0.3)
|
|
169
190
|
concurrent-ruby (~> 1.0)
|
|
170
191
|
rack (> 1, < 3)
|
|
171
|
-
sprockets-rails (3.
|
|
172
|
-
actionpack (>=
|
|
173
|
-
activesupport (>=
|
|
192
|
+
sprockets-rails (3.4.2)
|
|
193
|
+
actionpack (>= 5.2)
|
|
194
|
+
activesupport (>= 5.2)
|
|
174
195
|
sprockets (>= 3.0.0)
|
|
175
196
|
sqlite3 (1.4.2)
|
|
176
|
-
|
|
197
|
+
strscan (3.0.3)
|
|
198
|
+
thor (1.2.1)
|
|
177
199
|
tilt (2.0.10)
|
|
200
|
+
timeout (0.3.0)
|
|
178
201
|
tzinfo (2.0.4)
|
|
179
202
|
concurrent-ruby (~> 1.0)
|
|
180
203
|
warden (1.2.9)
|
|
@@ -182,7 +205,7 @@ GEM
|
|
|
182
205
|
websocket-driver (0.7.5)
|
|
183
206
|
websocket-extensions (>= 0.1.0)
|
|
184
207
|
websocket-extensions (0.1.5)
|
|
185
|
-
zeitwerk (2.4
|
|
208
|
+
zeitwerk (2.5.4)
|
|
186
209
|
|
|
187
210
|
PLATFORMS
|
|
188
211
|
ruby
|
data/README.md
CHANGED
|
@@ -104,25 +104,36 @@ Direct upload will send the file BEFORE the page submission. You will get a prog
|
|
|
104
104
|
## Resize
|
|
105
105
|
|
|
106
106
|
You can add an option to the field to resize the image after upload (of course it has to be an image!).
|
|
107
|
+
|
|
107
108
|
Add `resize: true` to your field.
|
|
108
|
-
|
|
109
|
+
|
|
110
|
+
You can also specify a ratio for the cropper. For example `resize: 1` will lock the aspect ratio to a square. Beware of the float constraints in rails. If you want a 4/3 ratio use `resize: 4/3.to_f` as 4/3 otherwise gives 1.
|
|
109
111
|
|
|
110
112
|
|
|
111
|
-
The resizer is based on [CropperJS](https://github.com/fengyuanchen/cropperjs) so you have to add cropper and jquery-cropper to your dependencies
|
|
113
|
+
The resizer is based on [CropperJS](https://github.com/fengyuanchen/cropperjs) so you have to add cropper and jquery-cropper to your dependencies:
|
|
112
114
|
```
|
|
113
115
|
yarn add cropperjs
|
|
114
116
|
yarn add jquery-cropper
|
|
115
117
|
```
|
|
116
|
-
then include the js files in your application.js file
|
|
118
|
+
then include the js files in your application.js file:
|
|
117
119
|
```
|
|
118
120
|
//= require cropperjs/dist/cropper
|
|
119
121
|
//= require jquery-cropper/dist/jquery-cropper
|
|
120
122
|
```
|
|
121
|
-
and include the css in your application.sass file
|
|
123
|
+
and include the css in your application.sass file:
|
|
122
124
|
```
|
|
123
125
|
@import 'cropperjs/dist/cropper'
|
|
124
126
|
```
|
|
125
127
|
|
|
128
|
+
In your `config/application.yml`, to support `+repage`, you have to add `+` method in supported operations.
|
|
129
|
+
```ruby
|
|
130
|
+
module MyApp
|
|
131
|
+
class Application < Rails::Application
|
|
132
|
+
# ...
|
|
133
|
+
config.active_storage.supported_image_processing_methods = ["+"]
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
```
|
|
126
137
|
|
|
127
138
|
## I18n
|
|
128
139
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
class ActiveRecord::Base
|
|
2
|
-
def self.has_one_attached_deletable(name,
|
|
2
|
+
def self.has_one_attached_deletable(name, **options)
|
|
3
3
|
class_eval do
|
|
4
4
|
attr_accessor :"#{name}_delete"
|
|
5
5
|
attr_accessor :"#{name}_infos"
|
|
@@ -49,6 +49,6 @@ class ActiveRecord::Base
|
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
51
|
|
|
52
|
-
has_one_attached name
|
|
52
|
+
has_one_attached name, **options
|
|
53
53
|
end
|
|
54
54
|
end
|
|
@@ -52,9 +52,7 @@ class SingleDeletableFileInput < SimpleForm::Inputs::Base
|
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
def existing_file_name_or_default_text
|
|
55
|
-
if should_display_file?
|
|
56
|
-
"#{file_attachment.filename}"
|
|
57
|
-
end
|
|
55
|
+
"#{file_attachment.filename}" if should_display_file?
|
|
58
56
|
end
|
|
59
57
|
|
|
60
58
|
def input_delete_name
|
|
@@ -122,9 +120,13 @@ class SingleDeletableFileInput < SimpleForm::Inputs::Base
|
|
|
122
120
|
end
|
|
123
121
|
|
|
124
122
|
def preview_image_tag
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
123
|
+
# Pas de fichier, pas de chocolat
|
|
124
|
+
return unless should_display_file?
|
|
125
|
+
# Fichier invariable, pas de chocolat non plus
|
|
126
|
+
return unless file_attachment&.variable?
|
|
127
|
+
variant = file_attachment.variant(resize: "#{preview_image_width}x")
|
|
128
|
+
path = url_helpers.polymorphic_url variant, only_path: true
|
|
129
|
+
image_tag path, class: 'img-fluid img-thumbnail', width: preview_image_width
|
|
128
130
|
end
|
|
129
131
|
|
|
130
132
|
def default_preview_image_width
|
|
Binary file
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: simple_form_bs5_file_input
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Pierre-andré Boissinot
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2022-05-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -73,6 +73,7 @@ extensions: []
|
|
|
73
73
|
extra_rdoc_files: []
|
|
74
74
|
files:
|
|
75
75
|
- ".eslintrc.yml"
|
|
76
|
+
- ".gitignore"
|
|
76
77
|
- ".sass-lint.yml"
|
|
77
78
|
- Gemfile
|
|
78
79
|
- Gemfile.lock
|
|
@@ -90,12 +91,13 @@ files:
|
|
|
90
91
|
- lib/simple_form_bs5_file_input/version.rb
|
|
91
92
|
- pkg/simple_form_bs5_file_input-0.0.1.gem
|
|
92
93
|
- pkg/simple_form_bs5_file_input-0.0.2.gem
|
|
94
|
+
- pkg/simple_form_bs5_file_input-0.0.3.gem
|
|
93
95
|
- simple_form_bs5_file_input.gemspec
|
|
94
96
|
homepage: https://github.com/noesya/simple_form_bs5_file_input
|
|
95
97
|
licenses:
|
|
96
98
|
- MIT
|
|
97
99
|
metadata: {}
|
|
98
|
-
post_install_message:
|
|
100
|
+
post_install_message:
|
|
99
101
|
rdoc_options: []
|
|
100
102
|
require_paths:
|
|
101
103
|
- lib
|
|
@@ -110,8 +112,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
110
112
|
- !ruby/object:Gem::Version
|
|
111
113
|
version: '0'
|
|
112
114
|
requirements: []
|
|
113
|
-
rubygems_version: 3.1.
|
|
114
|
-
signing_key:
|
|
115
|
+
rubygems_version: 3.1.6
|
|
116
|
+
signing_key:
|
|
115
117
|
specification_version: 4
|
|
116
118
|
summary: Simple Form BS5 File Input
|
|
117
119
|
test_files: []
|