rails_admin_featured_content_rails_6 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +92 -0
- data/Rakefile +2 -0
- data/app/assets/images/fc-image-default.jpg +0 -0
- data/app/assets/images/fc-loading.svg +1 -0
- data/app/assets/images/fc-snippet-float-one.jpg +0 -0
- data/app/assets/images/fc-snippet-float-one.psd +0 -0
- data/app/assets/images/fc-snippet-float-three.jpg +0 -0
- data/app/assets/images/fc-snippet-float-three.psd +0 -0
- data/app/assets/images/fc-snippet-float-two.jpg +0 -0
- data/app/assets/images/fc-snippet-float-two.psd +0 -0
- data/app/assets/images/fc-snippet-four.jpg +0 -0
- data/app/assets/images/fc-snippet-four.psd +0 -0
- data/app/assets/images/fc-snippet-highlight.jpg +0 -0
- data/app/assets/images/fc-snippet-highlight.psd +0 -0
- data/app/assets/images/fc-snippet-one.jpg +0 -0
- data/app/assets/images/fc-snippet-one.psd +0 -0
- data/app/assets/images/fc-snippet-slide.jpg +0 -0
- data/app/assets/images/fc-snippet-slide.psd +0 -0
- data/app/assets/images/fc-snippet-text-one.jpg +0 -0
- data/app/assets/images/fc-snippet-text-one.psd +0 -0
- data/app/assets/images/fc-snippet-text-three.jpg +0 -0
- data/app/assets/images/fc-snippet-text-three.psd +0 -0
- data/app/assets/images/fc-snippet-text-two.jpg +0 -0
- data/app/assets/images/fc-snippet-text-two.psd +0 -0
- data/app/assets/images/fc-snippet-text.jpg +0 -0
- data/app/assets/images/fc-snippet-text.psd +0 -0
- data/app/assets/images/fc-snippet-three.jpg +0 -0
- data/app/assets/images/fc-snippet-three.psd +0 -0
- data/app/assets/images/fc-snippet-two.jpg +0 -0
- data/app/assets/images/fc-snippet-two.psd +0 -0
- data/app/assets/javascripts/rails_admin/featured_content.js.erb +574 -0
- data/app/assets/javascripts/rails_admin/helpers/autocomplete.js +21 -0
- data/app/assets/javascripts/rails_admin/helpers/events.js +4 -0
- data/app/assets/javascripts/rails_admin/helpers/generate_radom_id.js +4 -0
- data/app/assets/javascripts/rails_admin/helpers/slide.js.erb +77 -0
- data/app/assets/javascripts/rails_admin/helpers/upload_file.js +32 -0
- data/app/assets/stylesheets/rails_admin/featured_content.scss +661 -0
- data/app/controllers/rails_admin_featured_content/featured_content_controller.rb +37 -0
- data/app/models/.keep +0 -0
- data/app/models/rails_admin_featured_content/featured_content.rb +16 -0
- data/app/models/rails_admin_featured_content/featured_content_image.rb +11 -0
- data/app/views/.gitkeep +0 -0
- data/app/views/rails_admin/main/featured_content.html.erb +113 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/config/initializers/assets.rb +15 -0
- data/config/locales/featured_content.en.yml +32 -0
- data/config/locales/featured_content.pt-BR.yml +32 -0
- data/config/routes.rb +9 -0
- data/lib/generators/rails_admin_featured_content_generator.rb +36 -0
- data/lib/generators/templates/create_featured_content_images_migration.rb +10 -0
- data/lib/generators/templates/create_featured_content_migration.rb +11 -0
- data/lib/generators/templates/featured_content_image_uploader.rb +64 -0
- data/lib/generators/templates/rails_admin_featured_content.rb +22 -0
- data/lib/rails_admin_featured_content_rails_6.rb +55 -0
- data/lib/rails_admin_featured_content_rails_6/engine.rb +22 -0
- data/lib/rails_admin_featured_content_rails_6/version.rb +3 -0
- data/rails_admin_featured_content_rails_6.gemspec +45 -0
- data/screenshots/image-1.png +0 -0
- data/vendor/assets/stylesheets/rails_admin_featured_content.scss +459 -0
- metadata +426 -0
@@ -0,0 +1,37 @@
|
|
1
|
+
module RailsAdminFeaturedContent
|
2
|
+
class FeaturedContentController < ::ApplicationController
|
3
|
+
def search_content
|
4
|
+
@content_builder = RailsAdminContentBuilder::ContentBuilder
|
5
|
+
.order('date_publish desc').limit(10).search(params[:term])
|
6
|
+
|
7
|
+
if @content_builder
|
8
|
+
render json: @content_builder.to_json(include: {
|
9
|
+
content_builder_category: {
|
10
|
+
only: [:name, :slug]
|
11
|
+
}
|
12
|
+
}
|
13
|
+
)
|
14
|
+
else
|
15
|
+
render json: @content_builder.errors
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def create_images
|
20
|
+
@featured_content = FeaturedContent.find(params[:id])
|
21
|
+
@image = @featured_content.featured_content_images
|
22
|
+
.create(image: params[:featured_content_image])
|
23
|
+
|
24
|
+
if @image
|
25
|
+
render json: find_image(@image.id)
|
26
|
+
else
|
27
|
+
render json: @image.errors
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def find_image(id)
|
34
|
+
FeaturedContentImage.find(id).image.to_json
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/app/models/.keep
ADDED
File without changes
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module RailsAdminFeaturedContent
|
2
|
+
class FeaturedContent < ActiveRecord::Base
|
3
|
+
has_many :featured_content_images, inverse_of: :featured_content, dependent: :destroy
|
4
|
+
|
5
|
+
self.table_name = 'featured_contents'
|
6
|
+
|
7
|
+
def featured_sanitized
|
8
|
+
white_list_sanitizer = Rails::Html::WhiteListSanitizer.new
|
9
|
+
white_list_sanitizer.sanitize(
|
10
|
+
self.content,
|
11
|
+
tags: %w(div h1 h2 b u p img section figure figcaption a iframe),
|
12
|
+
attributes: %w(src class alt href allowfullscreen frameborder height width)
|
13
|
+
).try(:html_safe)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module RailsAdminFeaturedContent
|
2
|
+
class FeaturedContentImage < ActiveRecord::Base
|
3
|
+
mount_uploader :image, FeaturedContentImageUploader
|
4
|
+
|
5
|
+
validates :image, presence: true
|
6
|
+
|
7
|
+
belongs_to :featured_content, inverse_of: :featured_content_images
|
8
|
+
|
9
|
+
self.table_name = 'featured_content_images'
|
10
|
+
end
|
11
|
+
end
|
data/app/views/.gitkeep
ADDED
File without changes
|
@@ -0,0 +1,113 @@
|
|
1
|
+
<%= stylesheet_link_tag 'rails_admin/featured_content' %>
|
2
|
+
<%= javascript_include_tag 'rails_admin/featured_content' %>
|
3
|
+
|
4
|
+
<div class="fc-snippet">
|
5
|
+
<%= link_to '#', class: 'fc-snippet__btn', data: {snippet: '1'} do %>
|
6
|
+
<%= image_tag 'fc-snippet-highlight.jpg', class: 'fc-snippet__image' %>
|
7
|
+
<span class="fc-snippet__caption">
|
8
|
+
<%= t('admin.actions.featured_content.snippet.targe') %>
|
9
|
+
</span>
|
10
|
+
<% end %>
|
11
|
+
|
12
|
+
<%= link_to '#', class: 'fc-snippet__btn', data: {snippet: '2'} do %>
|
13
|
+
<%= image_tag 'fc-snippet-text.jpg', class: 'fc-snippet__image' %>
|
14
|
+
<span class="fc-snippet__caption">
|
15
|
+
<%= t('admin.actions.featured_content.snippet.title_large') %>
|
16
|
+
</span>
|
17
|
+
<% end %>
|
18
|
+
|
19
|
+
<%= link_to '#', class: 'fc-snippet__btn', data: {snippet: '3'} do %>
|
20
|
+
<%= image_tag 'fc-snippet-slide.jpg', class: 'fc-snippet__image' %>
|
21
|
+
<span class="fc-snippet__caption">
|
22
|
+
<%= t('admin.actions.featured_content.snippet.slide') %>
|
23
|
+
</span>
|
24
|
+
<% end %>
|
25
|
+
|
26
|
+
<%= link_to '#', class: 'fc-snippet__btn', data: {snippet: '4'} do %>
|
27
|
+
<%= image_tag 'fc-snippet-one.jpg', class: 'fc-snippet__image' %>
|
28
|
+
<span class="fc-snippet__caption">
|
29
|
+
<%= t('admin.actions.featured_content.snippet.one') %>
|
30
|
+
</span>
|
31
|
+
<% end %>
|
32
|
+
|
33
|
+
<%= link_to '#', class: 'fc-snippet__btn', data: {snippet: '5'} do %>
|
34
|
+
<%= image_tag 'fc-snippet-two.jpg', class: 'fc-snippet__image' %>
|
35
|
+
<span class="fc-snippet__caption">
|
36
|
+
<%= t('admin.actions.featured_content.snippet.list_two') %>
|
37
|
+
</span>
|
38
|
+
<% end %>
|
39
|
+
|
40
|
+
<%= link_to '#', class: 'fc-snippet__btn', data: {snippet: '6'} do %>
|
41
|
+
<%= image_tag 'fc-snippet-three.jpg', class: 'fc-snippet__image' %>
|
42
|
+
<span class="fc-snippet__caption">
|
43
|
+
<%= t('admin.actions.featured_content.snippet.list_three') %>
|
44
|
+
</span>
|
45
|
+
<% end %>
|
46
|
+
|
47
|
+
<%= link_to '#', class: 'fc-snippet__btn', data: {snippet: '7'} do %>
|
48
|
+
<%= image_tag 'fc-snippet-four.jpg', class: 'fc-snippet__image' %>
|
49
|
+
<span class="fc-snippet__caption">
|
50
|
+
<%= t('admin.actions.featured_content.snippet.list_four') %>
|
51
|
+
</span>
|
52
|
+
<% end %>
|
53
|
+
|
54
|
+
<%= link_to '#', class: 'fc-snippet__btn', data: {snippet: '8'} do %>
|
55
|
+
<%= image_tag 'fc-snippet-float-one.jpg', class: 'fc-snippet__image' %>
|
56
|
+
<span class="fc-snippet__caption">
|
57
|
+
<%= t('admin.actions.featured_content.snippet.float_one') %>
|
58
|
+
</span>
|
59
|
+
<% end %>
|
60
|
+
|
61
|
+
<%= link_to '#', class: 'fc-snippet__btn', data: {snippet: '9'} do %>
|
62
|
+
<%= image_tag 'fc-snippet-float-two.jpg', class: 'fc-snippet__image' %>
|
63
|
+
<span class="fc-snippet__caption">
|
64
|
+
<%= t('admin.actions.featured_content.snippet.list_float_two') %>
|
65
|
+
</span>
|
66
|
+
<% end %>
|
67
|
+
|
68
|
+
<%= link_to '#', class: 'fc-snippet__btn', data: {snippet: '10'} do %>
|
69
|
+
<%= image_tag 'fc-snippet-float-three.jpg', class: 'fc-snippet__image' %>
|
70
|
+
<span class="fc-snippet__caption">
|
71
|
+
<%= t('admin.actions.featured_content.snippet.list_float_three') %>
|
72
|
+
</span>
|
73
|
+
<% end %>
|
74
|
+
|
75
|
+
<%= link_to '#', class: 'fc-snippet__btn', data: {snippet: '11'} do %>
|
76
|
+
<%= image_tag 'fc-snippet-text-one.jpg', class: 'fc-snippet__image' %>
|
77
|
+
<span class="fc-snippet__caption">
|
78
|
+
<%= t('admin.actions.featured_content.snippet.text_one') %>
|
79
|
+
</span>
|
80
|
+
<% end %>
|
81
|
+
|
82
|
+
<%= link_to '#', class: 'fc-snippet__btn', data: {snippet: '12'} do %>
|
83
|
+
<%= image_tag 'fc-snippet-text-two.jpg', class: 'fc-snippet__image' %>
|
84
|
+
<span class="fc-snippet__caption">
|
85
|
+
<%= t('admin.actions.featured_content.snippet.list_text_two') %>
|
86
|
+
</span>
|
87
|
+
<% end %>
|
88
|
+
|
89
|
+
<%= link_to '#', class: 'fc-snippet__btn', data: {snippet: '13'} do %>
|
90
|
+
<%= image_tag 'fc-snippet-text-three.jpg', class: 'fc-snippet__image' %>
|
91
|
+
<span class="fc-snippet__caption">
|
92
|
+
<%= t('admin.actions.featured_content.snippet.list_text_three') %>
|
93
|
+
</span>
|
94
|
+
<% end %>
|
95
|
+
</div>
|
96
|
+
|
97
|
+
<%= simple_form_for rails_admin.featured_content_url(@abstract_model.to_param, id: @object.id), html: { class: 'fc-form' }, remote: false do |f| %>
|
98
|
+
<div class="fc-controls">
|
99
|
+
<%= f.button :submit, "Salvar", name: 'save', class: 'btn btn-block btn-primary btn-right' %>
|
100
|
+
<% if @object.status %>
|
101
|
+
<%= f.button :submit, "Despublicar", name: 'unpublish', class: 'btn btn-block btn-danger btn-left' %>
|
102
|
+
<% else %>
|
103
|
+
<%= f.button :submit, "Publicar", name: 'publish', class: 'btn btn-block btn-success btn-left' %>
|
104
|
+
<% end %>
|
105
|
+
</div>
|
106
|
+
|
107
|
+
<div class="fc-container">
|
108
|
+
<%= @object.content.try(:html_safe) %>
|
109
|
+
</div>
|
110
|
+
|
111
|
+
<%= f.input :id, as: :hidden, :input_html => { :name => "id", :value => @object.id } %>
|
112
|
+
<%= f.input :content, as: :hidden, :input_html => { :name => "content", :id => "content", :value => @object.content } %>
|
113
|
+
<% end %>
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "rails_admin_featured_content_rails_6"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
Rails.application.config.assets.precompile += %w( fc-loading.svg )
|
2
|
+
Rails.application.config.assets.precompile += %w( fc-image-default.jpg )
|
3
|
+
Rails.application.config.assets.precompile += %w( fc-snippet-highlight.jpg )
|
4
|
+
Rails.application.config.assets.precompile += %w( fc-snippet-slide.jpg )
|
5
|
+
Rails.application.config.assets.precompile += %w( fc-snippet-text.jpg )
|
6
|
+
Rails.application.config.assets.precompile += %w( fc-snippet-one.jpg )
|
7
|
+
Rails.application.config.assets.precompile += %w( fc-snippet-two.jpg )
|
8
|
+
Rails.application.config.assets.precompile += %w( fc-snippet-three.jpg )
|
9
|
+
Rails.application.config.assets.precompile += %w( fc-snippet-four.jpg )
|
10
|
+
Rails.application.config.assets.precompile += %w( fc-snippet-float-one.jpg )
|
11
|
+
Rails.application.config.assets.precompile += %w( fc-snippet-float-two.jpg )
|
12
|
+
Rails.application.config.assets.precompile += %w( fc-snippet-float-three.jpg )
|
13
|
+
Rails.application.config.assets.precompile += %w( fc-snippet-text-one.jpg )
|
14
|
+
Rails.application.config.assets.precompile += %w( fc-snippet-text-two.jpg )
|
15
|
+
Rails.application.config.assets.precompile += %w( fc-snippet-text-three.jpg )
|
@@ -0,0 +1,32 @@
|
|
1
|
+
en:
|
2
|
+
admin:
|
3
|
+
actions:
|
4
|
+
featured_content:
|
5
|
+
title: "Create Featured Content"
|
6
|
+
menu: "Create Featured Content"
|
7
|
+
breadcrumb: "Create Featured Content"
|
8
|
+
delete_block: "Do you want to remove this content?"
|
9
|
+
success_save: "Successfully updated"
|
10
|
+
error_save: "Error updating"
|
11
|
+
written_by: "Writter By"
|
12
|
+
news_source: "News source"
|
13
|
+
summary: "Summary"
|
14
|
+
button:
|
15
|
+
save: "Save"
|
16
|
+
publish: "Publish"
|
17
|
+
unpublish: 'Unpublish'
|
18
|
+
snippet:
|
19
|
+
targe: "Targe"
|
20
|
+
title_large: "Title large"
|
21
|
+
slide: "Slide"
|
22
|
+
one: "Block image"
|
23
|
+
list_two: "List with two block image"
|
24
|
+
list_three: "List with three block image"
|
25
|
+
list_four: "List with four block image"
|
26
|
+
float_one: "Float image"
|
27
|
+
list_float_two: "List with two float image"
|
28
|
+
list_float_three: "List with three float image"
|
29
|
+
text_one: "No image"
|
30
|
+
list_text_two: "List with two no image"
|
31
|
+
list_text_three: "List with three no image"
|
32
|
+
search_news: "Search News"
|
@@ -0,0 +1,32 @@
|
|
1
|
+
pt-BR:
|
2
|
+
admin:
|
3
|
+
actions:
|
4
|
+
featured_content:
|
5
|
+
title: "Criar Destaque"
|
6
|
+
menu: "Criar Destaque"
|
7
|
+
breadcrumb: "Criar Destaque"
|
8
|
+
delete_block: "Deseja mesmo remover esse conteúdo?"
|
9
|
+
success_save: "Atualizado com sucesso"
|
10
|
+
error_save: "Erro ao atualizar"
|
11
|
+
written_by: "Autor"
|
12
|
+
news_source: "Fonte"
|
13
|
+
summary: "Resumo"
|
14
|
+
button:
|
15
|
+
save: "Salvar"
|
16
|
+
publish: "Publicar"
|
17
|
+
unpublish: 'Despublicar'
|
18
|
+
snippet:
|
19
|
+
targe: "Tarja"
|
20
|
+
title_large: "Título grande"
|
21
|
+
slide: "Slide"
|
22
|
+
one: "Imagem em bloco"
|
23
|
+
list_two: "Lista com duas em bloco"
|
24
|
+
list_three: "Lista com três em bloco"
|
25
|
+
list_four: "Lista com quatro em bloco"
|
26
|
+
float_one: "Imagem fluída"
|
27
|
+
list_float_two: "Lista com duas fluídas"
|
28
|
+
list_float_three: "Lista com três fluídas"
|
29
|
+
text_one: "Sem imagem"
|
30
|
+
list_text_two: "Lista com duas sem imagem"
|
31
|
+
list_text_three: "Lista com três sem imagem"
|
32
|
+
search_news: "Buscar Notícia"
|
data/config/routes.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
Rails.application.routes.draw do
|
2
|
+
get_path_url = 'admin/rails_admin_featured_content~featured_content/:id/search_content'
|
3
|
+
get_path_method = 'rails_admin_featured_content/featured_content#search_content'
|
4
|
+
get get_path_url => get_path_method
|
5
|
+
|
6
|
+
put_path_url = 'admin/rails_admin_featured_content~featured_content/:id/create_images'
|
7
|
+
put_path_method = 'rails_admin_featured_content/featured_content#create_images'
|
8
|
+
put put_path_url => put_path_method
|
9
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
class RailsAdminFeaturedContentGenerator < Rails::Generators::Base
|
4
|
+
include Rails::Generators::Migration
|
5
|
+
|
6
|
+
def self.source_root
|
7
|
+
@source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'templates/'))
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.next_migration_number(*)
|
11
|
+
unless @migration
|
12
|
+
@migration = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
|
13
|
+
else
|
14
|
+
@migration += 1
|
15
|
+
end
|
16
|
+
@migration.to_s
|
17
|
+
end
|
18
|
+
|
19
|
+
def create_uploader_featured_content_image_model
|
20
|
+
template "featured_content_image_uploader.rb",
|
21
|
+
"app/uploaders/featured_content_image_uploader.rb"
|
22
|
+
end
|
23
|
+
|
24
|
+
def create_rails_admin_config_in_initializer
|
25
|
+
template "rails_admin_featured_content.rb",
|
26
|
+
"config/initializers/rails_admin_featured_content.rb"
|
27
|
+
end
|
28
|
+
|
29
|
+
def create_migrations
|
30
|
+
migration_template "create_featured_content_migration.rb",
|
31
|
+
File.join('db/migrate', "create_featured_contents.rb")
|
32
|
+
|
33
|
+
migration_template "create_featured_content_images_migration.rb",
|
34
|
+
File.join('db/migrate', "create_featured_content_images.rb")
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class FeaturedContentImageUploader < CarrierWave::Uploader::Base
|
4
|
+
# Include RMagick or MiniMagick support:
|
5
|
+
# include CarrierWave::RMagick
|
6
|
+
include CarrierWave::MiniMagick
|
7
|
+
|
8
|
+
# Choose what kind of storage to use for this uploader:
|
9
|
+
if Rails.env.development? || Rails.env.test?
|
10
|
+
storage :file
|
11
|
+
else
|
12
|
+
storage :sftp
|
13
|
+
end
|
14
|
+
# storage :fog
|
15
|
+
|
16
|
+
# Override the directory where uploaded files will be stored.
|
17
|
+
# This is a sensible default for uploaders that are meant to be mounted:
|
18
|
+
def store_dir
|
19
|
+
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
20
|
+
end
|
21
|
+
|
22
|
+
# Provide a default URL as a default if there hasn't been a file uploaded:
|
23
|
+
# def default_url
|
24
|
+
# # For Rails 3.1+ asset pipeline compatibility:
|
25
|
+
# # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
|
26
|
+
#
|
27
|
+
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
|
28
|
+
# end
|
29
|
+
|
30
|
+
# Process files as they are uploaded:
|
31
|
+
# process scale: [200, 300]
|
32
|
+
#
|
33
|
+
# def scale(width, height)
|
34
|
+
# # do something
|
35
|
+
# end
|
36
|
+
|
37
|
+
# Create different versions of your uploaded files:
|
38
|
+
# Use quality to compress the image
|
39
|
+
version :thumb do
|
40
|
+
process resize_to_fit: [400, 400]
|
41
|
+
process quality: 80
|
42
|
+
end
|
43
|
+
|
44
|
+
# Add a white list of extensions which are allowed to be uploaded.
|
45
|
+
# For images you might use something like this:
|
46
|
+
def extension_whitelist
|
47
|
+
%w(jpg jpeg gif png)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Mitigate CVE-2016-3714
|
51
|
+
def content_type_whitelist
|
52
|
+
[/image\//]
|
53
|
+
end
|
54
|
+
|
55
|
+
# Override the filename of the uploaded files:
|
56
|
+
# Avoid using model.id or version_name here, see uploader/store.rb for details.
|
57
|
+
def filename
|
58
|
+
if original_filename
|
59
|
+
image_format = original_filename.match(/\.([^.]*)$/).to_a.first
|
60
|
+
image_name = original_filename.gsub(/\.([^.]*)$/, "").parameterize
|
61
|
+
return "#{image_name}#{image_format}"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
RailsAdmin.config do |config|
|
2
|
+
config.actions do
|
3
|
+
featured_content do
|
4
|
+
only ['RailsAdminFeaturedContent::FeaturedContent']
|
5
|
+
end
|
6
|
+
|
7
|
+
config.model 'RailsAdminFeaturedContent::FeaturedContent' do
|
8
|
+
list do
|
9
|
+
field :id
|
10
|
+
field :title
|
11
|
+
field :status
|
12
|
+
end
|
13
|
+
edit do
|
14
|
+
field :title
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
config.model 'RailsAdminFeaturedContent::FeaturedContentImage' do
|
19
|
+
visible false
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|