administrate-field-active_storage 0.1.0 → 0.1.1
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/administrate-field-active_storage.gemspec +1 -1
- data/app/views/fields/active_storage/_index.html.erb +1 -0
- data/app/views/fields/active_storage/_item.html.erb +5 -5
- data/app/views/fields/active_storage/_show.html.erb +1 -0
- data/lib/administrate/field/active_storage.rb +10 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa336e8650e210e4f08df6a0b32d57ddbe8144ac
|
4
|
+
data.tar.gz: 248f5fcfdb3441164bdeac8a0e7b7d6340427c65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f761ce95580dc9ea93ec59c193510ede0367df1359e97269f891e7660857e113faca84e8151f509fa57cd95a5ed068eb72bf93dc5085736cd33204c27c90516
|
7
|
+
data.tar.gz: 22b431bad7e7431734ef4aae904d2bd2b29ee411944fee524fd1d2d22e501f06d0854f8f55260bffd4b864ee90d9c1a6b84ffbf5cab18f5833a1855f5b6ceab5
|
@@ -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.1.
|
5
|
+
gem.version = "0.1.1"
|
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"
|
@@ -18,6 +18,7 @@ By default, the attribute is rendered as an image tag.
|
|
18
18
|
<% if field.many? %>
|
19
19
|
<% field.attachments.each do |attachment| %>
|
20
20
|
<%= render :partial => 'item', :field => field, :attachment => attachment %>
|
21
|
+
<br/>
|
21
22
|
<% end %>
|
22
23
|
<% else %>
|
23
24
|
<%= render :partial => 'item', :field => field, :attachment => field.data %>
|
@@ -1,12 +1,12 @@
|
|
1
|
-
<% if attachment.image? %>
|
1
|
+
<% if attachment.image? and !field.url_only? %>
|
2
2
|
<%= image_tag(field.url(attachment)) %>
|
3
|
-
<% elsif attachment.video? and attachment.previewable? %> <%# if ffmpeg is installed %>
|
3
|
+
<% elsif attachment.video? and attachment.previewable? and !field.url_only? %> <%# if ffmpeg is installed %>
|
4
4
|
<%= video_tag(field.url(attachment), poster: field.preview(attachment, resize: "1920x1080>"), controls: true, autobuffer: true, style: "width: 100%; height: auto;") %>
|
5
|
-
<% elsif attachment.video? %>
|
5
|
+
<% elsif attachment.video? and !field.url_only? %>
|
6
6
|
<%= video_tag(field.url(attachment), controls: true, autobuffer: true, style: "width: 100%; height: auto;") %>
|
7
|
-
<% elsif attachment.audio? %>
|
7
|
+
<% elsif attachment.audio? and !field.url_only? %>
|
8
8
|
<%= audio_tag(field.url(attachment), autoplay: true, controls: true) %>
|
9
|
-
<% elsif attachment.previewable? %>
|
9
|
+
<% elsif attachment.previewable? and !field.url_only? %>
|
10
10
|
<%= image_tag(field.preview(attachment, resize: "595x842>")) %>
|
11
11
|
<br/>
|
12
12
|
Download: <%= link_to(attachment.filename, field.blob_url(attachment)) %>
|
@@ -18,6 +18,7 @@ By default, the attribute is rendered as an image tag.
|
|
18
18
|
<% if field.many? %>
|
19
19
|
<% field.attachments.each do |attachment| %>
|
20
20
|
<%= render :partial => 'fields/active_storage/item', locals: { field: field, attachment: attachment } %>
|
21
|
+
<br/>
|
21
22
|
<% end %>
|
22
23
|
<% else %>
|
23
24
|
<%= render :partial => 'fields/active_storage/item', locals: { field: field, attachment: field.data } %>
|
@@ -6,16 +6,22 @@ module Administrate
|
|
6
6
|
class ActiveStorage < Administrate::Field::Base
|
7
7
|
class Engine < ::Rails::Engine
|
8
8
|
end
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
|
10
|
+
def url_only?
|
11
|
+
options.fetch(:url_only, false)
|
12
|
+
end
|
13
|
+
|
12
14
|
def many?
|
13
15
|
# find a way to use instance_of
|
14
16
|
data.class.name == "ActiveStorage::Attached::Many"
|
15
17
|
end
|
18
|
+
|
19
|
+
# currently we are using Rails.application.routes.url_helpers
|
20
|
+
# without including the namespace because it runs into an
|
21
|
+
# exception
|
22
|
+
|
16
23
|
# work around since calling data.preview(options)
|
17
24
|
# returns "/images/<ActiveStorage::Preview>" which isnt the url
|
18
|
-
|
19
25
|
def preview(attachment, options)
|
20
26
|
Rails.application.routes.url_helpers.rails_representation_path(attachment.preview(options), only_path: true)
|
21
27
|
end
|