trestle-active_storage 0.0.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 50cc7a1ff90ab38d8f8abc8b2586447a41431f537d87686e1f21ca0f2bd7e44c
4
- data.tar.gz: a44acd224be364941ea78a69ba53288ab24e5e0b2bd838f6c55becab2ff3592d
3
+ metadata.gz: d7afe155600a65f0a430762dd74d885234377f3f4587c08813f3a7b8ab2ef9e2
4
+ data.tar.gz: ac66a74dac13db2f3df90b0c30591d135780f0036c9e9923a194045c5ef8074a
5
5
  SHA512:
6
- metadata.gz: 170ed9f8a485d885cc1fa4c7682e7865e18cfc8ee4cfcf26b4a9417c8773436deb52012ad0079e54f68fa501eb304da8e148a3131fdde3777c3ac433d4b6d643
7
- data.tar.gz: 7020a30b055329ed3ff6ee3cc963b3edb6d458defc49f6e538312332d2bb79be8a1872095064ce4fc3e9d1b0ae61c35bb7be0cca13ffbadfb6b663427e6ae815
6
+ metadata.gz: 9023b24a2bda93e2441cbce24eea0bfe70dc964b5b0702fabb4b33cc1f0aa45c33d22ceca066ffd0ae152a475a63717d76479085432badd376dd7266662a1c44
7
+ data.tar.gz: b9472272e26f4b3643830247b3ae5e10037aa83a71143a612877e7aaeca1f7d34489a78a752152eba00020b3171092c0e8261dfa6a52f1e6cf43bc07908624cb
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
- # Trestle ActiveStorage Integration (trestle-active_storage)
1
+ # Trestle Active Storage Integration (trestle-active_storage)
2
2
 
3
- > [ActiveStorage](https://github.com/rails/rails/tree/master/activestorage#active-storage) integration plugin for the [Trestle admin framework](https://trestle.io)
3
+ > [Active Storage](https://guides.rubyonrails.org/active_storage_overview.html) integration plugin for the [Trestle admin framework](https://trestle.io)
4
+
5
+ [![Gem](https://img.shields.io/gem/v/trestle-active_storage.svg)](https://rubygems.org/gems/trestle-active_storage)
4
6
 
5
7
  ## Usage
6
8
 
@@ -31,10 +33,17 @@ gem 'trestle-active_storage'
31
33
 
32
34
  Run `bundle install`, and then restart your Rails server.
33
35
 
34
- ## Wishlist
36
+ ### Active Storage previews
37
+
38
+ This plugin shows previews of uploaded files if your system meets the requirements. For more information please [consult the Ruby on Rails guides](https://edgeguides.rubyonrails.org/active_storage_overview.html#previewing-files).
39
+
40
+ If you'd like to get up and running on Heroku, check out their [documentation on Active Storage on Heroku](https://devcenter.heroku.com/articles/active-storage-on-heroku#attachment-previews). The [Ruby on Rails Development Dependencies Install guide](https://edgeguides.rubyonrails.org/development_dependencies_install.html#active-storage-setup) outlines how to install the neccessary dependencies to get previews working locally.
41
+
42
+ ## TODO / Wishlist
35
43
 
36
44
  - [ ] Support for `has_many_attached` attachments
37
- - [ ] Support for [ActiveStorage previews](https://api.rubyonrails.org/v5.2/classes/ActiveStorage/Previewer.html)
45
+ - [x] Support for Active Storage previews
46
+ - [ ] Preview of selected local file ([#1](https://github.com/richardvenneman/trestle-active_storage/issues/1))
38
47
  - [ ] Integration tests
39
48
 
40
49
  ## License
@@ -12,7 +12,6 @@ Trestle.ready(function() {
12
12
  var progressBarEl = field.parentNode.querySelectorAll(".progress-bar")[0];
13
13
 
14
14
  field.addEventListener("direct-upload:start", function(event) {
15
- var detail = event.detail;
16
15
  progressEl.style = "display: block";
17
16
  });
18
17
 
@@ -1,12 +1,19 @@
1
1
  <div class="active-storage">
2
2
  <% if attachment.attached? %>
3
3
  <div class="active-storage__preview">
4
- <% if attachment.blob.image? %>
5
- <%= link_to image_tag(main_app.rails_blob_url(attachment), class: 'active-storage__image'),
6
- main_app.rails_blob_url(attachment), target: 'blank' %>
4
+ <% if attachment.previewable? %>
5
+ <%= link_to image_tag(main_app.url_for(attachment.preview(resize: "300x300>")), class: "active-storage__image"),
6
+ main_app.rails_blob_path(attachment, disposition: "attachment") %>
7
+ <% elsif attachment.variable? %>
8
+ <%= link_to image_tag(main_app.url_for(attachment.variant(resize: "300x300>")), class: "active-storage__image"),
9
+ main_app.rails_blob_path(attachment, disposition: "attachment") %>
7
10
  <% else %>
8
- <%= link_to(main_app.rails_blob_url(attachment), class: 'active-storage__link') %>
11
+ <%= link_to main_app.rails_blob_path(attachment, disposition: "attachment"), class: "btn btn-info" do %>
12
+ <i class="fa fa-download"></i>
13
+ <span class="btn-label">Download <%= field_name %></span>
14
+ <% end %>
9
15
  <% end %>
16
+ <div><small><%= attachment.blob.filename %></small></div>
10
17
  </div>
11
18
 
12
19
  <%= builder.check_box("delete_#{field_name}", label: "Delete #{field_name}") %>
@@ -1,5 +1,5 @@
1
1
  module Trestle
2
2
  module ActiveStorage
3
- VERSION = '0.0.1'
3
+ VERSION = '2.0.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trestle-active_storage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Venneman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-28 00:00:00.000000000 Z
11
+ date: 2018-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails