effective_pages 3.0.2 → 3.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2624cae83c49b16480071da85aaac6bf14daac37bb3c761af9a5eb463c4f1559
4
- data.tar.gz: 5cea72cad0f89b57bd47d62a25f1d694e0b5accd1546bd0f190dc104da3fbe10
3
+ metadata.gz: 6cf23b05e739f425ac9681d3a23482c0080498a59257e3e7f1988976e2807d3e
4
+ data.tar.gz: 4504a432b1d2e2700aa351160ba73afe2ae9368f59aed98e00a5d0b3b30cb677
5
5
  SHA512:
6
- metadata.gz: 576642b33ebfe721192d30e860d6d864d659abba485a24e158e33234f4dde18b4a3548b33d043024114fe89eae8e3c6ab8854b3dd9dc8e5e23b6c5d617d0d023
7
- data.tar.gz: 512237ffc6d895b2d547fe0ffd8d9807931c5e925bcabb912eec86defe56745335a3f1d9c6b3fe848ed0e5613bf90505c79e91504cf125440896029eaa9b0c0e
6
+ metadata.gz: 7ee1f64e3076dc7ca7e428d8d310881836b6ce24feeea8c310a20b7e1b582f60cb2a57992cb25f2d73ee8621f8424237b0cddc8e5c6292a10bb4041f1f005824
7
+ data.tar.gz: 36137529002c0d6051ded641ee237a1e7419eb5a62364ab32718d30d7308dc5aa29d3b9a44746b07556cb99440fda95efe61b9b8fefa5875c2bb00cc0a706d4b
@@ -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
@@ -31,6 +32,7 @@ module Effective
31
32
  menu :boolean
32
33
  menu_name :string
33
34
 
35
+ menu_title :string
34
36
  menu_url :string
35
37
  menu_position :integer
36
38
 
@@ -82,6 +84,15 @@ module Effective
82
84
  title
83
85
  end
84
86
 
87
+ # As per has_many_rich_texts
88
+ def body
89
+ rich_text_body
90
+ end
91
+
92
+ def sidebar
93
+ rich_text_sidebar
94
+ end
95
+
85
96
  def published?
86
97
  !draft?
87
98
  end
@@ -104,6 +115,10 @@ module Effective
104
115
  duplicate.tap { |page| page.save! }
105
116
  end
106
117
 
118
+ def menu_root_level
119
+ menu? && menu_parent.blank?
120
+ end
121
+
107
122
  end
108
123
 
109
124
  end
@@ -14,11 +14,13 @@
14
14
  = render '/admin/pages/form_page', page: page
15
15
 
16
16
  - if page.persisted?
17
- = tab 'Content' do
18
- = render '/admin/pages/form_content', page: page
17
+ - if EffectivePages.menus.present?
18
+ = tab 'Menu' do
19
+ = render '/admin/pages/form_menu', page: page
19
20
 
20
- = tab 'Menu' do
21
- = render '/admin/pages/form_menu', page: page
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,9 +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
+
19
+ = f.text_field :menu_title, hint: "Display this title on menus instead of full page title"
20
+
11
21
  = f.text_field :menu_url, label: "Redirect to path or url instead of displaying page",
12
22
  hint: "Must start with http(s):// or /"
13
23
 
14
- = f.select :menu_parent_id, Effective::Page.menuable.root_level, placeholder: 'None. Top level menu.'
15
-
16
24
  = f.submit
@@ -9,12 +9,12 @@
9
9
  - menu_children = page.menu_children.select { |page| page.menu_name == menu }
10
10
 
11
11
  - if menu_children.blank?
12
- = nav_link_to(page, page.menu_url.presence || effective_pages.page_path(page))
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
- - ([page] + menu_children).each do |page|
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)
19
19
 
20
- = nav_link_to(page, page.menu_url.presence || effective_pages.page_path(page))
20
+ = nav_link_to((page.menu_title.presence || page.title), (page.menu_url.presence || effective_pages.page_path(page)))
@@ -17,6 +17,7 @@ class CreateEffectivePages < ActiveRecord::Migration[4.2]
17
17
  t.integer :menu_parent_id
18
18
  t.boolean :menu, default: false
19
19
  t.string :menu_name
20
+ t.string :menu_title
20
21
  t.string :menu_url
21
22
  t.integer :menu_position
22
23
 
@@ -1,3 +1,3 @@
1
1
  module EffectivePages
2
- VERSION = '3.0.2'.freeze
2
+ VERSION = '3.0.6'.freeze
3
3
  end
@@ -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
- ApplicationController.view_paths.map { |path| Dir[File.join(path, pages_path, '**')] }.flatten.map do |file|
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
- ApplicationController.view_paths.map { |path| Dir[File.join(path, layouts_path, '**')] }.flatten.map do |file|
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.2
4
+ version: 3.0.6
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-03-08 00:00:00.000000000 Z
11
+ date: 2021-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails