administrate-field-active_storage 0.2.1 → 0.2.2

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: 5a1843a0c5df0b671282ec4c77f631d13449509a6cec6cf045080969a020b5eb
4
- data.tar.gz: acbc64571121abbf5da1f154e7c104a657aa21c1ecee607f9c183616fa4723c4
3
+ metadata.gz: 6840d701a76b3fa5a311bb907ae5d4d78be0d16614b90d77ab7a43ad9e7dad62
4
+ data.tar.gz: ae7ad5a5636a73896296e1e5a1568aab403005e669b9f4f5a862ae3b27de20bd
5
5
  SHA512:
6
- metadata.gz: 35d06be4c51b39db656b97560c9a4b62fb058927f376c44bc8eb931d2ba23d9e309342c358905f34aa0a45617bece357376f7d076bc84386068afa396e337b9a
7
- data.tar.gz: f99b2d49769516204e9ce38a290abcfb50365a59f3a1df00a33b3753cbd9853894458fc58dac3991e10377c6bf26eb1ba2917d7d063847fc2cb9106ddbf2f525
6
+ metadata.gz: 87639eb9518a224dd5d23b500fd6372fdf96f30288ae93e4c8ffdfad0e4605eae0f02877febc85be1e79a89f7213572cf78b2f0612e560fcfe4ffdc387a676a4
7
+ data.tar.gz: 790bae3270fda0dc76594ee80414a9de7b84633aef1aca19ee60a759d272ed3f5762ff7e5b2a336fe5509e547d45f3e8345002ef2f0d99b4d2ebe56715205374
data/README.md CHANGED
@@ -4,12 +4,14 @@
4
4
  ## Things To Know:
5
5
  - To preview pdf files you need to install `mupdf` or `Poppler`.
6
6
  - To preview video files you need to install `ffmpeg`.
7
+ - To preview Office files as pictures you need to install [activestorage-office-previewer](https://github.com/basecamp/activestorage-office-previewer) by basecamp
7
8
 
8
9
  ## How To Use:
9
- Add `administrate-field-active_storage` to your Gemfile (rails 6):
10
+ Add `administrate-field-active_storage` and `mini_magick` to your Gemfile (rails 6):
10
11
 
11
12
  ```ruby
12
13
  gem 'administrate-field-active_storage'
14
+ gem 'mini_magick'
13
15
  ```
14
16
 
15
17
  for rails 5.x use the following
@@ -62,11 +64,8 @@ In order to prevent N+1 queries from active storage you have to modify your admi
62
64
  ```ruby
63
65
  module Admin
64
66
  class UsersController < Admin::ApplicationController
65
- def index
66
- super
67
- @resources = User.with_attached_avatars.
68
- page(params[:page]).
69
- per(10)
67
+ def scoped_resource
68
+ resource_class.with_attached_avatars
70
69
  end
71
70
  end
72
71
  end
@@ -121,11 +120,11 @@ end
121
120
  ```
122
121
 
123
122
  ### show_preview_size
124
- Supply the size of the image preview inside the show page check out the mini_magic documentation for resize
123
+ Supply the size of the image preview inside the show page. Check out the [mini_magic#resize_to_limit](https://github.com/janko/image_processing/blob/master/doc/minimagick.md#methods) documentation
125
124
  ```ruby
126
125
  class ModelDashboard < Administrate::BaseDashboard
127
126
  ATTRIBUTE_TYPES = {
128
- attachments: Field::ActiveStorage.with_options({show_preview_size: '150x200>'}),
127
+ attachments: Field::ActiveStorage.with_options({show_preview_size: [150, 200]}),
129
128
  # ...
130
129
  }
131
130
  # ...
@@ -156,14 +155,12 @@ Don't forget to include [ActiveStorage JavaScript](https://edgeguides.rubyonrail
156
155
  - [x] preview pdfs
157
156
  - [x] upload multiple files
158
157
  - [x] find a way to delete attachments
159
- - [ ] preview office files as pictures
158
+ - [x] preview office files as pictures
160
159
 
161
160
  ## Contribution Guide:
162
161
  1. contributers are welcome (code, suggestions, and bugs).
163
162
  2. please document your code.
164
163
  3. add your name to the `contribute.md`.
165
164
 
166
- Please note that this is my first gem :) i might have gotten some stuff wrong PR's are always welcome.
167
-
168
165
  ---
169
166
  Based on the [Administrate::Field::Image](https://github.com/thoughtbot/administrate-field-image) template, and inspired by [Administrate::Field::Paperclip](https://github.com/picandocodigo/administrate-field-paperclip).
@@ -0,0 +1 @@
1
+ theme: jekyll-theme-minimal
@@ -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.2.1"
5
+ gem.version = "0.2.2"
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"
@@ -27,20 +27,28 @@ controlled via a boolean local variable.
27
27
  image_size = local_assigns.fetch(:image_size, [1920, 1080])
28
28
  %>
29
29
 
30
- <% if attachment.image? and !field.url_only? %>
31
- <%= image_tag(field.variant(attachment, resize_to_limit: image_size)) %>
30
+ <% if attachment.image? and attachment.variable? and !field.url_only? %>
31
+ <%= link_to(field.blob_url(attachment), title: attachment.filename) do %>
32
+ <%= image_tag(field.variant(attachment, resize_to_limit: image_size)) %>
33
+ <% end %>
34
+ <% elsif attachment.image? and !field.url_only? %>
35
+ <%= link_to(field.blob_url(attachment), title: attachment.filename) do %>
36
+ <%= image_tag(field.url(attachment)) %>
37
+ <% end %>
32
38
  <% elsif attachment.video? and attachment.previewable? and !field.url_only? %> <%# if ffmpeg is installed %>
33
39
  <%= video_tag(field.url(attachment), poster: field.preview(attachment, resize_to_limit: image_size), controls: true, autobuffer: true, style: "width: 100%; height: auto;") %>
34
40
  <% elsif attachment.video? and !field.url_only? %>
35
41
  <%= video_tag(field.url(attachment), controls: true, autobuffer: true, style: "width: 100%; height: auto;") %>
36
42
  <% elsif attachment.audio? and !field.url_only? %>
37
43
  <%= audio_tag(field.url(attachment), autoplay: false, controls: true) %>
38
- <% elsif attachment.previewable? and !field.url_only? %>
39
- <%= image_tag(field.preview(attachment, resize_to_limit: [595, 842])) %>
40
- <br/>
41
- Download: <%= link_to(attachment.filename, field.blob_url(attachment)) %>
42
44
  <% else %>
43
- <%= link_to(attachment.filename, field.blob_url(attachment)) %>
45
+ <%= link_to(field.blob_url(attachment), title: attachment.filename) do %>
46
+ <% if attachment.previewable? and !field.url_only? %>
47
+ <%= image_tag(field.preview(attachment, resize_to_limit: [595, 842])) %>
48
+ <% else %>
49
+ <%= attachment.filename %>
50
+ <% end %>
51
+ <% end %>
44
52
  <% end %>
45
53
 
46
54
  <% if removable %>
@@ -9,3 +9,5 @@
9
9
  - Joé Dupuis [@twistedjoe](https://github.com/twistedjoe)
10
10
  - Eugeny Khlopin [@evgeniy-khlopin](https://github.com/evgeniy-khlopin)
11
11
  - Daniel Tinoco [@0urobor0s](https://github.com/0urobor0s)
12
+ - Matthew Hui [@mhui](https://github.com/mhui)
13
+ - Sébastien Dubois [@sedubois](https://github.com/sedubois)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: administrate-field-active_storage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hamad AlGhanim
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-27 00:00:00.000000000 Z
11
+ date: 2020-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: administrate
@@ -65,6 +65,7 @@ files:
65
65
  - LICENSE
66
66
  - README.md
67
67
  - Rakefile
68
+ - _config.yml
68
69
  - administrate-field-active_storage.gemspec
69
70
  - app/views/fields/active_storage/_form.html.erb
70
71
  - app/views/fields/active_storage/_index.html.erb