effective_pages 3.0.3 → 3.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/effective/page.rb +15 -2
- data/app/views/admin/pages/_form.html.haml +6 -4
- data/app/views/admin/pages/_form_menu.html.haml +8 -2
- data/app/views/effective/pages/_menu.html.haml +1 -1
- data/lib/effective_pages/version.rb +1 -1
- data/lib/effective_pages.rb +8 -4
- data/lib/generators/effective_pages/install_generator.rb +0 -3
- data/lib/tasks/effective_pages_tasks.rake +0 -26
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: edab6d11ae76db81b7c9805116c36cf24562346eff5cfab83df02f270a1e33cb
|
4
|
+
data.tar.gz: d72f504d2563ab8e78e92dad9e7d85032c45b5694a5b23b77e8c77a17f24e98c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c88a81eb833e0127f2001e5056a4da27e17206d9396fac46a513357b7d51894d5a308e5092e34ba69b7bab51c56ee5b8e5528fb80fe286c9939b2cb3969b3cdf
|
7
|
+
data.tar.gz: a2042ed232554fa71b4dd7135ba5d14647105b33c634a736a2ed4059927825c607e9b084858a6785cd32a159a76323f9648410703999d7b16c08e537501e0207
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Effective
|
2
2
|
class Page < ActiveRecord::Base
|
3
3
|
attr_accessor :current_user
|
4
|
+
attr_accessor :menu_root_level
|
4
5
|
|
5
6
|
# These parent / children are for the menu as well
|
6
7
|
belongs_to :menu_parent, class_name: 'Effective::Page', optional: true
|
@@ -58,8 +59,7 @@ module Effective
|
|
58
59
|
validates :layout, presence: true
|
59
60
|
validates :template, presence: true
|
60
61
|
|
61
|
-
validates :menu_name, if: -> { menu? && EffectivePages.menus.present? },
|
62
|
-
presence: true, inclusion: { in: EffectivePages.menus.map(&:to_s) }
|
62
|
+
validates :menu_name, if: -> { menu? && EffectivePages.menus.present? }, presence: true
|
63
63
|
|
64
64
|
# validates :menu_position, if: -> { menu? },
|
65
65
|
# presence: true, uniqueness: { scope: [:menu_name, :menu_parent_id] }
|
@@ -83,6 +83,15 @@ module Effective
|
|
83
83
|
title
|
84
84
|
end
|
85
85
|
|
86
|
+
# As per has_many_rich_texts
|
87
|
+
def body
|
88
|
+
rich_text_body
|
89
|
+
end
|
90
|
+
|
91
|
+
def sidebar
|
92
|
+
rich_text_sidebar
|
93
|
+
end
|
94
|
+
|
86
95
|
def published?
|
87
96
|
!draft?
|
88
97
|
end
|
@@ -105,6 +114,10 @@ module Effective
|
|
105
114
|
duplicate.tap { |page| page.save! }
|
106
115
|
end
|
107
116
|
|
117
|
+
def menu_root_level
|
118
|
+
menu? && menu_parent.blank?
|
119
|
+
end
|
120
|
+
|
108
121
|
end
|
109
122
|
|
110
123
|
end
|
@@ -14,11 +14,13 @@
|
|
14
14
|
= render '/admin/pages/form_page', page: page
|
15
15
|
|
16
16
|
- if page.persisted?
|
17
|
-
|
18
|
-
=
|
17
|
+
- if EffectivePages.menus.present?
|
18
|
+
= tab 'Menu' do
|
19
|
+
= render '/admin/pages/form_menu', page: page
|
19
20
|
|
20
|
-
|
21
|
-
=
|
21
|
+
- unless page.menu_root_level
|
22
|
+
= tab 'Content' do
|
23
|
+
= render '/admin/pages/form_content', page: page
|
22
24
|
|
23
25
|
= tab 'Access' do
|
24
26
|
= render '/admin/pages/form_access', page: page
|
@@ -8,11 +8,17 @@
|
|
8
8
|
- else
|
9
9
|
= f.hidden_field :menu_name, value: menus.first
|
10
10
|
|
11
|
+
= f.check_box :menu_root_level, label: "This is a top level menu item. Do not show page content."
|
12
|
+
|
13
|
+
= f.show_if :menu_root_level, true do
|
14
|
+
= f.hidden_field :menu_parent_id, value: nil
|
15
|
+
|
16
|
+
= f.show_if :menu_root_level, false do
|
17
|
+
= f.select :menu_parent_id, Effective::Page.menuable.root_level.where.not(id: f.object), required: true
|
18
|
+
|
11
19
|
= f.text_field :menu_title, hint: "Display this title on menus instead of full page title"
|
12
20
|
|
13
21
|
= f.text_field :menu_url, label: "Redirect to path or url instead of displaying page",
|
14
22
|
hint: "Must start with http(s):// or /"
|
15
23
|
|
16
|
-
= f.select :menu_parent_id, Effective::Page.menuable.root_level, placeholder: 'None. Top level menu.'
|
17
|
-
|
18
24
|
= f.submit
|
@@ -12,7 +12,7 @@
|
|
12
12
|
= nav_link_to((page.menu_title.presence || page.title), (page.menu_url.presence || effective_pages.page_path(page)))
|
13
13
|
- else
|
14
14
|
= nav_dropdown(page.to_s) do
|
15
|
-
-
|
15
|
+
- menu_children.each do |page|
|
16
16
|
- next unless EffectiveResources.authorized?(self, :show, page)
|
17
17
|
- next if (page.authenticate_user || page.roles.present?) && current_user.blank?
|
18
18
|
- next if page.roles.present? && !current_user.roles.include?(page.roles)
|
data/lib/effective_pages.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
require 'effective_datatables'
|
2
|
-
require 'effective_resources'
|
3
1
|
require 'effective_roles'
|
2
|
+
require 'effective_resources'
|
3
|
+
require 'effective_datatables'
|
4
4
|
require 'effective_pages/engine'
|
5
5
|
require 'effective_pages/version'
|
6
6
|
|
@@ -19,7 +19,9 @@ module EffectivePages
|
|
19
19
|
include EffectiveGem
|
20
20
|
|
21
21
|
def self.templates
|
22
|
-
|
22
|
+
view_paths = defined?(Tenant) ? Tenant.view_paths : ApplicationController.view_paths
|
23
|
+
|
24
|
+
view_paths.map { |path| Dir[File.join(path, pages_path, '**')] }.flatten.map do |file|
|
23
25
|
name = File.basename(file).split('.').first
|
24
26
|
next if name.starts_with?('_')
|
25
27
|
next if Array(EffectivePages.excluded_pages).map { |str| str.to_s }.include?(name)
|
@@ -30,7 +32,9 @@ module EffectivePages
|
|
30
32
|
def self.layouts
|
31
33
|
return [] if layouts_path.blank?
|
32
34
|
|
33
|
-
|
35
|
+
view_paths = defined?(Tenant) ? Tenant.view_paths : ApplicationController.view_paths
|
36
|
+
|
37
|
+
view_paths.map { |path| Dir[File.join(path, layouts_path, '**')] }.flatten.map do |file|
|
34
38
|
name = File.basename(file).split('.').first
|
35
39
|
next if name.starts_with?('_')
|
36
40
|
next if name.include?('mailer')
|
@@ -21,9 +21,6 @@ module EffectivePages
|
|
21
21
|
|
22
22
|
def create_migration_file
|
23
23
|
@pages_table_name = ':' + EffectivePages.pages_table_name.to_s
|
24
|
-
@menus_table_name = ':' + EffectivePages.menus_table_name.to_s
|
25
|
-
@menu_items_table_name = ':' + EffectivePages.menu_items_table_name.to_s
|
26
|
-
|
27
24
|
migration_template ('../' * 3) + 'db/migrate/01_create_effective_pages.rb.erb', 'db/migrate/create_effective_pages.rb'
|
28
25
|
end
|
29
26
|
|
@@ -1,29 +1,3 @@
|
|
1
1
|
# bundle exec rake effective_pages:seed
|
2
2
|
namespace :effective_pages do
|
3
|
-
task seed: :environment do
|
4
|
-
include EffectiveMenusHelper
|
5
|
-
|
6
|
-
return true if Effective::Menu.find_by_title('main menu').present?
|
7
|
-
|
8
|
-
Effective::Menu.new(:title => 'main menu').build do
|
9
|
-
dropdown 'About' do
|
10
|
-
item '111'
|
11
|
-
item '222'
|
12
|
-
dropdown 'More...' do
|
13
|
-
item '333'
|
14
|
-
item '444'
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
dropdown 'Pages' do
|
19
|
-
item 'AAA'
|
20
|
-
divider
|
21
|
-
item 'BBB'
|
22
|
-
item 'CCC'
|
23
|
-
divider
|
24
|
-
item 'DDD'
|
25
|
-
end
|
26
|
-
end.save!
|
27
|
-
|
28
|
-
end
|
29
3
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_pages
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|