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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3cce01035ebb6d8d270b4703123e5da7d74d3dd7
4
- data.tar.gz: 73e0994b8b94bd8951d83cb1f5e8f18b3da372dc
3
+ metadata.gz: aa336e8650e210e4f08df6a0b32d57ddbe8144ac
4
+ data.tar.gz: 248f5fcfdb3441164bdeac8a0e7b7d6340427c65
5
5
  SHA512:
6
- metadata.gz: d6e1b6db8cf2ecf429006e34664ff801978150da69448abf772b2bcdaf88fa49778b1dc6819ae5108e03626271269820a60d9020634f1913fcba0c4b37eadb09
7
- data.tar.gz: a1f3d6cdb212cd5b1c36999d890ac1cda80ae4eb3f1df31b9a9ff4887decd92ce10cdbfb2ae27b04e8fd83c10e68184af710edcb64baea8eb243dccfa5ab8510
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.0"
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
- # currently we are using Rails.application.routes.url_helpers
10
- # without including the namespace because it runs into an
11
- # exception
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: administrate-field-active_storage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hamad AlGhanim