enjoy_cms_pages 0.4.0.beta3
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 +7 -0
- data/.gitignore +9 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +40 -0
- data/Rakefile +1 -0
- data/app/assets/javascripts/enjoy/pages/init.coffee +2 -0
- data/app/assets/javascripts/enjoy/pages/scrolling.coffee +55 -0
- data/app/assets/javascripts/enjoy/pages.coffee +6 -0
- data/app/controllers/concerns/enjoy/pages/blocksetable.rb +81 -0
- data/app/controllers/concerns/enjoy/pages/decorators/pages_controller.rb +5 -0
- data/app/controllers/concerns/enjoy/pages/nav_menu.rb +91 -0
- data/app/controllers/concerns/enjoy/pages/seo_pages.rb +90 -0
- data/app/controllers/enjoy/pages/pages_controller.rb +7 -0
- data/app/helpers/enjoy/pages/canonical_helper.rb +13 -0
- data/app/helpers/enjoy/pages/pages_helpers.rb +2 -0
- data/app/models/concerns/enjoy/pages/canonicalable.rb +22 -0
- data/app/models/concerns/enjoy/pages/connectable.rb +36 -0
- data/app/models/concerns/enjoy/pages/decorators/block.rb +5 -0
- data/app/models/concerns/enjoy/pages/decorators/blockset.rb +5 -0
- data/app/models/concerns/enjoy/pages/decorators/menu.rb +5 -0
- data/app/models/concerns/enjoy/pages/decorators/page.rb +5 -0
- data/app/models/enjoy/pages/block.rb +13 -0
- data/app/models/enjoy/pages/blockset.rb +13 -0
- data/app/models/enjoy/pages/menu.rb +16 -0
- data/app/models/enjoy/pages/page.rb +16 -0
- data/app/views/enjoy/pages/pages/show.html.slim +1 -0
- data/app/views/rails_admin/main/_enjoy_connectable.html.slim +56 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/config/initializers/enjoy_pages.rb +85 -0
- data/config/locales/ru.enjoy.pages.yml +44 -0
- data/enjoy_cms_pages.gemspec +36 -0
- data/lib/enjoy/pages/admin/block.rb +67 -0
- data/lib/enjoy/pages/admin/blockset.rb +53 -0
- data/lib/enjoy/pages/admin/menu.rb +27 -0
- data/lib/enjoy/pages/admin/page.rb +98 -0
- data/lib/enjoy/pages/admin.rb +4 -0
- data/lib/enjoy/pages/configuration.rb +32 -0
- data/lib/enjoy/pages/controllers/pages.rb +26 -0
- data/lib/enjoy/pages/engine.rb +5 -0
- data/lib/enjoy/pages/models/active_record/block.rb +16 -0
- data/lib/enjoy/pages/models/active_record/blockset.rb +19 -0
- data/lib/enjoy/pages/models/active_record/menu.rb +20 -0
- data/lib/enjoy/pages/models/active_record/page.rb +22 -0
- data/lib/enjoy/pages/models/block.rb +89 -0
- data/lib/enjoy/pages/models/blockset.rb +17 -0
- data/lib/enjoy/pages/models/menu.rb +23 -0
- data/lib/enjoy/pages/models/mongoid/block.rb +32 -0
- data/lib/enjoy/pages/models/mongoid/blockset.rb +16 -0
- data/lib/enjoy/pages/models/mongoid/menu.rb +16 -0
- data/lib/enjoy/pages/models/mongoid/page.rb +43 -0
- data/lib/enjoy/pages/models/page.rb +106 -0
- data/lib/enjoy/pages/rails_admin_ext/enjoy_connectable.rb +33 -0
- data/lib/enjoy/pages/rails_admin_ext/menu.rb +147 -0
- data/lib/enjoy/pages/routes.rb +46 -0
- data/lib/enjoy/pages/version.rb +5 -0
- data/lib/enjoy_cms_pages.rb +70 -0
- data/lib/generators/enjoy/pages/migration_generator.rb +18 -0
- data/lib/generators/enjoy/pages/templates/migration_blocks.rb +42 -0
- data/lib/generators/enjoy/pages/templates/migration_pages.rb +48 -0
- data/release.sh +7 -0
- metadata +164 -0
@@ -0,0 +1,56 @@
|
|
1
|
+
ruby:
|
2
|
+
related_id = params[:associations] && params[:associations][field.name.to_s]
|
3
|
+
config = field.associated_model_config
|
4
|
+
source_abstract_model = RailsAdmin.config(form.object.class).abstract_model
|
5
|
+
|
6
|
+
if form.object.new_record? && related_id.present? && related_id != 'new'
|
7
|
+
selected = [config.abstract_model.get(related_id)]
|
8
|
+
else
|
9
|
+
selected = form.object.send(field.name)
|
10
|
+
end
|
11
|
+
selected_ids = selected.map{|s| s.send(field.associated_primary_key)}
|
12
|
+
|
13
|
+
current_action = params[:action].in?(['create', 'new']) ? 'create' : 'update'
|
14
|
+
|
15
|
+
xhr = !field.associated_collection_cache_all
|
16
|
+
|
17
|
+
collection = if xhr
|
18
|
+
selected.map { |o| [o.send(field.associated_object_label_method), o.send(field.associated_primary_key)] }
|
19
|
+
else
|
20
|
+
i = 0
|
21
|
+
controller.list_entries(config, :index, field.associated_collection_scope, false).map { |o| [o.send(field.associated_object_label_method), o.send(field.associated_primary_key)] }.sort_by {|a| [selected_ids.index(a[1]) || selected_ids.size, i+=1] }
|
22
|
+
end
|
23
|
+
|
24
|
+
js_data = {
|
25
|
+
xhr: xhr,
|
26
|
+
:'edit-url' => (authorized?(:edit, config.abstract_model) ? edit_path(model_name: config.abstract_model.to_param, id: '__ID__') : ''),
|
27
|
+
remote_source: index_path(config.abstract_model, source_object_id: form.object.id, source_abstract_model: source_abstract_model.to_param, associated_collection: field.name, current_action: current_action, compact: true),
|
28
|
+
sortable: !!field.orderable,
|
29
|
+
removable: !!field.removable,
|
30
|
+
cacheAll: !!field.associated_collection_cache_all,
|
31
|
+
regional: {
|
32
|
+
chooseAll: t("admin.misc.chose_all"),
|
33
|
+
chosen: t("admin.misc.chosen", name: config.label_plural),
|
34
|
+
clearAll: t("admin.misc.clear_all"),
|
35
|
+
search: t("admin.misc.search"),
|
36
|
+
up: t("admin.misc.up"),
|
37
|
+
down: t("admin.misc.down")
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
input{name="#{form.dom_name(field)}" type="hidden" value=""}
|
42
|
+
|
43
|
+
- if field.bindings[:object].new_record? and field.bindings[:object].respond_to?(field.autocreate_page_attr)
|
44
|
+
p
|
45
|
+
span{style='float: left'}= form.check_box field.autocreate_page_attr, checked: false, class: "form-control"
|
46
|
+
div{style='margin-left: 35px; line-height: 40px;'} Автоматически создать пункт меню
|
47
|
+
|
48
|
+
- selected_ids = (hdv = field.form_default_value).nil? ? selected_ids : hdv
|
49
|
+
= form.select field.method_name, collection, { selected: selected_ids, object: form.object }, field.html_attributes.reverse_merge({data: { filteringmultiselect: true, options: js_data.to_json }, multiple: true})
|
50
|
+
- if authorized?(:new, config.abstract_model) && field.inline_add
|
51
|
+
- path_hash = { model_name: config.abstract_model.to_param, modal: true }
|
52
|
+
- path_hash.merge!({ associations: { field.inverse_of => (form.object.persisted? ? form.object.id : 'new') } }) if field.inverse_of
|
53
|
+
= link_to "<i class=\"icon-plus icon-white\"></i> ".html_safe + wording_for(:link, :new, config.abstract_model), '#', data: { link: new_path(path_hash) }, class: "create btn btn-info", style: 'margin-left:10px'
|
54
|
+
|
55
|
+
|
56
|
+
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "enjoy_pages"
|
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
|
data/bin/setup
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
Enjoy.configure do |config|
|
2
|
+
config.ability_manager_config ||= []
|
3
|
+
config.ability_manager_config << {
|
4
|
+
method: :can,
|
5
|
+
model: Enjoy::Pages::Page,
|
6
|
+
actions: [:show, :read, :new, :create, :edit, :update, :nested_set]
|
7
|
+
}
|
8
|
+
config.ability_manager_config << {
|
9
|
+
method: :cannot,
|
10
|
+
model: Enjoy::Pages::Menu,
|
11
|
+
actions: :manage
|
12
|
+
}
|
13
|
+
config.ability_manager_config << {
|
14
|
+
method: :can,
|
15
|
+
model: Enjoy::Pages::Blockset,
|
16
|
+
actions: [:show, :read, :new, :create, :edit, :update, :sort_embedded]
|
17
|
+
}
|
18
|
+
config.ability_manager_config << {
|
19
|
+
method: :can,
|
20
|
+
model: Enjoy::Pages::Block,
|
21
|
+
actions: [:show, :read, :new, :create, :edit, :update]
|
22
|
+
}
|
23
|
+
|
24
|
+
config.ability_admin_config ||= []
|
25
|
+
config.ability_admin_config << {
|
26
|
+
method: :can,
|
27
|
+
model: Enjoy::Pages::Page,
|
28
|
+
actions: :manage
|
29
|
+
}
|
30
|
+
config.ability_admin_config << {
|
31
|
+
method: :can,
|
32
|
+
model: Enjoy::Pages::Menu,
|
33
|
+
actions: :manage
|
34
|
+
}
|
35
|
+
config.ability_admin_config << {
|
36
|
+
method: :can,
|
37
|
+
model: Enjoy::Pages::Blockset,
|
38
|
+
actions: :manage
|
39
|
+
}
|
40
|
+
config.ability_admin_config << {
|
41
|
+
method: :can,
|
42
|
+
model: Enjoy::Pages::Block,
|
43
|
+
actions: :manage
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
Enjoy.rails_admin_configure do |config|
|
49
|
+
config.action_visible_for :nested_set, 'Enjoy::Pages::Page'
|
50
|
+
if Enjoy::Pages.active_record?
|
51
|
+
config.action_visible_for :nested_set, 'Enjoy::Pages::Blockset'
|
52
|
+
end
|
53
|
+
|
54
|
+
if Enjoy::Pages.mongoid?
|
55
|
+
config.action_visible_for :sort_embedded, 'Enjoy::Pages::Blockset'
|
56
|
+
end
|
57
|
+
|
58
|
+
config.action_visible_for :toggle_menu, 'Enjoy::Pages::Page'
|
59
|
+
|
60
|
+
if defined?(RailsAdminComments)
|
61
|
+
config.action_visible_for :comments, 'Enjoy::Pages::Menu'
|
62
|
+
config.action_visible_for :comments, 'Enjoy::Pages::Page'
|
63
|
+
config.action_visible_for :comments, 'Enjoy::Pages::Blockset'
|
64
|
+
config.action_visible_for :model_comments, 'Enjoy::Pages::Menu'
|
65
|
+
config.action_visible_for :model_comments, 'Enjoy::Pages::Page'
|
66
|
+
config.action_visible_for :model_comments, 'Enjoy::Pages::Blockset'
|
67
|
+
if Enjoy::Pages.active_record?
|
68
|
+
config.action_visible_for :comments, 'Enjoy::Pages::Block'
|
69
|
+
config.action_visible_for :model_comments, 'Enjoy::Pages::Block'
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
if defined?(RailsAdmin)
|
76
|
+
RailsAdmin.config do |config|
|
77
|
+
config.excluded_models ||= []
|
78
|
+
if Enjoy::Pages.mongoid?
|
79
|
+
config.excluded_models << [
|
80
|
+
# 'Enjoy::Pages::Block'
|
81
|
+
]
|
82
|
+
end
|
83
|
+
config.excluded_models.flatten!
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
ru:
|
2
|
+
admin:
|
3
|
+
actions:
|
4
|
+
toggle_menu:
|
5
|
+
menu: Переключатель меню
|
6
|
+
breadcrumb: Переключатель меню
|
7
|
+
title: Переключатель меню
|
8
|
+
|
9
|
+
enjoy:
|
10
|
+
pages: 'Страницы и меню'
|
11
|
+
menu_title: Меню
|
12
|
+
menu:
|
13
|
+
enabled: 'добавлено в меню "%{menu}"'
|
14
|
+
disabled: 'удалено из меню "%{menu}"'
|
15
|
+
error: "Ошибка: %{err}"
|
16
|
+
no_id: "Не указан ID"
|
17
|
+
|
18
|
+
mongoid: &mongoid
|
19
|
+
models:
|
20
|
+
enjoy/pages/menu: Меню
|
21
|
+
enjoy/pages/page: Страница
|
22
|
+
enjoy/pages/block: Блок
|
23
|
+
enjoy/pages/blockset: Блоки
|
24
|
+
|
25
|
+
attributes:
|
26
|
+
enjoy/pages/page:
|
27
|
+
fullpath: URL
|
28
|
+
regexp: Подсветка меню
|
29
|
+
redirect: Редирект
|
30
|
+
image: Картинка
|
31
|
+
hidden: Скрытая
|
32
|
+
menus: Меню
|
33
|
+
connectable: Связанный элемент
|
34
|
+
connectable_type: Связанный элемент
|
35
|
+
connectable_id: Связанный элемент
|
36
|
+
enjoy/pages/blockset:
|
37
|
+
blocks: Блоки
|
38
|
+
enjoy/pages/block:
|
39
|
+
pageblock_selector: "CSS селектор блока на странице"
|
40
|
+
partial: "Файл-partial"
|
41
|
+
file_path: "Путь к файлу"
|
42
|
+
|
43
|
+
activerecord:
|
44
|
+
<<: *mongoid
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'enjoy/pages/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "enjoy_cms_pages"
|
8
|
+
spec.version = Enjoy::Pages::VERSION
|
9
|
+
spec.authors = ["Alexander Kiseliev"]
|
10
|
+
spec.email = ["dev@enjoycreate.ru"]
|
11
|
+
|
12
|
+
spec.description = %q{enjoy_cms_pages }
|
13
|
+
spec.summary = %q{enjoy_cms_pages}
|
14
|
+
spec.homepage = 'https://github.com/enjoycreative/enjoy_cms_pages'
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
19
|
+
# if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
# else
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
# end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
|
33
|
+
spec.add_dependency 'enjoy_cms', "~> 0.4.0.beta3"
|
34
|
+
|
35
|
+
spec.add_dependency 'simple-navigation'
|
36
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Enjoy::Pages
|
2
|
+
module Admin
|
3
|
+
module Block
|
4
|
+
def self.config(fields = {})
|
5
|
+
Proc.new {
|
6
|
+
navigation_label I18n.t('enjoy.pages')
|
7
|
+
|
8
|
+
field :enabled, :toggle do
|
9
|
+
searchable false
|
10
|
+
end
|
11
|
+
field :show_in_menu, :toggle do
|
12
|
+
searchable false
|
13
|
+
end
|
14
|
+
field :partial, :toggle do
|
15
|
+
searchable false
|
16
|
+
end
|
17
|
+
field :name do
|
18
|
+
searchable true
|
19
|
+
end
|
20
|
+
field :menu_link_content, :text do
|
21
|
+
searchable true
|
22
|
+
end
|
23
|
+
field :pageblock_selector, :string do
|
24
|
+
searchable true
|
25
|
+
end
|
26
|
+
|
27
|
+
field :file_path, :string do
|
28
|
+
searchable true
|
29
|
+
end
|
30
|
+
field :content, :enjoy_html do
|
31
|
+
searchable true
|
32
|
+
end
|
33
|
+
|
34
|
+
group :wrapper do
|
35
|
+
active false
|
36
|
+
field :use_wrapper, :toggle
|
37
|
+
field :wrapper_tag, :string
|
38
|
+
field :wrapper_class, :string
|
39
|
+
field :wrapper_id, :string
|
40
|
+
end
|
41
|
+
|
42
|
+
# field :content_html, :ck_editor
|
43
|
+
# field :content_clear, :toggle
|
44
|
+
|
45
|
+
Enjoy::RailsAdminGroupPatch::enjoy_cms_group(self, fields)
|
46
|
+
|
47
|
+
# field :blocksets do
|
48
|
+
# read_only true
|
49
|
+
# help 'Список групп блоков'
|
50
|
+
#
|
51
|
+
# pretty_value do
|
52
|
+
# bindings[:object].blocksets.to_a.map { |bs|
|
53
|
+
# route = (bindings[:view] || bindings[:controller])
|
54
|
+
# model_name = bs.rails_admin_model
|
55
|
+
# route.link_to(bs.name, route.rails_admin.show_path(model_name: model_name, id: bs.id), title: bs.name)
|
56
|
+
# }.join("<br>").html_safe
|
57
|
+
# end
|
58
|
+
# end
|
59
|
+
|
60
|
+
if block_given?
|
61
|
+
yield self
|
62
|
+
end
|
63
|
+
}
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Enjoy::Pages
|
2
|
+
module Admin
|
3
|
+
module Blockset
|
4
|
+
def self.config(fields = {})
|
5
|
+
Proc.new {
|
6
|
+
navigation_label I18n.t('enjoy.pages')
|
7
|
+
|
8
|
+
field :enabled, :toggle do
|
9
|
+
searchable false
|
10
|
+
end
|
11
|
+
field :text_slug do
|
12
|
+
searchable true
|
13
|
+
end
|
14
|
+
field :name do
|
15
|
+
searchable true
|
16
|
+
end
|
17
|
+
|
18
|
+
group :blocks do
|
19
|
+
active false
|
20
|
+
field :blocks do
|
21
|
+
searchable :name
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
Enjoy::RailsAdminGroupPatch::enjoy_cms_group(self, fields)
|
26
|
+
|
27
|
+
# field :blocks do
|
28
|
+
# read_only true
|
29
|
+
# help 'Список блоков'
|
30
|
+
#
|
31
|
+
# pretty_value do
|
32
|
+
# bindings[:object].blocks.to_a.map { |b|
|
33
|
+
# route = (bindings[:view] || bindings[:controller])
|
34
|
+
# model_name = b.rails_admin_model
|
35
|
+
# route.link_to(b.name, route.rails_admin.show_path(model_name: model_name, id: b.id), title: b.name)
|
36
|
+
# }.join("<br>").html_safe
|
37
|
+
# end
|
38
|
+
# end
|
39
|
+
|
40
|
+
sort_embedded(
|
41
|
+
{
|
42
|
+
fields: [:blocks]
|
43
|
+
}
|
44
|
+
)
|
45
|
+
|
46
|
+
if block_given?
|
47
|
+
yield self
|
48
|
+
end
|
49
|
+
}
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Enjoy::Pages
|
2
|
+
module Admin
|
3
|
+
module Menu
|
4
|
+
def self.config(fields = {})
|
5
|
+
Proc.new {
|
6
|
+
navigation_label I18n.t('enjoy.pages')
|
7
|
+
|
8
|
+
field :enabled, :toggle do
|
9
|
+
searchable false
|
10
|
+
end
|
11
|
+
field :text_slug do
|
12
|
+
searchable true
|
13
|
+
end
|
14
|
+
field :name do
|
15
|
+
searchable true
|
16
|
+
end
|
17
|
+
|
18
|
+
Enjoy::RailsAdminGroupPatch::enjoy_cms_group(self, fields)
|
19
|
+
|
20
|
+
if block_given?
|
21
|
+
yield self
|
22
|
+
end
|
23
|
+
}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
module Enjoy::Pages
|
2
|
+
module Admin
|
3
|
+
module Page
|
4
|
+
def self.config(fields = {})
|
5
|
+
Proc.new {
|
6
|
+
navigation_label I18n.t('enjoy.pages')
|
7
|
+
|
8
|
+
list do
|
9
|
+
scopes [:sorted, :enabled, nil]
|
10
|
+
|
11
|
+
field :enabled, :toggle do
|
12
|
+
searchable false
|
13
|
+
end
|
14
|
+
field :menus, :menu do
|
15
|
+
searchable :name
|
16
|
+
end
|
17
|
+
field :name do
|
18
|
+
searchable true
|
19
|
+
end
|
20
|
+
field :connectable do
|
21
|
+
searchable :name
|
22
|
+
end
|
23
|
+
field :fullpath do
|
24
|
+
searchable true
|
25
|
+
pretty_value do
|
26
|
+
bindings[:view].content_tag(:a, bindings[:object].fullpath, href: bindings[:object].fullpath)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
field :redirect do
|
30
|
+
searchable true
|
31
|
+
end
|
32
|
+
field :slug do
|
33
|
+
searchable true
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
edit do
|
38
|
+
field :enabled, :toggle
|
39
|
+
field :name
|
40
|
+
field :connectable do
|
41
|
+
read_only true
|
42
|
+
end
|
43
|
+
|
44
|
+
group :content do
|
45
|
+
active false
|
46
|
+
field :excerpt, :enjoy_html
|
47
|
+
# field :excerpt_html, :ck_editor
|
48
|
+
# field :excerpt_clear, :toggle
|
49
|
+
field :content, :enjoy_html
|
50
|
+
# field :content_html, :ck_editor
|
51
|
+
# field :content_clear, :toggle
|
52
|
+
end
|
53
|
+
|
54
|
+
group :menu do
|
55
|
+
active false
|
56
|
+
label I18n.t('enjoy.menu_title')
|
57
|
+
field :menus
|
58
|
+
field :fullpath, :string do
|
59
|
+
help I18n.t('enjoy.with_final_slash')
|
60
|
+
end
|
61
|
+
field :regexp, :string do
|
62
|
+
help I18n.t('enjoy.page_url_regex')
|
63
|
+
end
|
64
|
+
field :redirect, :string do
|
65
|
+
help I18n.t('enjoy.final_in_menu')
|
66
|
+
end
|
67
|
+
field :text_slug
|
68
|
+
end
|
69
|
+
|
70
|
+
Enjoy::RailsAdminGroupPatch::enjoy_cms_group(self, fields)
|
71
|
+
|
72
|
+
group :seo do
|
73
|
+
active false
|
74
|
+
field :seo do
|
75
|
+
active true
|
76
|
+
end
|
77
|
+
end
|
78
|
+
group :sitemap_data do
|
79
|
+
active false
|
80
|
+
field :sitemap_data do
|
81
|
+
active true
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
nested_set({
|
87
|
+
max_depth: Enjoy::Pages.config.menu_max_depth,
|
88
|
+
scopes: []
|
89
|
+
})
|
90
|
+
|
91
|
+
if block_given?
|
92
|
+
yield self
|
93
|
+
end
|
94
|
+
}
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Enjoy::Pages
|
2
|
+
def self.configuration
|
3
|
+
@configuration ||= Configuration.new
|
4
|
+
end
|
5
|
+
def self.config
|
6
|
+
@configuration ||= Configuration.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.configure
|
10
|
+
yield configuration
|
11
|
+
end
|
12
|
+
|
13
|
+
class Configuration
|
14
|
+
attr_accessor :menu_max_depth
|
15
|
+
|
16
|
+
attr_accessor :seo_support
|
17
|
+
|
18
|
+
attr_accessor :localize
|
19
|
+
|
20
|
+
attr_accessor :breadcrumbs_on_rails_support
|
21
|
+
|
22
|
+
def initialize
|
23
|
+
@menu_max_depth = 2
|
24
|
+
|
25
|
+
@seo_support = defined? Enjoy::Seo
|
26
|
+
|
27
|
+
@localize = Enjoy.config.localize
|
28
|
+
|
29
|
+
@breadcrumbs_on_rails_support = defined?(BreadcrumbsOnRails)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Enjoy::Pages
|
2
|
+
module Controllers
|
3
|
+
module Pages
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
def show
|
6
|
+
if @seo_page.nil? || !@seo_page.persisted?
|
7
|
+
if !params[:id].blank? or !params[:slug].blank?
|
8
|
+
@seo_page = model.enabled.find(params[:id] || params[:slug])
|
9
|
+
end
|
10
|
+
end
|
11
|
+
if @seo_page.nil?
|
12
|
+
render_404
|
13
|
+
return true
|
14
|
+
end
|
15
|
+
|
16
|
+
if Enjoy::Pages.config.breadcrumbs_on_rails_support
|
17
|
+
add_breadcrumb @seo_page.name, @seo_page.slug
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def model
|
22
|
+
Enjoy::Pages::Page
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Enjoy::Pages
|
2
|
+
module Models
|
3
|
+
module ActiveRecord
|
4
|
+
module Blockset
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
has_paper_trail
|
9
|
+
validates_lengths_from_database only: [:name]
|
10
|
+
if Enjoy::Pages.config.localize
|
11
|
+
translates :name
|
12
|
+
end
|
13
|
+
|
14
|
+
has_many :page_blocks, class_name: "Enjoy::Pages::Blockset"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Enjoy::Pages
|
2
|
+
module Models
|
3
|
+
module ActiveRecord
|
4
|
+
module Menu
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
included do
|
7
|
+
has_paper_trail
|
8
|
+
validates_lengths_from_database only: [:name]
|
9
|
+
if Enjoy::Pages.config.localize
|
10
|
+
translates :name
|
11
|
+
end
|
12
|
+
|
13
|
+
has_and_belongs_to_many :pages,
|
14
|
+
class_name: "Enjoy::Pages::Page",
|
15
|
+
join_table: :enjoy_pages_menus_pages
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Enjoy::Pages
|
2
|
+
module Models
|
3
|
+
module ActiveRecord
|
4
|
+
module Page
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
has_paper_trail
|
9
|
+
validates_lengths_from_database only: [:name, :content_html, :excerpt_html, :regexp, :redirect, :fullpath]
|
10
|
+
scope :sorted, -> { order(lft: :asc) }
|
11
|
+
if Enjoy::Pages.config.localize
|
12
|
+
translates :name, :content_html, :excerpt_html
|
13
|
+
end
|
14
|
+
|
15
|
+
has_and_belongs_to_many :menus,
|
16
|
+
class_name: "Enjoy::Pages::Menu",
|
17
|
+
join_table: :enjoy_pages_menus_pages
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|