viniBaxter-field-active_storage 15.0.0 → 300.0.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c4181d7b57c9417bc9d3be49393beea99da0909f2be7b1c5a0bd3a09d96bd00
4
- data.tar.gz: 538a19df914e49d3a71b66eea8cc3f3fd61bdeeaa3bbba7e31464324ee4da548
3
+ metadata.gz: d22048dd1719aafbaa1450afd38a0c25bc7011d0afc594aed93d556edb5d826c
4
+ data.tar.gz: b8c0044eebcf42b178fad52ff14f923096673fc87fb1dd61f3897441d4d7da24
5
5
  SHA512:
6
- metadata.gz: 18f9900627550206b8921b5577eceaa9087619aa3b159ee65a5373edaea213e0d0d4836a2b5ff108dc5ac5ce6df9e153abdf30c851607f376553d3086b65f611
7
- data.tar.gz: b992563fd128dcdefa02b5fd71323eafb4721b900fd72b4b5c23a48e0fd715479e881f955672d72c5eb6b7fd4646ebf1396e584557d5effe0d82817b17fc0646
6
+ metadata.gz: 8592b56fdd2b2c779b65e02227e65451b2201bcef0cee75a8044ae72a767e5d64ab07745e54a7bc6232b26bd85473d223ccbc7c63bacf7f331cf237b25ff0ae1
7
+ data.tar.gz: f68e11231bd2fd97692cf051068e7b93605729b31ec3f269a42c4ba2f81bee7b480ab57729a29d85405f84b32077b28126bd4899a51e9a1ba190a682219ab2dc
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.6.3
1
+ 3.0.3
@@ -1,19 +1,3 @@
1
- <%#
2
- # Image Form Partial
3
-
4
- This partial renders an input element for image attributes.
5
- By default, the input is a text field for the image's URL.
6
-
7
- ## Local variables:
8
-
9
- - `f`:
10
- A Rails form generator, used to help create the appropriate input fields.
11
- - `field`:
12
- An instance of [Administrate::Field::Image][1].
13
- A wrapper around the image url pulled from the database.
14
-
15
- [1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Image
16
- %>
17
1
  <div class="field-unit__label">
18
2
  <%= f.label field.attribute %>
19
3
  </div>
@@ -1,42 +1,34 @@
1
- <%#
2
- # Image Index Partial
3
-
4
- This partial renders an image attribute
5
- to be displayed on a resource's index page.
6
-
7
- By default, the attribute is rendered as an image tag.
8
-
9
- ## Local variables:
10
-
11
- - `field`:
12
- An instance of [Administrate::Field::Image][1].
13
- A wrapper around the image url pulled from the database.
14
-
15
- [1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Image
16
- %>
17
- <style>
18
- <%# figure out a way to remove this %>
19
- td img {
20
- max-height: unset !important;
21
- }
22
- </style>
23
- <%
24
- attachments = Array(field.many? ? field.attachments : field.data)
25
- %>
26
1
  <% if field.attached? %>
27
- <% if field.show_in_index? %>
28
- <%= render partial: 'fields/active_storage/normal/item',
29
- locals: {
30
- field: field,
31
- attachment: field.data,
32
- image_size: [200, 200]
33
- } %>
2
+ <style type="text/css" nonce="<%= content_security_policy_nonce %>">
3
+ <%# figure out a way to remove this %>
4
+ td img {
5
+ max-height: unset !important;
6
+ }
7
+ </style>
8
+ <% if field.index_display_preview? %>
9
+ <% if field.many? %>
10
+ <%= render partial: 'fields/active_storage/normal/items',
11
+ locals: {
12
+ many: true,
13
+ field: field,
14
+ size: field.index_preview_size
15
+ } %>
16
+ <% else %>
17
+ <%= render partial: 'fields/active_storage/normal/item',
18
+ locals: {
19
+ many: false,
20
+ field: field,
21
+ attachment: field.data,
22
+ size: field.index_preview_size
23
+ } %>
24
+ <% end %>
34
25
  <% end %>
35
26
  <% if field.index_display_count? %>
36
27
  <div class="attachments-count">
37
- <%= pluralize(field.attachments.count, 'Attachment') %>
28
+ <%= pluralize(field.attachments.count,
29
+ I18n.t("administrate.fields.active_storage.attachment", default: 'Attachment')
30
+ )
31
+ %>
38
32
  </div>
39
33
  <% end %>
40
- <% else %>
41
- 0 Attached files
42
34
  <% end %>
@@ -1,23 +1,9 @@
1
- <%#
2
- # Image Show Partial
3
-
4
- This partial renders an image attribute,
5
- to be displayed on a resource's show page.
6
-
7
- By default, the attribute is rendered as an image tag.
8
-
9
- ## Local variables:
10
-
11
- - `field`:
12
- An instance of [Administrate::Field::Image][1].
13
- A wrapper around the image url pulled from the database.
14
-
15
- [1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Image
16
- %>
17
1
  <% if field.attached? %>
18
- <% if field.show_drop_js_on_show? %>
2
+ <% if field.show_drop_js_on_show? && field.sweety_show_drop_js_on_show? %>
3
+ <%= render partial: 'fields/active_storage/drop_js/drop_js_items_if_sweety', locals: { field: field, removable: field.destroyable? } %>
4
+ <% elsif field.show_drop_js_on_show?%>
19
5
  <%= render partial: 'fields/active_storage/drop_js/drop_js_items_on_show', locals: { field: field } %>
20
- <%else %>
6
+ <% else %>
21
7
  <%= render partial: 'fields/active_storage/normal/items_on_show', locals: { field: field } %>
22
8
  <% end %>
23
9
  <% end %>
@@ -0,0 +1,57 @@
1
+ <%
2
+ attachments = Array(field.many? ? field.attachments : field.data)
3
+ removable = local_assigns.fetch(:removable, false)
4
+ %>
5
+ <div class="mt-5 col-12 ">
6
+ <div class="row">
7
+ <div class="col-12">
8
+ <div class="">
9
+ <div class="card-body">
10
+ <div class="already-downloaded dropzone">
11
+ <div class="list-group list-group-flush">
12
+ <div class="list-group-item">
13
+ <div class="row align-items-center">
14
+ <% attachments.each do |attachment| %>
15
+ <div>
16
+ <div class="" id="<%= @page.class %>_picture_<%= attachment.id %>">
17
+ <%= render partial: 'fields/active_storage/drop_js/dropjs_list_edit', locals: {
18
+ field: field,
19
+ attachment: attachment,
20
+ removable: removable,
21
+ image_size: field.show_preview_size
22
+ }%>
23
+ </div>
24
+ <div class="col ml-n2">
25
+ <small class="text-muted">
26
+ <div class="mb-1 dz-size" data-dz-size="">
27
+ <strong>
28
+ SEO: <%= alt_method(attachment) %>
29
+ </strong>
30
+ </div>
31
+ </small>
32
+ <div class="dz-error-message"><span data-dz-errormessage=""></span></div>
33
+ <!-- Text -->
34
+ <small class="text-muted">
35
+ <div class="mb-1 dz-size" data-dz-size="">
36
+ <strong>
37
+ full name : <%= attachment.filename %> |
38
+ </strong></div>
39
+ </small>
40
+ <small class="text-muted">
41
+ <div class="mb-1 dz-size" data-dz-size="">
42
+ <strong>
43
+ <%= attachment.byte_size.fdiv(1000).round(1) %>
44
+ </strong> KB</div>
45
+ </small>
46
+ </div>
47
+ </div>
48
+ <% end %>
49
+ </div>
50
+ </div>
51
+ </div>
52
+ </div>
53
+ </div>
54
+ </div>
55
+ </div>
56
+ </div>
57
+ </div>
@@ -1,35 +1,33 @@
1
- <% removable = local_assigns.fetch(:removable, false)
2
- image_size = local_assigns.fetch(:image_size, [200, 200]) %>
3
- <% if attachment.image? and attachment.variable? and !field.url_only? %>
4
- <div class="avatar avatar-lg">
5
- <%= image_tag attachment.variant(resize_to_limit: image_size), class:"avatar-img rounded"%>
1
+ <%#
2
+ # Item Partial
3
+
4
+ This partial renders attached items.
5
+
6
+ Attachments of type image, video and audio are emedded. For all other types
7
+ we try use it's preview. If all else fails we simply link to the attached file.
8
+
9
+ This partial will optionally show a `remove` link next to each attachment which is
10
+ controlled via a boolean local variable.
11
+
12
+ ## Local variables:
13
+
14
+ - `field`:
15
+ An instance of [Administrate::Field::Image].
16
+ A wrapper around the image url pulled from the database.
17
+ - `attachment`:
18
+ Reference to the file
19
+ - `removable`:
20
+ A boolean used to control the display of a `Remove` link which
21
+ is used to destroy a single attachment. Defaults to `false`
22
+ - `size`:
23
+ [x, y]
24
+ Maximum size of the ActiveStorage preview.
25
+ %>
26
+ <% if field.show_display_preview? %>
27
+ <div>
28
+ <%= render partial: 'fields/active_storage/normal/preview', locals: local_assigns %>
6
29
  </div>
7
- <% elsif attachment.image? and !field.url_only? %>
8
- <%= link_to(field.blob_url(attachment), title: attachment.filename) do %>
9
- <%= image_tag(field.url(attachment)) %>
10
- <% end %>
11
- <% elsif attachment.video? and attachment.previewable? and !field.url_only? %> <%# if ffmpeg is installed %>
12
- <%= video_tag(field.url(attachment), poster: field.preview(attachment, resize_to_limit: image_size), controls: true, autobuffer: true, style: "width: 100%; height: auto;") %>
13
- <% elsif attachment.video? and !field.url_only? %>
14
- <%= video_tag(field.url(attachment), controls: true, autobuffer: true, style: "width: 100%; height: auto;") %>
15
- <% elsif attachment.audio? and !field.url_only? %>
16
- <%= audio_tag(field.url(attachment), autoplay: false, controls: true) %>
17
- <% else %>
18
- <%= link_to(field.blob_url(attachment), title: attachment.filename) do %>
19
- <% if attachment.previewable? and !field.url_only? %>
20
- <%= image_tag(field.preview(attachment, resize_to_limit: [595, 842])) %>
21
- <% else %>
22
- <%= attachment.filename %>
23
- <% end %>
24
- <% end %>
25
- <% end %>
26
- <% if removable %>
27
- <%#= link_to 'Remove', field.destroy_path(field, attachment), method: :delete, class: 'remove-attachment-link' %>
28
- <%= link_to 'Remove', destroy_url,
29
- method: :delete,
30
- # data: { confirm: t("administrate.actions.confirm") },
31
- remote: true,
32
- class: 'remove-attachment-link'
33
- %>
34
- <hr>
35
30
  <% end %>
31
+ <div>
32
+ <%#= link_to attachment.filename, field.blob_url(attachment), title: attachment.filename %>
33
+ </div>
@@ -0,0 +1,35 @@
1
+ <%#
2
+ # Items Partial
3
+
4
+ This partial renders one or more attachments
5
+
6
+ ## Local variables:
7
+
8
+ - `field`:
9
+ An instance of [Administrate::Field::Image].
10
+ A wrapper around the image url pulled from the database.
11
+ - `removable`:
12
+ A boolean used to control the display of a `Remove` link which
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`.
18
+ %>
19
+ <%
20
+ removable = local_assigns.fetch(:removable, false)
21
+ size = local_assigns.fetch(:size, field.show_preview_size)
22
+ %>
23
+ <div class="d-flex" style="flex-wrap: wrap;">
24
+ <% field.attachments.each do |attachment| %>
25
+ <div class="attachments-listing m-1">
26
+ <%= render partial: 'fields/active_storage/normal/item',
27
+ locals: {
28
+ field: field,
29
+ attachment: attachment,
30
+ removable: removable,
31
+ size: size
32
+ } %>
33
+ </div>
34
+ <% end %>
35
+ </div>
@@ -0,0 +1,35 @@
1
+ <div id="as-field-<%= attachment.id %>">
2
+ <% if attachment.image? %>
3
+ <% if attachment.variable? %>
4
+ <div class="avatar">
5
+ <%#= image_tag attachment.variant(resize_to_limit: image_size)%>
6
+ <%= image_tag(field.variant(attachment, resize_to_limit: size), class:"avatar-img rounded") %>
7
+ </div>
8
+ <% else %>
9
+ <%= image_tag(field.url(attachment)) %>
10
+ <% end %>
11
+ <% elsif attachment.video? %>
12
+ <style type="text/css" nonce="<%= content_security_policy_nonce %>">
13
+ #as-field-video-<%= attachment.id %> {
14
+ object-fit: contain;
15
+ width: 100%;
16
+ height: 100%;
17
+ }
18
+ </style>
19
+ <% if attachment.previewable? %>
20
+ <%= video_tag(field.url(attachment),
21
+ poster: field.preview(attachment, resize_to_limit: size),
22
+ controls: true,
23
+ autobuffer: true,
24
+ id: "as-field-video-#{attachment.id}") %>
25
+ <% else %>
26
+ <%= video_tag(field.url(attachment), controls: true, autobuffer: true, id: "as-field-video-#{attachment.id}") %>
27
+ <% end %>
28
+ <% elsif attachment.audio? %>
29
+ <%= audio_tag(field.url(attachment), autoplay: false, controls: true) %>
30
+ <% elsif attachment.previewable? %>
31
+ <%= image_tag(field.preview(attachment, resize_to_limit: size)) %>
32
+ <% else %>
33
+ <%= attachment.filename %>
34
+ <% end %>
35
+ </div>
@@ -17,6 +17,22 @@ module Administrate
17
17
  # theVariant.service.send(:path_for, theVariant.key) # Absolute path to variant file
18
18
  # end
19
19
 
20
+ def index_display_preview?
21
+ options.fetch(:index_display_preview, true)
22
+ end
23
+
24
+ def index_preview_size
25
+ options.fetch(:index_preview_size, [10, 10])
26
+ end
27
+
28
+ def show_display_preview?
29
+ options.fetch(:show_display_preview, true)
30
+ end
31
+
32
+ def show_preview_size
33
+ options.fetch(:show_preview_size, [200, 200])
34
+ end
35
+
20
36
  def url_only?
21
37
  options.fetch(:url_only, false)
22
38
  end
@@ -33,10 +49,6 @@ module Administrate
33
49
  options.fetch(:index_display_count) { attached? && attachments.count != 1 }
34
50
  end
35
51
 
36
- def show_preview_size
37
- options.fetch(:show_preview_size, [1080, 1920])
38
- end
39
-
40
52
  def many?
41
53
  # find a way to use instance_of
42
54
  # data.class.name == 'ActiveStorage::Attached::Many'
@@ -47,46 +59,23 @@ module Administrate
47
59
  options.fetch(:direct_upload, false)
48
60
  end
49
61
 
50
- def drop_js?
51
- options.fetch(:drop_js, false)
52
- end
53
-
54
- def show_drop_js_on_show?
55
- options.fetch(:show_drop_js_on_show, false)
56
- end
57
-
58
- def drop_max_file?
59
- options.fetch(:drop_max_file, many? == true ? 10 : 1)
60
- end
61
-
62
- def drop_max_file_size?
63
- options.fetch(:drop_max_file_size, 10)
64
- end
65
-
66
- def drop_accepted_files?
67
- options.fetch(:drop_accepted_files, ".jpeg,.jpg,.png,.gif,.svg")
68
- end
69
-
70
62
  def destroy_url
71
63
  options.fetch(:destroy_url, nil)
72
64
  end
73
65
 
74
- # def destroy_path?
75
- # options.fetch(:destroy_path, false).present?
76
- # end
77
-
78
66
  # currently we are using Rails.application.routes.url_helpers
79
67
  # without including the namespace because it runs into an
80
68
  # exception
81
69
 
82
70
  # work around since calling data.preview(options)
83
71
  # returns "/images/<ActiveStorage::Preview>" which isnt the url
72
+
84
73
  def preview(attachment, options)
85
74
  Rails.application.routes.url_helpers.rails_representation_path(attachment.preview(options), only_path: true)
86
75
  end
87
76
 
88
77
  def variant(attachment, options)
89
- Rails.application.routes.url_helpers.rails_representation_path(attachment.variant(combine_options: options), only_path: true)
78
+ Rails.application.routes.url_helpers.rails_representation_path(attachment.variant(options), only_path: true)
90
79
  end
91
80
 
92
81
  def url(attachment)
@@ -118,6 +107,35 @@ module Administrate
118
107
  def attachments
119
108
  data.attachments if attached?
120
109
  end
110
+
111
+ # drop js
112
+
113
+ def drop_js?
114
+ options.fetch(:drop_js, false)
115
+ end
116
+
117
+ def show_drop_js_on_show?
118
+ options.fetch(:show_drop_js_on_show, false)
119
+ end
120
+
121
+ def sweety_show_drop_js_on_show?
122
+ options.fetch(:sweety_show_drop_js_on_show, false)
123
+ end
124
+
125
+ def drop_max_file?
126
+ options.fetch(:drop_max_file, many? == true ? 20 : 1)
127
+ end
128
+
129
+ def drop_max_file_size?
130
+ options.fetch(:drop_max_file_size, 50)
131
+ end
132
+
133
+ def drop_accepted_files?
134
+ options.fetch(:drop_accepted_files, ".jpeg,.jpg,.png,.svg,.gif,.pdf,.mov")
135
+ end
136
+
137
+ # end of drop js
138
+
121
139
  end
122
140
  end
123
141
  end
@@ -0,0 +1,13 @@
1
+ module ViniBaxter
2
+ # module SpaLanding
3
+ # VERSION = '15.0.0'
4
+ # end
5
+ module ViniBaxterFieldActiveStorage
6
+ MAJOR = 300
7
+ MINOR = 0
8
+ TINY = 8
9
+ PRE = "STUDIO"
10
+
11
+ VERSION = [MAJOR, MINOR, TINY].compact.join(".")
12
+ end
13
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: viniBaxter-field-active_storage
3
3
  version: !ruby/object:Gem::Version
4
- version: 15.0.0
4
+ version: 300.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - viny baxter
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-19 00:00:00.000000000 Z
11
+ date: 2022-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: administrate
@@ -69,6 +69,7 @@ files:
69
69
  - app/views/fields/active_storage/_form.html.erb
70
70
  - app/views/fields/active_storage/_index.html.erb
71
71
  - app/views/fields/active_storage/_show.html.erb
72
+ - app/views/fields/active_storage/drop_js/_drop_js_items_if_sweety.html.erb
72
73
  - app/views/fields/active_storage/drop_js/_drop_js_items_on_edit.html.erb
73
74
  - app/views/fields/active_storage/drop_js/_drop_js_items_on_show.html.erb
74
75
  - app/views/fields/active_storage/drop_js/_dropjs_items.html.erb
@@ -76,16 +77,19 @@ files:
76
77
  - app/views/fields/active_storage/drop_js/_dropjs_list_show.html.erb
77
78
  - app/views/fields/active_storage/drop_js/_dropjs_template.html.erb
78
79
  - app/views/fields/active_storage/normal/_item.html.erb
80
+ - app/views/fields/active_storage/normal/_items.html.erb
79
81
  - app/views/fields/active_storage/normal/_items_on_show.html.erb
82
+ - app/views/fields/active_storage/normal/_preview.html.erb
80
83
  - contribute.md
81
84
  - lib/viniBaxter/field/active_storage.rb
85
+ - lib/viniBaxter/version.rb
82
86
  - spec/lib/administrate/field/active_storage_spec.rb
83
87
  - viniBaxter-field-active_storage.gemspec
84
88
  homepage: https://github.com/Dreamersoul/administrate-field-active_storage
85
89
  licenses:
86
90
  - MIT
87
91
  metadata: {}
88
- post_install_message:
92
+ post_install_message:
89
93
  rdoc_options: []
90
94
  require_paths:
91
95
  - lib
@@ -100,8 +104,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
104
  - !ruby/object:Gem::Version
101
105
  version: '0'
102
106
  requirements: []
103
- rubygems_version: 3.0.3
104
- signing_key:
107
+ rubygems_version: 3.2.32
108
+ signing_key:
105
109
  specification_version: 4
106
110
  summary: Administrate fields for active storage
107
111
  test_files: