rails_admin_content_builder_rails_6 1.0.0
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 +134 -0
- data/Rakefile +2 -0
- data/app/assets/images/cb-image-default.jpg +0 -0
- data/app/assets/images/cb-loading.svg +1 -0
- data/app/assets/images/cb-snippet-gallery.jpg +0 -0
- data/app/assets/images/cb-snippet-gallery.psd +0 -0
- data/app/assets/images/cb-snippet-image-text.jpg +0 -0
- data/app/assets/images/cb-snippet-image-text.psd +0 -0
- data/app/assets/images/cb-snippet-image.jpg +0 -0
- data/app/assets/images/cb-snippet-image.psd +0 -0
- data/app/assets/images/cb-snippet-quote-text.jpg +0 -0
- data/app/assets/images/cb-snippet-quote-text.psd +0 -0
- data/app/assets/images/cb-snippet-quote.jpg +0 -0
- data/app/assets/images/cb-snippet-quote.psd +0 -0
- data/app/assets/images/cb-snippet-relational-text.jpg +0 -0
- data/app/assets/images/cb-snippet-relational-text.psd +0 -0
- data/app/assets/images/cb-snippet-text-image.jpg +0 -0
- data/app/assets/images/cb-snippet-text-image.psd +0 -0
- data/app/assets/images/cb-snippet-text-quote.jpg +0 -0
- data/app/assets/images/cb-snippet-text-quote.psd +0 -0
- data/app/assets/images/cb-snippet-text-relational.jpg +0 -0
- data/app/assets/images/cb-snippet-text-relational.psd +0 -0
- data/app/assets/images/cb-snippet-text.jpg +0 -0
- data/app/assets/images/cb-snippet-text.psd +0 -0
- data/app/assets/images/cb-snippet-video.jpg +0 -0
- data/app/assets/images/cb-snippet-video.psd +0 -0
- data/app/assets/images/cb-video-default.jpg +0 -0
- data/app/assets/javascripts/rails_admin/content_builder.js.erb +374 -0
- data/app/assets/javascripts/rails_admin/helpers/action_sortable.js +16 -0
- data/app/assets/javascripts/rails_admin/helpers/add_event_to_input.js +9 -0
- data/app/assets/javascripts/rails_admin/helpers/autocomplete.js.erb +32 -0
- data/app/assets/javascripts/rails_admin/helpers/file_select_and_upload.js +31 -0
- data/app/assets/javascripts/rails_admin/helpers/file_select_and_upload_gallery.js +43 -0
- data/app/assets/javascripts/rails_admin/helpers/generate_id.js +4 -0
- data/app/assets/javascripts/rails_admin/helpers/get_image_of_position.js +11 -0
- data/app/assets/javascripts/rails_admin/helpers/medium_editor.js +44 -0
- data/app/assets/javascripts/rails_admin/helpers/scrool_to.js +8 -0
- data/app/assets/javascripts/rails_admin/helpers/youtube_parse.js.erb +11 -0
- data/app/assets/stylesheets/rails_admin/content_builder.scss +534 -0
- data/app/controllers/rails_admin_content_builder/content_builder_controller.rb +39 -0
- data/app/helpers/rails_admin_content_builder/content_builder_helpers.rb +38 -0
- data/app/models/application_record.rb +3 -0
- data/app/models/rails_admin_content_builder/content_builder.rb +45 -0
- data/app/models/rails_admin_content_builder/content_builder_category.rb +12 -0
- data/app/models/rails_admin_content_builder/content_builder_image.rb +11 -0
- data/app/views/.gitkeep +0 -0
- data/app/views/rails_admin/main/content_builder.html.erb +102 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/config/initializers/assets.rb +14 -0
- data/config/locales/content_builder.en.yml +32 -0
- data/config/locales/content_builder.pt-BR.yml +32 -0
- data/config/routes.rb +9 -0
- data/lib/rails_admin_content_builder_rails_6.rb +55 -0
- data/lib/rails_admin_content_builder_rails_6/engine.rb +24 -0
- data/lib/rails_admin_content_builder_rails_6/generators/rails_admin_content_builder_generator.rb +40 -0
- data/lib/rails_admin_content_builder_rails_6/generators/templates/content_builder_image_uploader.rb +90 -0
- data/lib/rails_admin_content_builder_rails_6/generators/templates/create_content_builder_category_migration.rb +10 -0
- data/lib/rails_admin_content_builder_rails_6/generators/templates/create_content_builder_image_migration.rb +10 -0
- data/lib/rails_admin_content_builder_rails_6/generators/templates/create_content_builder_migration.rb +16 -0
- data/lib/rails_admin_content_builder_rails_6/generators/templates/rails_admin_content_builder.rb +37 -0
- data/lib/rails_admin_content_builder_rails_6/version.rb +3 -0
- data/rails_admin_content_builder_rails_6.gemspec +45 -0
- data/vendor/assets/stylesheets/rails_admin_content_builder.scss +411 -0
- metadata +417 -0
@@ -0,0 +1,39 @@
|
|
1
|
+
module RailsAdminContentBuilder
|
2
|
+
# This class
|
3
|
+
class ContentBuilderController < ::ApplicationController
|
4
|
+
def search_content
|
5
|
+
content_builder = RailsAdminContentBuilder::ContentBuilder
|
6
|
+
@content_builder = content_builder.order('date_publish desc')
|
7
|
+
.limit(10)
|
8
|
+
.search(params[:term])
|
9
|
+
|
10
|
+
if @content_builder
|
11
|
+
render json: @content_builder.to_json(include: {
|
12
|
+
content_builder_category: {
|
13
|
+
only: [:name, :slug]
|
14
|
+
}
|
15
|
+
})
|
16
|
+
else
|
17
|
+
render json: @content_builder.errors
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def create_images
|
22
|
+
@content_builder = ContentBuilder.find(params[:id])
|
23
|
+
@image = @content_builder.content_builder_images
|
24
|
+
.create(image: params[:content_builder_image])
|
25
|
+
|
26
|
+
if @image.valid?
|
27
|
+
render json: find_image(@image.id)
|
28
|
+
else
|
29
|
+
render json: @image.errors
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def find_image(id)
|
36
|
+
ContentBuilderImage.find(id).image.to_json
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# Add ContentHelper in your Controller
|
2
|
+
#
|
3
|
+
# class PostsController < ApplicationController
|
4
|
+
# include RailsAdminContentBuilder::ContentBuilderHelpers
|
5
|
+
#
|
6
|
+
# def index
|
7
|
+
# end
|
8
|
+
# end
|
9
|
+
module RailsAdminContentBuilder
|
10
|
+
# This is a Module
|
11
|
+
module ContentBuilderHelpers
|
12
|
+
# Return content Object
|
13
|
+
#
|
14
|
+
# @content = content_created
|
15
|
+
def content_created
|
16
|
+
set_content_builder
|
17
|
+
end
|
18
|
+
|
19
|
+
# Return all contents created
|
20
|
+
#
|
21
|
+
# @content = all_contents_created
|
22
|
+
def all_contents_created
|
23
|
+
set_content_builder.where(status: true)
|
24
|
+
end
|
25
|
+
|
26
|
+
# Return specific contents created by slug
|
27
|
+
#
|
28
|
+
# @content = find_content_created_by_slug('slug')
|
29
|
+
def find_content_created_by_slug(slug)
|
30
|
+
set_content_builder.where(status: true, slug: slug).first
|
31
|
+
end
|
32
|
+
|
33
|
+
# Return object RailsAdminContentBuilder::ContentBuilder
|
34
|
+
def set_content_builder
|
35
|
+
RailsAdminContentBuilder::ContentBuilder
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module RailsAdminContentBuilder
|
2
|
+
class ContentBuilder < ApplicationRecord
|
3
|
+
include SearchCop
|
4
|
+
|
5
|
+
validates :title, :date_publish, :content_builder_category, :written_by,
|
6
|
+
presence: true
|
7
|
+
|
8
|
+
extend FriendlyId
|
9
|
+
friendly_id :title, use: :slugged
|
10
|
+
|
11
|
+
has_many :content_builder_images, inverse_of: :content_builder,
|
12
|
+
dependent: :destroy
|
13
|
+
belongs_to :content_builder_category, inverse_of: :content_builders
|
14
|
+
|
15
|
+
self.table_name = 'content_builders'
|
16
|
+
|
17
|
+
search_scope :search do
|
18
|
+
attributes :title
|
19
|
+
end
|
20
|
+
|
21
|
+
def content_sanitized
|
22
|
+
content.gsub!(/<div class="cb-tools([\s\S]*?)<\/div>/, "")
|
23
|
+
|
24
|
+
white_list_sanitizer = Rails::Html::WhiteListSanitizer.new
|
25
|
+
white_list_sanitizer.sanitize(
|
26
|
+
content,
|
27
|
+
tags: tags_hash,
|
28
|
+
attributes: attributes_hash
|
29
|
+
).try(:html_safe)
|
30
|
+
end
|
31
|
+
|
32
|
+
def tags_hash
|
33
|
+
%w(
|
34
|
+
div b i a u p img figure figcaption a iframe footer aside
|
35
|
+
section blockquote ul ol li h1 h2 h3 h4 h5 h6
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
39
|
+
def attributes_hash
|
40
|
+
%w(
|
41
|
+
src class alt href allowfullscreen frameborder height width
|
42
|
+
)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module RailsAdminContentBuilder
|
2
|
+
class ContentBuilderCategory < ApplicationRecord
|
3
|
+
validates :name, presence: true
|
4
|
+
|
5
|
+
has_many :content_builders, inverse_of: :content_builder_category
|
6
|
+
|
7
|
+
extend FriendlyId
|
8
|
+
friendly_id :name, use: :slugged
|
9
|
+
|
10
|
+
self.table_name = 'content_builder_categories'
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module RailsAdminContentBuilder
|
2
|
+
class ContentBuilderImage < ApplicationRecord
|
3
|
+
mount_uploader :image, ContentBuilderImageUploader
|
4
|
+
|
5
|
+
validates :image, presence: true
|
6
|
+
|
7
|
+
belongs_to :content_builder, inverse_of: :content_builder_images
|
8
|
+
|
9
|
+
self.table_name = 'content_builder_images'
|
10
|
+
end
|
11
|
+
end
|
data/app/views/.gitkeep
ADDED
File without changes
|
@@ -0,0 +1,102 @@
|
|
1
|
+
<%= stylesheet_link_tag 'rails_admin/content_builder' %>
|
2
|
+
<%= javascript_include_tag 'rails_admin/content_builder' %>
|
3
|
+
|
4
|
+
<div class="cb-snippet">
|
5
|
+
<%= link_to '#', class: 'cb-snippet__btn', data: {snippet: '1'} do %>
|
6
|
+
<%= image_tag 'cb-snippet-text.jpg', class: 'cb-snippet__image' %>
|
7
|
+
<span class="cb-snippet__caption">
|
8
|
+
<%= t('admin.actions.content_builder.snippet.text') %>
|
9
|
+
</span>
|
10
|
+
<% end %>
|
11
|
+
|
12
|
+
<%= link_to '#', class: 'cb-snippet__btn', data: {snippet: '2'} do %>
|
13
|
+
<%= image_tag 'cb-snippet-image-text.jpg', class: 'cb-snippet__image' %>
|
14
|
+
<span class="cb-snippet__caption">
|
15
|
+
<%= t('admin.actions.content_builder.snippet.image_left') %>
|
16
|
+
</span>
|
17
|
+
<% end %>
|
18
|
+
|
19
|
+
<%= link_to '#', class: 'cb-snippet__btn', data: {snippet: '3'} do %>
|
20
|
+
<%= image_tag 'cb-snippet-text-image.jpg', class: 'cb-snippet__image' %>
|
21
|
+
<span class="cb-snippet__caption">
|
22
|
+
<%= t('admin.actions.content_builder.snippet.image_right') %>
|
23
|
+
</span>
|
24
|
+
<% end %>
|
25
|
+
|
26
|
+
<%= link_to '#', class: 'cb-snippet__btn', data: {snippet: '4'} do %>
|
27
|
+
<%= image_tag 'cb-snippet-image.jpg', class: 'cb-snippet__image' %>
|
28
|
+
<span class="cb-snippet__caption">
|
29
|
+
<%= t('admin.actions.content_builder.snippet.image_center') %>
|
30
|
+
</span>
|
31
|
+
<% end %>
|
32
|
+
|
33
|
+
<%= link_to '#', class: 'cb-snippet__btn', data: {snippet: '5'} do %>
|
34
|
+
<%= image_tag 'cb-snippet-video.jpg', class: 'cb-snippet__image' %>
|
35
|
+
<span class="cb-snippet__caption">
|
36
|
+
<%= t('admin.actions.content_builder.snippet.video') %>
|
37
|
+
</span>
|
38
|
+
<% end %>
|
39
|
+
|
40
|
+
<%= link_to '#', class: 'cb-snippet__btn', data: {snippet: '6'} do %>
|
41
|
+
<%= image_tag 'cb-snippet-quote-text.jpg', class: 'cb-snippet__image' %>
|
42
|
+
<span class="cb-snippet__caption">
|
43
|
+
<%= t('admin.actions.content_builder.snippet.blockquote_right') %>
|
44
|
+
</span>
|
45
|
+
<% end %>
|
46
|
+
|
47
|
+
<%= link_to '#', class: 'cb-snippet__btn', data: {snippet: '7'} do %>
|
48
|
+
<%= image_tag 'cb-snippet-text-quote.jpg', class: 'cb-snippet__image' %>
|
49
|
+
<span class="cb-snippet__caption">
|
50
|
+
<%= t('admin.actions.content_builder.snippet.blockquote_left') %>
|
51
|
+
</span>
|
52
|
+
<% end %>
|
53
|
+
|
54
|
+
<%= link_to '#', class: 'cb-snippet__btn', data: {snippet: '8'} do %>
|
55
|
+
<%= image_tag 'cb-snippet-quote.jpg', class: 'cb-snippet__image' %>
|
56
|
+
<span class="cb-snippet__caption">
|
57
|
+
<%= t('admin.actions.content_builder.snippet.blockquote_center') %>
|
58
|
+
</span>
|
59
|
+
<% end %>
|
60
|
+
|
61
|
+
<% if(!(ENV['RAILS_ADMIN_CONTENT_BUILDER_RELATED'].present? &&
|
62
|
+
ENV['RAILS_ADMIN_CONTENT_BUILDER_RELATED'] == "false")) %>
|
63
|
+
<%= link_to '#', class: 'cb-snippet__btn', data: {snippet: '9'} do %>
|
64
|
+
<%= image_tag 'cb-snippet-relational-text.jpg', class: 'cb-snippet__image' %>
|
65
|
+
<span class="cb-snippet__caption">
|
66
|
+
<%= t('admin.actions.content_builder.snippet.related_content_right') %>
|
67
|
+
</span>
|
68
|
+
<% end %>
|
69
|
+
|
70
|
+
<%= link_to '#', class: 'cb-snippet__btn', data: {snippet: '10'} do %>
|
71
|
+
<%= image_tag 'cb-snippet-text-relational.jpg', class: 'cb-snippet__image' %>
|
72
|
+
<span class="cb-snippet__caption">
|
73
|
+
<%= t('admin.actions.content_builder.snippet.related_content_left') %>
|
74
|
+
</span>
|
75
|
+
<% end %>
|
76
|
+
<% end %>
|
77
|
+
|
78
|
+
<%= link_to '#', class: 'cb-snippet__btn', data: {snippet: '11'} do %>
|
79
|
+
<%= image_tag 'cb-snippet-gallery.jpg', class: 'cb-snippet__image' %>
|
80
|
+
<span class="cb-snippet__caption">
|
81
|
+
<%= t('admin.actions.content_builder.snippet.gallery') %>
|
82
|
+
</span>
|
83
|
+
<% end %>
|
84
|
+
</div>
|
85
|
+
|
86
|
+
<%= simple_form_for rails_admin.content_builder_url(@abstract_model.to_param, id: @object.id), html: { class: 'cb-form' }, remote: false do |f| %>
|
87
|
+
<div class="cb-controls">
|
88
|
+
<%= f.button :submit, t('admin.actions.content_builder.button.save'), name: 'save', class: 'btn btn-block btn-primary btn-right' %>
|
89
|
+
<% if @object.status %>
|
90
|
+
<%= f.button :submit, t('admin.actions.content_builder.button.unpublish'), name: 'unpublish', class: 'btn btn-block btn-danger btn-left' %>
|
91
|
+
<% else %>
|
92
|
+
<%= f.button :submit, t('admin.actions.content_builder.button.publish'), name: 'publish', class: 'btn btn-block btn-success btn-left' %>
|
93
|
+
<% end %>
|
94
|
+
</div>
|
95
|
+
|
96
|
+
<div id="cb-container">
|
97
|
+
<%= @object.content.try(:html_safe) %>
|
98
|
+
</div>
|
99
|
+
|
100
|
+
<%= f.input :id, as: :hidden, :input_html => { :name => "id", :value => @object.id } %>
|
101
|
+
<%= f.input :content, as: :hidden, :input_html => { :name => "content", :id => "content", :value => @object.content } %>
|
102
|
+
<% end %>
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "rails_admin_content_builder_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,14 @@
|
|
1
|
+
Rails.application.config.assets.precompile += %w(cb-loading.svg)
|
2
|
+
Rails.application.config.assets.precompile += %w(cb-snippet-text.jpg)
|
3
|
+
Rails.application.config.assets.precompile += %w(cb-snippet-image-text.jpg)
|
4
|
+
Rails.application.config.assets.precompile += %w(cb-snippet-text-image.jpg)
|
5
|
+
Rails.application.config.assets.precompile += %w(cb-snippet-quote.jpg)
|
6
|
+
Rails.application.config.assets.precompile += %w(cb-snippet-quote-text.jpg)
|
7
|
+
Rails.application.config.assets.precompile += %w(cb-snippet-text-quote.jpg)
|
8
|
+
Rails.application.config.assets.precompile += %w(cb-snippet-image.jpg)
|
9
|
+
Rails.application.config.assets.precompile += %w(cb-snippet-video.jpg)
|
10
|
+
Rails.application.config.assets.precompile += %w(cb-image-default.jpg)
|
11
|
+
Rails.application.config.assets.precompile += %w(cb-video-default.jpg)
|
12
|
+
Rails.application.config.assets.precompile += %w(cb-snippet-relational-text.jpg)
|
13
|
+
Rails.application.config.assets.precompile += %w(cb-snippet-text-relational.jpg)
|
14
|
+
Rails.application.config.assets.precompile += %w(cb-snippet-gallery.jpg)
|
@@ -0,0 +1,32 @@
|
|
1
|
+
en:
|
2
|
+
admin:
|
3
|
+
actions:
|
4
|
+
content_builder:
|
5
|
+
title: "Create News"
|
6
|
+
menu: "Create New"
|
7
|
+
breadcrumb: "Create New"
|
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
|
+
url: "Paste YouTube url"
|
15
|
+
invalid_url: "Invalid url"
|
16
|
+
image_description: 'Image description'
|
17
|
+
search_content: 'Search Content'
|
18
|
+
button:
|
19
|
+
save: "Save"
|
20
|
+
publish: "Publish"
|
21
|
+
unpublish: 'Unpublish'
|
22
|
+
snippet:
|
23
|
+
text: "Text"
|
24
|
+
image_left: "Image left"
|
25
|
+
image_right: "Image right"
|
26
|
+
image_center: "Image center"
|
27
|
+
video: "video"
|
28
|
+
blockquote_right: "Blockquote right"
|
29
|
+
blockquote_left: "Blockquote left"
|
30
|
+
blockquote_center: "Blockquote center"
|
31
|
+
related_content_right: "Related content right"
|
32
|
+
related_content_left: "Related content left"
|
@@ -0,0 +1,32 @@
|
|
1
|
+
pt-BR:
|
2
|
+
admin:
|
3
|
+
actions:
|
4
|
+
content_builder:
|
5
|
+
title: "Criar Notícia"
|
6
|
+
menu: "Criar Notícia"
|
7
|
+
breadcrumb: "Criar Notícia"
|
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
|
+
url: "Cole a url do YouTube"
|
15
|
+
invalid_url: "Ops! Você não informou uma url válida"
|
16
|
+
image_description: 'Divulgação'
|
17
|
+
search_content: 'Buscar notícias'
|
18
|
+
button:
|
19
|
+
save: "Salvar"
|
20
|
+
publish: "Publicar"
|
21
|
+
unpublish: 'Despublicar'
|
22
|
+
snippet:
|
23
|
+
text: "Texto"
|
24
|
+
image_left: "Imagem a esquerda"
|
25
|
+
image_right: "Imagem a direita"
|
26
|
+
image_center: "Imagem centralizada"
|
27
|
+
video: "Vídeo"
|
28
|
+
blockquote_right: "Citação a esqueda"
|
29
|
+
blockquote_left: "Citação a direita"
|
30
|
+
blockquote_center: "Citação centralizada"
|
31
|
+
related_content_right: "Notícias relacionadas a esquerda"
|
32
|
+
related_content_left: "Notícias relacionadas a direita"
|
data/config/routes.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
Rails.application.routes.draw do
|
2
|
+
get_url = 'admin/rails_admin_content_builder~content_builder/:id/search_content'
|
3
|
+
get_method = 'rails_admin_content_builder/content_builder#search_content'
|
4
|
+
get get_url => get_method
|
5
|
+
|
6
|
+
put_url = 'admin/rails_admin_content_builder~content_builder/:id/create_images'
|
7
|
+
put_method = 'rails_admin_content_builder/content_builder#create_images'
|
8
|
+
put put_url => put_method
|
9
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'rails_admin_content_builder_rails_6/engine'
|
2
|
+
|
3
|
+
module RailsAdminContentBuilderRails6
|
4
|
+
end
|
5
|
+
|
6
|
+
require 'rails_admin/config/actions'
|
7
|
+
|
8
|
+
module RailsAdmin
|
9
|
+
module Config
|
10
|
+
module Actions
|
11
|
+
class ContentBuilder < Base
|
12
|
+
RailsAdmin::Config::Actions.register(self)
|
13
|
+
register_instance_option :member do
|
14
|
+
true
|
15
|
+
end
|
16
|
+
|
17
|
+
register_instance_option :link_icon do
|
18
|
+
'icon-align-justify'
|
19
|
+
end
|
20
|
+
|
21
|
+
register_instance_option :http_methods do
|
22
|
+
[:get, :post]
|
23
|
+
end
|
24
|
+
|
25
|
+
register_instance_option :controller do
|
26
|
+
proc do
|
27
|
+
@object = @abstract_model.model.find(params[:id])
|
28
|
+
@response = {}
|
29
|
+
|
30
|
+
if request.post?
|
31
|
+
if params.present?
|
32
|
+
|
33
|
+
if params[:publish]
|
34
|
+
status = true
|
35
|
+
elsif params[:unpublish]
|
36
|
+
status = false
|
37
|
+
elsif params[:save]
|
38
|
+
status = @object.status
|
39
|
+
end
|
40
|
+
|
41
|
+
if @object.update(content: params[:content], status: status)
|
42
|
+
flash[:success] = t('admin.actions.content_builder.success_save')
|
43
|
+
else
|
44
|
+
flash[:error] = t('admin.actions.content_builder.error_save')
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
render action: @action.template_name
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'medium-editor-rails'
|
2
|
+
require 'simple_form'
|
3
|
+
require 'carrierwave'
|
4
|
+
require 'friendly_id'
|
5
|
+
require 'search_cop'
|
6
|
+
|
7
|
+
module RailsAdminContentBuilderRails6
|
8
|
+
class Engine < ::Rails::Engine
|
9
|
+
isolate_namespace RailsAdminContentBuilderRails6
|
10
|
+
|
11
|
+
initializer 'rails_admin_content_builder_rails_6.load_static_assets' do |app|
|
12
|
+
app.middleware.use ::ActionDispatch::Static, "#{root}/vendor"
|
13
|
+
app.config.assets.precompile += %w(
|
14
|
+
rails_admin/content_builder.js
|
15
|
+
rails_admin/content_builder.css
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
config.generators do |g|
|
20
|
+
g.assets false
|
21
|
+
g.helper false
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|