administrate-field-refile 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +7 -0
- data/Gemfile +3 -0
- data/README.md +36 -0
- data/administrate-field-refile.gemspec +21 -0
- data/app/views/fields/refile/_form.html.erb +20 -0
- data/app/views/fields/refile/_index.html.erb +16 -0
- data/app/views/fields/refile/_show.html.erb +21 -0
- data/lib/administrate/field/refile.rb +28 -0
- data/spec/lib/administrate/field/refile_spec.rb +14 -0
- metadata +83 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 43089e8e87aff06fd350932c27c19a6950652607
|
4
|
+
data.tar.gz: 3e8432762135bc928f8cd6c47a0927a2c459673d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7263381adac2b1410622533cb77a03af0d90ce07c55bbc966905b10fd10beca6cbb84fc5f43cff4dad901a7434e3955b84dbd98e2810fb5ca6f7fd5de5d469c3
|
7
|
+
data.tar.gz: f34ce374eec2079aa40a1ca555817ccad04bda73dab0de8d43e3a2e97e753457df0e9149072f85a4b914df35851358ea661dbd29a4ed44e8866f7f83144c332e
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# AdministrateRefileField
|
2
|
+
|
3
|
+
All you need to integrate Refile with Administrate.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'administrate-field-refile'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
```
|
15
|
+
$ bundle
|
16
|
+
```
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
In your Dashboard `ATTRIBUTE_TYPES` use the field type `RefileField`. i.e.
|
21
|
+
```ruby
|
22
|
+
ATTRIBUTE_TYPES = {
|
23
|
+
images_files: FieldRefile
|
24
|
+
}
|
25
|
+
```
|
26
|
+
|
27
|
+
By default all `Refile` options are false, you can set them to true like this:
|
28
|
+
```ruby
|
29
|
+
ATTRIBUTE_TYPES = {
|
30
|
+
images_files: FieldRefile.with_options(direct: true, presigned: true, multiple: true)
|
31
|
+
}
|
32
|
+
```
|
33
|
+
|
34
|
+
## Contributing
|
35
|
+
|
36
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/DisruptiveAngels/administrate_refile_field.
|
@@ -0,0 +1,21 @@
|
|
1
|
+
$:.push File.expand_path('../lib', __FILE__)
|
2
|
+
|
3
|
+
require 'administrate/field/refile'
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = 'administrate-field-refile'
|
7
|
+
gem.version = Administrate::Field::Refile::VERSION
|
8
|
+
gem.authors = ['Adrian Rangel']
|
9
|
+
gem.email = ['adrian@disruptiveangels.com']
|
10
|
+
gem.homepage = 'https://github.com/disruptiveangels/administrate-field-refile'
|
11
|
+
gem.summary = 'Add Refile fields to Administrate'
|
12
|
+
gem.description = 'Easily add Refile fields to your administrate views'
|
13
|
+
gem.license = 'MIT'
|
14
|
+
|
15
|
+
gem.require_paths = ['lib']
|
16
|
+
gem.files = `git ls-files`.split("\n")
|
17
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
|
19
|
+
gem.add_dependency 'administrate', '~> 0.1.2'
|
20
|
+
gem.add_dependency 'rails', '~> 4.2'
|
21
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<%#
|
2
|
+
# Refile Form Partial
|
3
|
+
|
4
|
+
This partial renders an attachment_field element for uloading files.
|
5
|
+
|
6
|
+
## Local variables:
|
7
|
+
|
8
|
+
- `f`:
|
9
|
+
A Rails form generator, used to help create the appropriate input fields.
|
10
|
+
- `field`:
|
11
|
+
An instance of [Administrate::Field::Refile][1].
|
12
|
+
|
13
|
+
%>
|
14
|
+
|
15
|
+
<div class="field-unit__label">
|
16
|
+
<%= f.label field.attribute %>
|
17
|
+
</div>
|
18
|
+
<div class="field-unit__field">
|
19
|
+
<%= f.attachment_field field.attribute, direct: field.direct, presigned: field.presigned, multiple: field.multiple %>
|
20
|
+
</div>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<%#
|
2
|
+
# Refile Index Partial
|
3
|
+
|
4
|
+
This partial renders a refile link to the attachment_url
|
5
|
+
to be displayed on a resource's index page.
|
6
|
+
|
7
|
+
By default, the attribute is rendered as a link tag.
|
8
|
+
|
9
|
+
## Local variables:
|
10
|
+
|
11
|
+
- `field`:
|
12
|
+
An instance of [Administrate::Field::Refile][1].
|
13
|
+
|
14
|
+
%>
|
15
|
+
|
16
|
+
<%= link_to field.attribute, attachment_url(field.parent_instance, field.attribute) %>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<%#
|
2
|
+
# Refile Show Partial
|
3
|
+
|
4
|
+
This partial renders refile attachment(s),
|
5
|
+
to be displayed on a resource's show page.
|
6
|
+
|
7
|
+
By default, the attribute is rendered as a link tag.
|
8
|
+
|
9
|
+
## Local variables:
|
10
|
+
|
11
|
+
- `field`:
|
12
|
+
An instance of [Administrate::Field::Refile][1].
|
13
|
+
%>
|
14
|
+
|
15
|
+
<% if @_requested_resource.public_send("#{field.name}").is_a?(Array) %>
|
16
|
+
<% @_requested_resource.public_send("#{field.name.split('_')[0]}").each do |photo| %>
|
17
|
+
<%= link_to photo.file_filename, attachment_url(photo, :file) %>
|
18
|
+
<% end %>
|
19
|
+
<% else %>
|
20
|
+
<%= link_to @_requested_resource.public_send("#{field.name}_filename"), attachment_url(@_requested_resource, field.attribute) %>
|
21
|
+
<% end %>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'administrate/field/base'
|
2
|
+
require 'rails'
|
3
|
+
|
4
|
+
module Administrate
|
5
|
+
module Field
|
6
|
+
class Refile < Administrate::Field::Base
|
7
|
+
VERSION = '0.0.1'
|
8
|
+
class Engine < ::Rails::Engine
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_s
|
12
|
+
data
|
13
|
+
end
|
14
|
+
|
15
|
+
def direct
|
16
|
+
options.fetch(:direct, false)
|
17
|
+
end
|
18
|
+
|
19
|
+
def presigned
|
20
|
+
options.fetch(:presigned, false)
|
21
|
+
end
|
22
|
+
|
23
|
+
def multiple
|
24
|
+
options.fetch(:multiple, false)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'administrate/field/refile'
|
2
|
+
|
3
|
+
describe Administrate::Field::Refile do
|
4
|
+
describe '#to_partial_path' do
|
5
|
+
it 'returns a partial based on the page being rendered' do
|
6
|
+
page = :show
|
7
|
+
field = Administrate::Field::Refile.new(:file, '/a.jpg', page)
|
8
|
+
|
9
|
+
path = field.to_partial_path
|
10
|
+
|
11
|
+
expect(path).to eq("/field/refile/#{page}")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: administrate-field-refile
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Adrian Rangel
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-02-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: administrate
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.1.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.1.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rails
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '4.2'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '4.2'
|
41
|
+
description: Easily add Refile fields to your administrate views
|
42
|
+
email:
|
43
|
+
- adrian@disruptiveangels.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- README.md
|
51
|
+
- administrate-field-refile.gemspec
|
52
|
+
- app/views/fields/refile/_form.html.erb
|
53
|
+
- app/views/fields/refile/_index.html.erb
|
54
|
+
- app/views/fields/refile/_show.html.erb
|
55
|
+
- lib/administrate/field/refile.rb
|
56
|
+
- spec/lib/administrate/field/refile_spec.rb
|
57
|
+
homepage: https://github.com/disruptiveangels/administrate-field-refile
|
58
|
+
licenses:
|
59
|
+
- MIT
|
60
|
+
metadata: {}
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 2.5.1
|
78
|
+
signing_key:
|
79
|
+
specification_version: 4
|
80
|
+
summary: Add Refile fields to Administrate
|
81
|
+
test_files:
|
82
|
+
- spec/lib/administrate/field/refile_spec.rb
|
83
|
+
has_rdoc:
|