administrate-field-active_storage 0.3.4 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +21 -0
- data/.gitignore +0 -1
- data/.ruby-version +1 -1
- data/Gemfile.lock +217 -0
- data/README.md +8 -1
- data/administrate-field-active_storage.gemspec +3 -2
- data/app/views/fields/active_storage/_form.html.erb +4 -1
- data/app/views/fields/active_storage/_index.html.erb +19 -8
- data/app/views/fields/active_storage/_item.html.erb +2 -1
- data/app/views/fields/active_storage/_items.html.erb +6 -1
- data/app/views/fields/active_storage/_preview.html.erb +17 -3
- data/app/views/fields/active_storage/_show.html.erb +1 -1
- data/config/i18n-tasks.yml +8 -0
- data/config/locales/administrate-field-active_storage.en.yml +10 -0
- data/config/locales/administrate-field-active_storage.ru.yml +10 -0
- data/contribute.md +3 -0
- data/lib/administrate/field/active_storage.rb +3 -3
- data/spec/i18n_spec.rb +35 -0
- data/test_app/.browserslistrc +1 -0
- data/test_app/.gitattributes +10 -0
- data/{example-project → test_app}/.gitignore +9 -7
- data/test_app/.ruby-version +1 -0
- data/test_app/Gemfile +45 -0
- data/test_app/Gemfile.lock +237 -0
- data/{example-project → test_app}/README.md +0 -0
- data/{example-project → test_app}/Rakefile +1 -1
- data/test_app/app/assets/config/manifest.js +4 -0
- data/{example-project → test_app}/app/assets/images/.keep +0 -0
- data/{example-project → test_app}/app/assets/stylesheets/application.css +0 -0
- data/{example-project → test_app}/app/controllers/admin/application_controller.rb +3 -3
- data/test_app/app/controllers/admin/posts_controller.rb +46 -0
- data/{example-project → test_app}/app/controllers/application_controller.rb +0 -0
- data/{example-project/app/dashboards/user_dashboard.rb → test_app/app/dashboards/post_dashboard.rb} +29 -27
- data/{example-project → test_app}/app/helpers/application_helper.rb +0 -0
- data/test_app/app/javascript/packs/application.js +10 -0
- data/{example-project → test_app}/app/models/application_record.rb +0 -0
- data/test_app/app/models/post.rb +3 -0
- data/test_app/app/views/layouts/application.html.erb +16 -0
- data/test_app/bin/bundle +114 -0
- data/test_app/bin/rails +4 -0
- data/test_app/bin/rake +4 -0
- data/{example-project → test_app}/bin/setup +6 -9
- data/test_app/config/application.rb +35 -0
- data/{example-project/bin/bundle → test_app/config/boot.rb} +2 -2
- data/test_app/config/credentials.yml.enc +1 -0
- data/{example-project → test_app}/config/database.yml +1 -1
- data/{example-project → test_app}/config/environment.rb +1 -1
- data/{example-project → test_app}/config/environments/development.rb +21 -11
- data/{example-project → test_app}/config/environments/production.rb +36 -24
- data/{example-project → test_app}/config/environments/test.rb +20 -14
- data/{example-project → test_app}/config/initializers/application_controller_renderer.rb +0 -0
- data/{example-project → test_app}/config/initializers/assets.rb +0 -0
- data/test_app/config/initializers/backtrace_silencers.rb +8 -0
- data/{example-project → test_app}/config/initializers/content_security_policy.rb +5 -0
- data/{example-project → test_app}/config/initializers/cookies_serializer.rb +0 -0
- data/{example-project → test_app}/config/initializers/filter_parameter_logging.rb +3 -1
- data/{example-project → test_app}/config/initializers/inflections.rb +0 -0
- data/{example-project → test_app}/config/initializers/mime_types.rb +0 -0
- data/test_app/config/initializers/permissions_policy.rb +11 -0
- data/{example-project → test_app}/config/initializers/wrap_parameters.rb +0 -0
- data/{example-project → test_app}/config/locales/en.yml +1 -1
- data/{example-project → test_app}/config/puma.rb +13 -4
- data/test_app/config/routes.rb +9 -0
- data/{example-project → test_app}/config/storage.yml +0 -0
- data/{example-project → test_app}/config.ru +2 -1
- data/{example-project/db/migrate/20181221134334_create_active_storage_tables.active_storage.rb → test_app/db/migrate/20210118122804_create_active_storage_tables.active_storage.rb} +15 -5
- data/test_app/db/migrate/20210118122927_create_posts.rb +8 -0
- data/{example-project → test_app}/db/schema.rb +18 -10
- data/{example-project → test_app}/db/seeds.rb +1 -1
- data/test_app/lib/active_storage/fixture_set.rb +71 -0
- data/{example-project → test_app}/public/404.html +0 -0
- data/{example-project → test_app}/public/422.html +0 -0
- data/{example-project → test_app}/public/500.html +0 -0
- data/{example-project → test_app}/public/apple-touch-icon-precomposed.png +0 -0
- data/{example-project → test_app}/public/apple-touch-icon.png +0 -0
- data/{example-project → test_app}/public/favicon.ico +0 -0
- data/test_app/public/robots.txt +1 -0
- data/{example-project → test_app}/test/application_system_test_case.rb +0 -0
- data/test_app/test/controllers/admin/posts_controller_test.rb +14 -0
- data/test_app/test/fixtures/active_storage/attachments.yml +4 -0
- data/test_app/test/fixtures/active_storage/blobs.yml +2 -0
- data/test_app/test/fixtures/files/cover_image.jpg +0 -0
- data/test_app/test/fixtures/posts.yml +11 -0
- data/test_app/test/models/post_test.rb +9 -0
- data/test_app/test/test_helper.rb +20 -0
- metadata +97 -99
- data/Rakefile +0 -22
- data/example-project/.ruby-version +0 -1
- data/example-project/Gemfile +0 -67
- data/example-project/Gemfile.lock +0 -265
- data/example-project/app/assets/config/manifest.js +0 -3
- data/example-project/app/assets/javascripts/application.js +0 -16
- data/example-project/app/assets/javascripts/cable.js +0 -13
- data/example-project/app/assets/javascripts/channels/.keep +0 -0
- data/example-project/app/channels/application_cable/channel.rb +0 -4
- data/example-project/app/channels/application_cable/connection.rb +0 -4
- data/example-project/app/controllers/admin/users_controller.rb +0 -27
- data/example-project/app/controllers/concerns/.keep +0 -0
- data/example-project/app/controllers/users_controller.rb +0 -7
- data/example-project/app/jobs/application_job.rb +0 -2
- data/example-project/app/mailers/application_mailer.rb +0 -4
- data/example-project/app/models/concerns/.keep +0 -0
- data/example-project/app/models/user.rb +0 -3
- data/example-project/app/views/layouts/application.html.erb +0 -15
- data/example-project/app/views/layouts/mailer.html.erb +0 -13
- data/example-project/app/views/layouts/mailer.text.erb +0 -1
- data/example-project/bin/rails +0 -9
- data/example-project/bin/rake +0 -9
- data/example-project/bin/spring +0 -17
- data/example-project/bin/update +0 -31
- data/example-project/bin/yarn +0 -11
- data/example-project/config/application.rb +0 -19
- data/example-project/config/boot.rb +0 -4
- data/example-project/config/cable.yml +0 -10
- data/example-project/config/credentials.yml.enc +0 -1
- data/example-project/config/initializers/backtrace_silencers.rb +0 -7
- data/example-project/config/routes.rb +0 -10
- data/example-project/config/spring.rb +0 -6
- data/example-project/db/migrate/20181013145025_create_users.rb +0 -9
- data/example-project/lib/assets/.keep +0 -0
- data/example-project/lib/tasks/.keep +0 -0
- data/example-project/log/.keep +0 -0
- data/example-project/package.json +0 -5
- data/example-project/public/robots.txt +0 -1
- data/example-project/test/controllers/.keep +0 -0
- data/example-project/test/fixtures/.keep +0 -0
- data/example-project/test/fixtures/files/.keep +0 -0
- data/example-project/test/fixtures/users.yml +0 -7
- data/example-project/test/helpers/.keep +0 -0
- data/example-project/test/integration/.keep +0 -0
- data/example-project/test/mailers/.keep +0 -0
- data/example-project/test/models/.keep +0 -0
- data/example-project/test/models/user_test.rb +0 -7
- data/example-project/test/system/.keep +0 -0
- data/example-project/test/test_helper.rb +0 -10
- data/example-project/tmp/.keep +0 -0
- data/example-project/vendor/.keep +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d685dc2a380f464f63d5b78dfd5a3c967e4a22ec7b28218f8e8bd8f22d5039e
|
4
|
+
data.tar.gz: ae36c6c3b520706249cf3bb917f1441cd22506f9ea0761fb14f51834406e2c7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91b86562577256f867aa848391004229f58200757c8ddddc9895d22d6907c15472d5e0308e292323979787687f9362a7aba9b2d7f2ec63cad8ac4151d6559069
|
7
|
+
data.tar.gz: 842ece6e36fb7592cbea4a99a362af6862824cb74f60dfe4f7d28a07a0a95d7174669e7a3e68dce5152efa9a4ce35309ac6271c685e335b1990e24ebdf352ad9
|
@@ -0,0 +1,21 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on: [push,pull_request]
|
4
|
+
|
5
|
+
env:
|
6
|
+
RAILS_MASTER_KEY: ca18e029a12884a87e96cf6a64a12fb5
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
build:
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
steps:
|
12
|
+
- uses: actions/checkout@v2
|
13
|
+
- uses: ruby/setup-ruby@v1
|
14
|
+
- uses: actions/cache@v2
|
15
|
+
with:
|
16
|
+
path: vendor/bundle
|
17
|
+
key: bundle-use-ruby-${{ matrix.os }}-${{ matrix.ruby }}-${{ hashFiles('**/Gemfile.lock') }}
|
18
|
+
restore-keys: |
|
19
|
+
bundle-use-ruby-${{ matrix.os }}-${{ matrix.ruby }}-
|
20
|
+
- run: test_app/bin/setup
|
21
|
+
- run: cd test_app && bundle exec rails test
|
data/.gitignore
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.0.0
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,217 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
administrate-field-active_storage (0.3.6)
|
5
|
+
administrate (>= 0.2.2)
|
6
|
+
rails (>= 6.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actioncable (6.1.1)
|
12
|
+
actionpack (= 6.1.1)
|
13
|
+
activesupport (= 6.1.1)
|
14
|
+
nio4r (~> 2.0)
|
15
|
+
websocket-driver (>= 0.6.1)
|
16
|
+
actionmailbox (6.1.1)
|
17
|
+
actionpack (= 6.1.1)
|
18
|
+
activejob (= 6.1.1)
|
19
|
+
activerecord (= 6.1.1)
|
20
|
+
activestorage (= 6.1.1)
|
21
|
+
activesupport (= 6.1.1)
|
22
|
+
mail (>= 2.7.1)
|
23
|
+
actionmailer (6.1.1)
|
24
|
+
actionpack (= 6.1.1)
|
25
|
+
actionview (= 6.1.1)
|
26
|
+
activejob (= 6.1.1)
|
27
|
+
activesupport (= 6.1.1)
|
28
|
+
mail (~> 2.5, >= 2.5.4)
|
29
|
+
rails-dom-testing (~> 2.0)
|
30
|
+
actionpack (6.1.1)
|
31
|
+
actionview (= 6.1.1)
|
32
|
+
activesupport (= 6.1.1)
|
33
|
+
rack (~> 2.0, >= 2.0.9)
|
34
|
+
rack-test (>= 0.6.3)
|
35
|
+
rails-dom-testing (~> 2.0)
|
36
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
37
|
+
actiontext (6.1.1)
|
38
|
+
actionpack (= 6.1.1)
|
39
|
+
activerecord (= 6.1.1)
|
40
|
+
activestorage (= 6.1.1)
|
41
|
+
activesupport (= 6.1.1)
|
42
|
+
nokogiri (>= 1.8.5)
|
43
|
+
actionview (6.1.1)
|
44
|
+
activesupport (= 6.1.1)
|
45
|
+
builder (~> 3.1)
|
46
|
+
erubi (~> 1.4)
|
47
|
+
rails-dom-testing (~> 2.0)
|
48
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
49
|
+
activejob (6.1.1)
|
50
|
+
activesupport (= 6.1.1)
|
51
|
+
globalid (>= 0.3.6)
|
52
|
+
activemodel (6.1.1)
|
53
|
+
activesupport (= 6.1.1)
|
54
|
+
activerecord (6.1.1)
|
55
|
+
activemodel (= 6.1.1)
|
56
|
+
activesupport (= 6.1.1)
|
57
|
+
activestorage (6.1.1)
|
58
|
+
actionpack (= 6.1.1)
|
59
|
+
activejob (= 6.1.1)
|
60
|
+
activerecord (= 6.1.1)
|
61
|
+
activesupport (= 6.1.1)
|
62
|
+
marcel (~> 0.3.1)
|
63
|
+
mimemagic (~> 0.3.2)
|
64
|
+
activesupport (6.1.1)
|
65
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
66
|
+
i18n (>= 1.6, < 2)
|
67
|
+
minitest (>= 5.1)
|
68
|
+
tzinfo (~> 2.0)
|
69
|
+
zeitwerk (~> 2.3)
|
70
|
+
administrate (0.14.0)
|
71
|
+
actionpack (>= 4.2)
|
72
|
+
actionview (>= 4.2)
|
73
|
+
activerecord (>= 4.2)
|
74
|
+
autoprefixer-rails (>= 6.0)
|
75
|
+
datetime_picker_rails (~> 0.0.7)
|
76
|
+
jquery-rails (>= 4.0)
|
77
|
+
kaminari (>= 1.0)
|
78
|
+
momentjs-rails (~> 2.8)
|
79
|
+
sassc-rails (~> 2.1)
|
80
|
+
selectize-rails (~> 0.6)
|
81
|
+
ast (2.4.2)
|
82
|
+
autoprefixer-rails (10.2.0.0)
|
83
|
+
execjs
|
84
|
+
builder (3.2.4)
|
85
|
+
concurrent-ruby (1.1.8)
|
86
|
+
crass (1.0.6)
|
87
|
+
datetime_picker_rails (0.0.7)
|
88
|
+
momentjs-rails (>= 2.8.1)
|
89
|
+
erubi (1.10.0)
|
90
|
+
execjs (2.7.0)
|
91
|
+
ffi (1.14.2)
|
92
|
+
globalid (0.4.2)
|
93
|
+
activesupport (>= 4.2.0)
|
94
|
+
highline (2.0.3)
|
95
|
+
i18n (1.8.7)
|
96
|
+
concurrent-ruby (~> 1.0)
|
97
|
+
i18n-tasks (0.9.34)
|
98
|
+
activesupport (>= 4.0.2)
|
99
|
+
ast (>= 2.1.0)
|
100
|
+
erubi
|
101
|
+
highline (>= 2.0.0)
|
102
|
+
i18n
|
103
|
+
parser (>= 2.2.3.0)
|
104
|
+
rails-i18n
|
105
|
+
rainbow (>= 2.2.2, < 4.0)
|
106
|
+
terminal-table (>= 1.5.1)
|
107
|
+
jquery-rails (4.4.0)
|
108
|
+
rails-dom-testing (>= 1, < 3)
|
109
|
+
railties (>= 4.2.0)
|
110
|
+
thor (>= 0.14, < 2.0)
|
111
|
+
kaminari (1.2.1)
|
112
|
+
activesupport (>= 4.1.0)
|
113
|
+
kaminari-actionview (= 1.2.1)
|
114
|
+
kaminari-activerecord (= 1.2.1)
|
115
|
+
kaminari-core (= 1.2.1)
|
116
|
+
kaminari-actionview (1.2.1)
|
117
|
+
actionview
|
118
|
+
kaminari-core (= 1.2.1)
|
119
|
+
kaminari-activerecord (1.2.1)
|
120
|
+
activerecord
|
121
|
+
kaminari-core (= 1.2.1)
|
122
|
+
kaminari-core (1.2.1)
|
123
|
+
loofah (2.9.0)
|
124
|
+
crass (~> 1.0.2)
|
125
|
+
nokogiri (>= 1.5.9)
|
126
|
+
mail (2.7.1)
|
127
|
+
mini_mime (>= 0.1.1)
|
128
|
+
marcel (0.3.3)
|
129
|
+
mimemagic (~> 0.3.2)
|
130
|
+
method_source (1.0.0)
|
131
|
+
mimemagic (0.3.5)
|
132
|
+
mini_mime (1.0.2)
|
133
|
+
minitest (5.14.3)
|
134
|
+
momentjs-rails (2.20.1)
|
135
|
+
railties (>= 3.1)
|
136
|
+
nio4r (2.5.4)
|
137
|
+
nokogiri (1.11.1-x86_64-darwin)
|
138
|
+
racc (~> 1.4)
|
139
|
+
nokogiri (1.11.1-x86_64-linux)
|
140
|
+
racc (~> 1.4)
|
141
|
+
parser (3.0.0.0)
|
142
|
+
ast (~> 2.4.1)
|
143
|
+
racc (1.5.2)
|
144
|
+
rack (2.2.3)
|
145
|
+
rack-test (1.1.0)
|
146
|
+
rack (>= 1.0, < 3)
|
147
|
+
rails (6.1.1)
|
148
|
+
actioncable (= 6.1.1)
|
149
|
+
actionmailbox (= 6.1.1)
|
150
|
+
actionmailer (= 6.1.1)
|
151
|
+
actionpack (= 6.1.1)
|
152
|
+
actiontext (= 6.1.1)
|
153
|
+
actionview (= 6.1.1)
|
154
|
+
activejob (= 6.1.1)
|
155
|
+
activemodel (= 6.1.1)
|
156
|
+
activerecord (= 6.1.1)
|
157
|
+
activestorage (= 6.1.1)
|
158
|
+
activesupport (= 6.1.1)
|
159
|
+
bundler (>= 1.15.0)
|
160
|
+
railties (= 6.1.1)
|
161
|
+
sprockets-rails (>= 2.0.0)
|
162
|
+
rails-dom-testing (2.0.3)
|
163
|
+
activesupport (>= 4.2.0)
|
164
|
+
nokogiri (>= 1.6)
|
165
|
+
rails-html-sanitizer (1.3.0)
|
166
|
+
loofah (~> 2.3)
|
167
|
+
rails-i18n (6.0.0)
|
168
|
+
i18n (>= 0.7, < 2)
|
169
|
+
railties (>= 6.0.0, < 7)
|
170
|
+
railties (6.1.1)
|
171
|
+
actionpack (= 6.1.1)
|
172
|
+
activesupport (= 6.1.1)
|
173
|
+
method_source
|
174
|
+
rake (>= 0.8.7)
|
175
|
+
thor (~> 1.0)
|
176
|
+
rainbow (3.0.0)
|
177
|
+
rake (13.0.3)
|
178
|
+
sassc (2.4.0)
|
179
|
+
ffi (~> 1.9)
|
180
|
+
sassc-rails (2.1.2)
|
181
|
+
railties (>= 4.0.0)
|
182
|
+
sassc (>= 2.0)
|
183
|
+
sprockets (> 3.0)
|
184
|
+
sprockets-rails
|
185
|
+
tilt
|
186
|
+
selectize-rails (0.12.6)
|
187
|
+
sprockets (4.0.2)
|
188
|
+
concurrent-ruby (~> 1.0)
|
189
|
+
rack (> 1, < 3)
|
190
|
+
sprockets-rails (3.2.2)
|
191
|
+
actionpack (>= 4.0)
|
192
|
+
activesupport (>= 4.0)
|
193
|
+
sprockets (>= 3.0.0)
|
194
|
+
sqlite3 (1.4.2)
|
195
|
+
terminal-table (3.0.0)
|
196
|
+
unicode-display_width (~> 1.1, >= 1.1.1)
|
197
|
+
thor (1.1.0)
|
198
|
+
tilt (2.0.10)
|
199
|
+
tzinfo (2.0.4)
|
200
|
+
concurrent-ruby (~> 1.0)
|
201
|
+
unicode-display_width (1.7.0)
|
202
|
+
websocket-driver (0.7.3)
|
203
|
+
websocket-extensions (>= 0.1.0)
|
204
|
+
websocket-extensions (0.1.5)
|
205
|
+
zeitwerk (2.4.2)
|
206
|
+
|
207
|
+
PLATFORMS
|
208
|
+
x86_64-darwin-20
|
209
|
+
x86_64-linux
|
210
|
+
|
211
|
+
DEPENDENCIES
|
212
|
+
administrate-field-active_storage!
|
213
|
+
i18n-tasks (~> 0.9.34)
|
214
|
+
sqlite3 (~> 1.4)
|
215
|
+
|
216
|
+
BUNDLED WITH
|
217
|
+
2.2.14
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# Administrate::Field::ActiveStorage
|
2
2
|
![rails](https://img.shields.io/badge/rails-%3E%3D5.2.0-red.svg)
|
3
|
+
![CI](https://github.com/Dreamersoul/administrate-field-active_storage/workflows/CI/badge.svg)
|
3
4
|
|
4
5
|
## Things To Know:
|
5
6
|
- To preview pdf files you need to install `mupdf` or `Poppler`.
|
@@ -16,7 +17,7 @@ gem "image_processing"
|
|
16
17
|
|
17
18
|
for rails 5.x use the following
|
18
19
|
```ruby
|
19
|
-
gem 'administrate-field-active_storage'
|
20
|
+
gem 'administrate-field-active_storage', "0.1.8"
|
20
21
|
```
|
21
22
|
|
22
23
|
Install:
|
@@ -59,6 +60,8 @@ class ModelDashboard < Administrate::BaseDashboard
|
|
59
60
|
```
|
60
61
|
I know it is not ideal, if you have a workaround please submit a PR.
|
61
62
|
|
63
|
+
Note: Rails 6 introduced a new config to determine the behavior on updates to `has_many_attached`. Setting `Rails.application.config.active_storage.replace_on_assign_to_many` to `true` will overwrite any existing values (purging the old ones), and setting it to `false` will append the new values.
|
64
|
+
|
62
65
|
### Prevent N+1 queries
|
63
66
|
In order to prevent N+1 queries from active storage you have to modify your admin model controller, below an example for a model called `User` and with attached avatars
|
64
67
|
```ruby
|
@@ -201,6 +204,10 @@ Defaults to `false`.
|
|
201
204
|
|
202
205
|
Don't forget to include [ActiveStorage JavaScript](https://edgeguides.rubyonrails.org/active_storage_overview.html#direct-uploads). You can use `rails generate administrate:assets:javascripts` to be able to customize Administrate JavaScripts in your application.
|
203
206
|
|
207
|
+
## I18n
|
208
|
+
|
209
|
+
You can see translation example [here](https://github.com/Dreamersoul/administrate-field-active_storage/blob/master/config/locales/administrate-field-active_storage.en.yml).
|
210
|
+
|
204
211
|
## Things To Do:
|
205
212
|
- [x] upload single file
|
206
213
|
- [x] adding image support through url_for to support 3rd party cloud storage
|
@@ -2,7 +2,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |gem|
|
4
4
|
gem.name = "administrate-field-active_storage"
|
5
|
-
gem.version = "0.3.
|
5
|
+
gem.version = "0.3.8"
|
6
6
|
gem.authors = ["Hamad AlGhanim"]
|
7
7
|
gem.email = ["hamadyalghanim@gmail.com"]
|
8
8
|
gem.homepage = "https://github.com/Dreamersoul/administrate-field-active_storage"
|
@@ -17,5 +17,6 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.add_dependency "administrate", ">= 0.2.2"
|
18
18
|
gem.add_dependency "rails", ">= 6.0"
|
19
19
|
|
20
|
-
gem.add_development_dependency
|
20
|
+
gem.add_development_dependency 'sqlite3', '~> 1.4'
|
21
|
+
gem.add_development_dependency 'i18n-tasks', '~> 0.9.34'
|
21
22
|
end
|
@@ -25,7 +25,10 @@ By default, the input is a text field for the image's URL.
|
|
25
25
|
<% end %>
|
26
26
|
|
27
27
|
<div>
|
28
|
-
<%= field.can_add_attachment? ?
|
28
|
+
<%= field.can_add_attachment? ?
|
29
|
+
I18n.t("administrate.fields.active_storage.add", default: 'Add') :
|
30
|
+
I18n.t("administrate.fields.active_storage.replace", default: 'Replace')
|
31
|
+
%>
|
29
32
|
<%= f.file_field field.attribute, multiple: field.many?, direct_upload: field.direct? %>
|
30
33
|
</div>
|
31
34
|
</div>
|
@@ -16,23 +16,34 @@ By default, the attribute is rendered as an image tag.
|
|
16
16
|
%>
|
17
17
|
|
18
18
|
<% if field.attached? %>
|
19
|
-
<style> <%# figure out a way to remove this %>
|
19
|
+
<style type="text/css" nonce="<%= content_security_policy_nonce %>"> <%# figure out a way to remove this %>
|
20
20
|
td img {
|
21
21
|
max-height: unset !important;
|
22
22
|
}
|
23
23
|
</style>
|
24
24
|
<% if field.index_display_preview? %>
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
25
|
+
<% if field.many? %>
|
26
|
+
<%= render partial: 'fields/active_storage/items',
|
27
|
+
locals: {
|
28
|
+
field: field,
|
29
|
+
size: field.index_preview_size
|
30
|
+
} %>
|
31
|
+
<% else %>
|
32
|
+
<%= render partial: 'fields/active_storage/item',
|
33
|
+
locals: {
|
34
|
+
field: field,
|
35
|
+
attachment: field.data,
|
36
|
+
size: field.index_preview_size
|
37
|
+
} %>
|
38
|
+
<% end %>
|
31
39
|
<% end %>
|
32
40
|
|
33
41
|
<% if field.index_display_count? %>
|
34
42
|
<div class="attachments-count">
|
35
|
-
<%= pluralize(field.attachments.count,
|
43
|
+
<%= pluralize(field.attachments.count,
|
44
|
+
I18n.t("administrate.fields.active_storage.attachment", default: 'Attachment')
|
45
|
+
)
|
46
|
+
%>
|
36
47
|
</div>
|
37
48
|
<% end %>
|
38
49
|
<% end %>
|
@@ -36,7 +36,8 @@ controlled via a boolean local variable.
|
|
36
36
|
<% if field.destroy_url.present? %>
|
37
37
|
<% destroy_url = field.destroy_url.call(namespace, field.data.record, attachment) %>
|
38
38
|
<div>
|
39
|
-
<%= link_to
|
39
|
+
<%= link_to I18n.t("administrate.fields.active_storage.remove", default: 'Remove'),
|
40
|
+
destroy_url, method: :delete, class: 'remove-attachment-link', data: { confirm: t("administrate.actions.confirm") } %>
|
40
41
|
</div>
|
41
42
|
<hr>
|
42
43
|
<% end %>
|
@@ -11,10 +11,15 @@ This partial renders one or more attachments
|
|
11
11
|
- `removable`:
|
12
12
|
A boolean used to control the display of a `Remove` link which
|
13
13
|
is used to destroy a single attachment. Defaults to `false`
|
14
|
+
- `size`:
|
15
|
+
[x, y]
|
16
|
+
Maximum size of the ActiveStorage preview.
|
17
|
+
Defaults to `field.show_preview_size`.
|
14
18
|
%>
|
15
19
|
|
16
20
|
<%
|
17
21
|
removable = local_assigns.fetch(:removable, false)
|
22
|
+
size = local_assigns.fetch(:size, field.show_preview_size)
|
18
23
|
%>
|
19
24
|
|
20
25
|
<% field.attachments.each do |attachment| %>
|
@@ -24,7 +29,7 @@ This partial renders one or more attachments
|
|
24
29
|
field: field,
|
25
30
|
attachment: attachment,
|
26
31
|
removable: removable,
|
27
|
-
size:
|
32
|
+
size: size
|
28
33
|
} %>
|
29
34
|
</div>
|
30
35
|
<% end %>
|
@@ -1,4 +1,11 @@
|
|
1
|
-
<
|
1
|
+
<style type="text/css" nonce="<%= content_security_policy_nonce %>">
|
2
|
+
#as-field-<%= attachment.id %> {
|
3
|
+
width: <%=size[0]/2%>px;
|
4
|
+
height: auto;
|
5
|
+
overflow: hidden;
|
6
|
+
}
|
7
|
+
</style>
|
8
|
+
<div id="as-field-<%= attachment.id %>">
|
2
9
|
<% if attachment.image? %>
|
3
10
|
<% if attachment.variable? %>
|
4
11
|
<%= image_tag(field.variant(attachment, resize_to_limit: size)) %>
|
@@ -6,14 +13,21 @@
|
|
6
13
|
<%= image_tag(field.url(attachment)) %>
|
7
14
|
<% end %>
|
8
15
|
<% elsif attachment.video? %>
|
16
|
+
<style type="text/css" nonce="<%= content_security_policy_nonce %>">
|
17
|
+
#as-field-video-<%= attachment.id %> {
|
18
|
+
object-fit: contain;
|
19
|
+
width: 100%;
|
20
|
+
height: 100%;
|
21
|
+
}
|
22
|
+
</style>
|
9
23
|
<% if attachment.previewable? %>
|
10
24
|
<%= video_tag(field.url(attachment),
|
11
25
|
poster: field.preview(attachment, resize_to_limit: size),
|
12
26
|
controls: true,
|
13
27
|
autobuffer: true,
|
14
|
-
|
28
|
+
id: "as-field-video-#{attachment.id}") %>
|
15
29
|
<% else %>
|
16
|
-
<%= video_tag(field.url(attachment), controls: true, autobuffer: true,
|
30
|
+
<%= video_tag(field.url(attachment), controls: true, autobuffer: true, id: "as-field-video-#{attachment.id}") %>
|
17
31
|
<% end %>
|
18
32
|
<% elsif attachment.audio? %>
|
19
33
|
<%= audio_tag(field.url(attachment), autoplay: false, controls: true) %>
|
@@ -18,5 +18,5 @@ By default, the attribute is rendered as an image tag.
|
|
18
18
|
<% if field.attached? %>
|
19
19
|
<%= render partial: 'fields/active_storage/items', locals: { field: field } %>
|
20
20
|
<% else %>
|
21
|
-
No attachment
|
21
|
+
<%= I18n.t("administrate.fields.active_storage.no_attachment", default: 'No attachment') %>
|
22
22
|
<% end %>
|
data/contribute.md
CHANGED
@@ -11,3 +11,6 @@
|
|
11
11
|
- Daniel Tinoco [@0urobor0s](https://github.com/0urobor0s)
|
12
12
|
- Matthew Hui [@mhui](https://github.com/mhui)
|
13
13
|
- Sébastien Dubois [@sedubois](https://github.com/sedubois)
|
14
|
+
- Jazzy Gasper [@jazzygasper](https://github.com/jazzygasper)
|
15
|
+
- David Ma [@taikon](https://github.com/taikon)
|
16
|
+
- Dmitry Davydov [@haukot](https://github.com/haukot)
|
@@ -16,7 +16,7 @@ module Administrate
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def index_display_count?
|
19
|
-
options.fetch(:index_display_count) {
|
19
|
+
options.fetch(:index_display_count) { attached? && attachments.count != 1 }
|
20
20
|
end
|
21
21
|
|
22
22
|
def show_display_preview?
|
@@ -50,7 +50,7 @@ module Administrate
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def variant(attachment, options)
|
53
|
-
Rails.application.routes.url_helpers.rails_representation_path(attachment.variant(
|
53
|
+
Rails.application.routes.url_helpers.rails_representation_path(attachment.variant(options), only_path: true)
|
54
54
|
end
|
55
55
|
|
56
56
|
def url(attachment)
|
@@ -70,7 +70,7 @@ module Administrate
|
|
70
70
|
end
|
71
71
|
|
72
72
|
def attachments
|
73
|
-
data.attachments if attached?
|
73
|
+
many? ? data.attachments : [data.attachment] if attached?
|
74
74
|
end
|
75
75
|
end
|
76
76
|
end
|
data/spec/i18n_spec.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'i18n/tasks'
|
4
|
+
|
5
|
+
# Template i18n-tasks test file from https://github.com/glebm/i18n-tasks/blob/main/templates/rspec/i18n_spec.rb
|
6
|
+
RSpec.describe I18n do
|
7
|
+
let(:i18n) { I18n::Tasks::BaseTask.new }
|
8
|
+
let(:missing_keys) { i18n.missing_keys }
|
9
|
+
let(:unused_keys) { i18n.unused_keys }
|
10
|
+
let(:inconsistent_interpolations) { i18n.inconsistent_interpolations }
|
11
|
+
|
12
|
+
it 'does not have missing keys' do
|
13
|
+
expect(missing_keys).to be_empty,
|
14
|
+
"Missing #{missing_keys.leaves.count} i18n keys, run `i18n-tasks missing' to show them"
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'does not have unused keys' do
|
18
|
+
expect(unused_keys).to be_empty,
|
19
|
+
"#{unused_keys.leaves.count} unused i18n keys, run `i18n-tasks unused' to show them"
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'files are normalized' do
|
23
|
+
non_normalized = i18n.non_normalized_paths
|
24
|
+
error_message = "The following files need to be normalized:\n" \
|
25
|
+
"#{non_normalized.map { |path| " #{path}" }.join("\n")}\n" \
|
26
|
+
"Please run `i18n-tasks normalize' to fix"
|
27
|
+
expect(non_normalized).to be_empty, error_message
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'does not have inconsistent interpolations' do
|
31
|
+
error_message = "#{inconsistent_interpolations.leaves.count} i18n keys have inconsistent interpolations.\n" \
|
32
|
+
"Run `i18n-tasks check-consistent-interpolations' to show them"
|
33
|
+
expect(inconsistent_interpolations).to be_empty, error_message
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
defaults
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# See https://git-scm.com/docs/gitattributes for more about git attribute files.
|
2
|
+
|
3
|
+
# Mark the database schema as having been generated.
|
4
|
+
db/schema.rb linguist-generated
|
5
|
+
|
6
|
+
# Mark the yarn lockfile as having been generated.
|
7
|
+
yarn.lock linguist-generated
|
8
|
+
|
9
|
+
# Mark any vendored files as having been vendored.
|
10
|
+
vendor/* linguist-vendored
|
@@ -9,22 +9,24 @@
|
|
9
9
|
|
10
10
|
# Ignore the default SQLite database.
|
11
11
|
/db/*.sqlite3
|
12
|
-
/db/*.sqlite3
|
12
|
+
/db/*.sqlite3-*
|
13
13
|
|
14
14
|
# Ignore all logfiles and tempfiles.
|
15
15
|
/log/*
|
16
16
|
/tmp/*
|
17
|
-
!/log/.keep
|
18
|
-
!/tmp/.keep
|
19
17
|
|
20
|
-
# Ignore uploaded files in development
|
18
|
+
# Ignore uploaded files in development.
|
21
19
|
/storage/*
|
22
20
|
|
23
|
-
/node_modules
|
24
|
-
/yarn-error.log
|
25
|
-
|
26
21
|
/public/assets
|
27
22
|
.byebug_history
|
28
23
|
|
29
24
|
# Ignore master key for decrypting credentials and more.
|
30
25
|
/config/master.key
|
26
|
+
|
27
|
+
/public/packs
|
28
|
+
/public/packs-test
|
29
|
+
/node_modules
|
30
|
+
/yarn-error.log
|
31
|
+
yarn-debug.log*
|
32
|
+
.yarn-integrity
|
@@ -0,0 +1 @@
|
|
1
|
+
ruby-3.0.0
|
data/test_app/Gemfile
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
3
|
+
|
4
|
+
ruby '3.0.0'
|
5
|
+
|
6
|
+
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
7
|
+
gem 'rails', '~> 6.1.1'
|
8
|
+
# Use sqlite3 as the database for Active Record
|
9
|
+
gem 'sqlite3', '~> 1.4'
|
10
|
+
# Use Puma as the app server
|
11
|
+
gem 'puma', '~> 5.0'
|
12
|
+
# Use SCSS for stylesheets
|
13
|
+
gem 'sass-rails', '>= 6'
|
14
|
+
# Use Active Model has_secure_password
|
15
|
+
# gem 'bcrypt', '~> 3.1.7'
|
16
|
+
|
17
|
+
# Use Active Storage variant
|
18
|
+
# gem 'image_processing', '~> 1.2'
|
19
|
+
|
20
|
+
group :development, :test do
|
21
|
+
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
22
|
+
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
|
23
|
+
end
|
24
|
+
|
25
|
+
group :development do
|
26
|
+
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
|
27
|
+
gem 'web-console', '>= 4.1.0'
|
28
|
+
# Display performance information such as SQL time and flame graphs for each request in your browser.
|
29
|
+
# Can be configured to work on production as well see: https://github.com/MiniProfiler/rack-mini-profiler/blob/master/README.md
|
30
|
+
gem 'rack-mini-profiler', '~> 2.0'
|
31
|
+
end
|
32
|
+
|
33
|
+
group :test do
|
34
|
+
# Adds support for Capybara system testing and selenium driver
|
35
|
+
gem 'capybara', '>= 3.26'
|
36
|
+
gem 'selenium-webdriver'
|
37
|
+
# Easy installation and use of web drivers to run system tests with browsers
|
38
|
+
# gem 'webdrivers'
|
39
|
+
end
|
40
|
+
|
41
|
+
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
42
|
+
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
|
43
|
+
|
44
|
+
gem "administrate", "~> 0.14.0"
|
45
|
+
gem "administrate-field-active_storage", path: ".."
|