administrate-field-carrierwave 0.0.3 → 0.1.0
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/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/README.md +3 -2
- data/administrate-field-carrierwave.gemspec +1 -1
- data/app/views/fields/carrierwave/_file.html.erb +1 -0
- data/app/views/fields/carrierwave/_form.html.erb +4 -8
- data/app/views/fields/carrierwave/_index.html.erb +6 -2
- data/app/views/fields/carrierwave/_preview.html.erb +1 -3
- data/app/views/fields/carrierwave/_show.html.erb +19 -4
- data/lib/administrate/field/carrierwave.rb +9 -6
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7be62a38a3fac45a480819d4857ff3fa59e60d9b
|
4
|
+
data.tar.gz: 7d12584f15145b96a35d959ab74e198003076c36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a95819b7c3b8f5a3d6944a1f9f558b83425a8cf3ff02c435bec54c3dbf116760250722f8a06f3df35abc9363d0c5665d26fa0f06c42c4d571a4538926bede6e7
|
7
|
+
data.tar.gz: 32d07b5b76e3bf6e4b776f3d067c71b6b8f4b0fb208dbe1dbc147d522b18ecec87cd17b0544b48df9638cf363442ea4b6573e5ad6445456e9fa07a9bd258a6c1
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v0.1.0](https://github.com/z-productions/administrate-field-carrierwave/tree/v0.1.0) (2016-11-30)
|
4
|
+
[Full Changelog](https://github.com/z-productions/administrate-field-carrierwave/compare/v0.0.3...v0.1.0)
|
5
|
+
|
6
|
+
* Add support for multiple files
|
7
|
+
|
3
8
|
## [v0.0.3](https://github.com/z-productions/administrate-field-carrierwave/tree/v0.0.3) (2016-11-29)
|
4
9
|
[Full Changelog](https://github.com/z-productions/administrate-field-carrierwave/compare/v0.0.2...v0.0.3)
|
5
10
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -9,7 +9,7 @@ A plugin to upload and preview Carrierwave attachments in [Administrate].
|
|
9
9
|
Add it to your `Gemfile`:
|
10
10
|
|
11
11
|
```ruby
|
12
|
-
gem 'administrate-field-carrierwave', '~> 0.0
|
12
|
+
gem 'administrate-field-carrierwave', '~> 0.1.0'
|
13
13
|
```
|
14
14
|
|
15
15
|
Run:
|
@@ -22,12 +22,13 @@ Add to your `FooDashboard`:
|
|
22
22
|
|
23
23
|
```ruby
|
24
24
|
ATTRIBUTE_TYPES = {
|
25
|
-
bar: Field::Carrierwave.with_options(image: :standard)
|
25
|
+
bar: Field::Carrierwave.with_options(image: :standard, multiple: true)
|
26
26
|
}.freeze
|
27
27
|
```
|
28
28
|
### Options
|
29
29
|
|
30
30
|
* `image` (default: `nil`): a [version] that will be displayed in an `<img>` element.
|
31
|
+
* `multiple` (default: `false`): allows uploading of multiple files. **ATTENTION 🚨**: [requires CarrierWave’s `master` branch](https://github.com/carrierwaveuploader/carrierwave#multiple-file-uploads). Uploaded files will replace the current ones – if present – and not add to them.
|
31
32
|
|
32
33
|
## About
|
33
34
|
|
@@ -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-carrierwave'
|
5
|
-
gem.version = '0.0
|
5
|
+
gem.version = '0.1.0'
|
6
6
|
gem.authors = ['Michele Gerarduzzi']
|
7
7
|
gem.email = ['michele.gerarduzzi@gmail.com']
|
8
8
|
gem.homepage = 'https://github.com/z-productions/administrate-field-carrierwave'
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= link_to (file.filename || file.path).split('/').last, file.url, target: '_blank' %>
|
@@ -1,7 +1,8 @@
|
|
1
1
|
<%#
|
2
2
|
# Carrierwave Form Partial
|
3
3
|
|
4
|
-
This partial renders a file input field
|
4
|
+
This partial renders a file input field and a summary of the current
|
5
|
+
attachment(s) for this attribute
|
5
6
|
|
6
7
|
## Local variables:
|
7
8
|
|
@@ -16,12 +17,7 @@ This partial renders a file input field.
|
|
16
17
|
<%= f.label field.attribute %>
|
17
18
|
</div>
|
18
19
|
<div class="field-unit__field">
|
19
|
-
<%= f.file_field field.attribute %>
|
20
|
+
<%= f.file_field field.attribute, multiple: field.multiple? %>
|
20
21
|
<br />
|
21
|
-
|
22
|
-
<%= render 'fields/carrierwave/preview', field: field %>
|
23
|
-
<%= link_to field.basename, field.url, title: field.filename, target: '_blank' %>
|
24
|
-
<%- else -%>
|
25
|
-
<span>No file uploaded yet</span>
|
26
|
-
<%- end -%>
|
22
|
+
<%= render 'fields/carrierwave/show', field: field %>
|
27
23
|
</div>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# Carrierwave Index Partial
|
3
3
|
|
4
4
|
This partial renders the URL of the attachment as a link that
|
5
|
-
opens in a new window/tab
|
5
|
+
opens in a new window/tab, or the total number of attached files
|
6
6
|
|
7
7
|
## Local variables:
|
8
8
|
|
@@ -11,4 +11,8 @@ opens in a new window/tab
|
|
11
11
|
A wrapper around the attribute pulled from the database.
|
12
12
|
%>
|
13
13
|
|
14
|
-
|
14
|
+
<% if field.multiple? %>
|
15
|
+
<%= pluralize(field.files.size, field.attribute.to_s.humanize.downcase) %>
|
16
|
+
<% else %>
|
17
|
+
<%= link_to 'View', field.file.url, title: field.file.filename, target: '_blank' %>
|
18
|
+
<% end %>
|
@@ -1,8 +1,8 @@
|
|
1
1
|
<%#
|
2
2
|
# Carrierwave Show Partial
|
3
3
|
|
4
|
-
This partial renders
|
5
|
-
|
4
|
+
This partial renders a summary of the current attachment(s)
|
5
|
+
for this attribute
|
6
6
|
|
7
7
|
## Local variables:
|
8
8
|
|
@@ -11,5 +11,20 @@ opens in a new window/tab, and an optional image preview
|
|
11
11
|
A wrapper around the attribute pulled from the database.
|
12
12
|
%>
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
<% if field.multiple? %>
|
15
|
+
<% if field.files.any? %>
|
16
|
+
<ul>
|
17
|
+
<%- field.files.each do |file| %>
|
18
|
+
<li><%= render 'fields/carrierwave/file', file: file %></li>
|
19
|
+
<% end %>
|
20
|
+
</ul>
|
21
|
+
<% else %>
|
22
|
+
<span>No file(s) uploaded yet</span>
|
23
|
+
<% end %>
|
24
|
+
<% else %>
|
25
|
+
<% if field.image.present? %>
|
26
|
+
<%= render 'fields/carrierwave/preview', file: field.file, field: field %>
|
27
|
+
<% else %>
|
28
|
+
<%= render 'fields/carrierwave/file', file: field.file %>
|
29
|
+
<% end %>
|
30
|
+
<% end %>
|
@@ -6,18 +6,21 @@ module Administrate
|
|
6
6
|
class Carrierwave < Administrate::Field::Base
|
7
7
|
class Engine < ::Rails::Engine; end
|
8
8
|
|
9
|
-
delegate :url, :filename, to: :data, allow_nil: true
|
10
|
-
|
11
9
|
def image
|
12
10
|
options.fetch(:image, nil)
|
13
11
|
end
|
14
12
|
|
15
|
-
def
|
16
|
-
|
13
|
+
def multiple?
|
14
|
+
options.fetch(:multiple, false)
|
15
|
+
end
|
16
|
+
|
17
|
+
# One-element array when single file field, array of files when multiple
|
18
|
+
def files
|
19
|
+
Array[*data]
|
17
20
|
end
|
18
21
|
|
19
|
-
def
|
20
|
-
|
22
|
+
def file
|
23
|
+
files.first
|
21
24
|
end
|
22
25
|
end
|
23
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: administrate-field-carrierwave
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michele Gerarduzzi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: administrate
|
@@ -52,6 +52,7 @@ files:
|
|
52
52
|
- LICENSE.md
|
53
53
|
- README.md
|
54
54
|
- administrate-field-carrierwave.gemspec
|
55
|
+
- app/views/fields/carrierwave/_file.html.erb
|
55
56
|
- app/views/fields/carrierwave/_form.html.erb
|
56
57
|
- app/views/fields/carrierwave/_index.html.erb
|
57
58
|
- app/views/fields/carrierwave/_preview.html.erb
|