effective_pages 3.0.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/admin/pages_controller.rb +4 -0
- data/app/controllers/effective/pages_controller.rb +5 -5
- data/app/models/effective/page.rb +25 -4
- data/app/views/admin/pages/_form.html.haml +2 -3
- data/app/views/admin/pages/_rich_texts.html.haml +2 -0
- data/config/effective_pages.rb +2 -2
- data/config/routes.rb +3 -7
- data/db/migrate/01_create_effective_pages.rb.erb +11 -3
- data/lib/effective_pages.rb +1 -7
- data/lib/effective_pages/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ccfde3b643933010d2ed2b254f381eda959b5d057cf9e30ab1cb1e2ed57adfaf
|
4
|
+
data.tar.gz: 5021c6f8feb8dfddc5f32ae1e076c976f7fc15408d0c69db25ae37e8c40da834
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70284db9597483e1ff7117056a18c282c7c822c372a6f5d1826e1d01ad4fbdba6603385e584c64040b0e2a0702590f3427d258837a38829cdbf340e5650ee613
|
7
|
+
data.tar.gz: f0f64d3c8739c2aeefb511cbbd1b6fd505728e7608f06684c020c68781d0baf005b753919da9b0ed2cdaad0dcc637d5016d43ac3c7750e12344a7464a6b26678
|
@@ -14,5 +14,9 @@ module Admin
|
|
14
14
|
submit :save, 'Save and View', redirect: -> { effective_pages.page_path(resource) }
|
15
15
|
submit :save, 'Duplicate', only: :edit, redirect: -> { effective_posts.new_admin_page_path(duplicate_id: resource.id) }
|
16
16
|
|
17
|
+
def permitted_params
|
18
|
+
params.require(:effective_page).permit!
|
19
|
+
end
|
20
|
+
|
17
21
|
end
|
18
22
|
end
|
@@ -1,7 +1,5 @@
|
|
1
1
|
module Effective
|
2
2
|
class PagesController < ApplicationController
|
3
|
-
before_action(:authenticate_user!) if defined?(Devise) && EffectiveResources.authenticate_user
|
4
|
-
|
5
3
|
include Effective::CrudController
|
6
4
|
|
7
5
|
def show
|
@@ -10,9 +8,11 @@ module Effective
|
|
10
8
|
|
11
9
|
@page = @pages.find(params[:id])
|
12
10
|
|
13
|
-
|
14
|
-
|
11
|
+
if @page.authenticate_user? || @page.roles.present?
|
12
|
+
authenticate_user!
|
13
|
+
end
|
15
14
|
|
15
|
+
raise Effective::AccessDenied.new('Access Denied', :show, @page) unless @page.roles_permit?(current_user)
|
16
16
|
EffectiveResources.authorize!(self, :show, @page)
|
17
17
|
|
18
18
|
@page_title = @page.title
|
@@ -29,7 +29,7 @@ module Effective
|
|
29
29
|
end
|
30
30
|
|
31
31
|
template = File.join(EffectivePages.pages_path, @page.template)
|
32
|
-
layout = (@page.layout
|
32
|
+
layout = File.join(EffectivePages.layouts_path, @page.layout)
|
33
33
|
|
34
34
|
render(template, layout: layout, locals: { page: @page })
|
35
35
|
end
|
@@ -2,13 +2,17 @@ module Effective
|
|
2
2
|
class Page < ActiveRecord::Base
|
3
3
|
attr_accessor :current_user
|
4
4
|
|
5
|
-
|
5
|
+
# These parent / children are for the menu as well
|
6
|
+
belongs_to :menu_parent, class_name: 'Effective::Page', optional: true
|
7
|
+
|
8
|
+
has_many :menu_children, -> { Effective::Page.menuable }, class_name: 'Effective::Page',
|
9
|
+
foreign_key: :menu_parent_id, inverse_of: :menu_parent
|
6
10
|
|
7
|
-
log_changes if respond_to?(:log_changes)
|
8
11
|
acts_as_role_restricted
|
12
|
+
acts_as_slugged
|
13
|
+
has_many_rich_texts
|
9
14
|
|
10
|
-
|
11
|
-
has_many :menu_items, as: :menuable, dependent: :destroy
|
15
|
+
log_changes if respond_to?(:log_changes)
|
12
16
|
|
13
17
|
self.table_name = EffectivePages.pages_table_name.to_s
|
14
18
|
|
@@ -22,7 +26,15 @@ module Effective
|
|
22
26
|
template :string
|
23
27
|
|
24
28
|
slug :string
|
29
|
+
|
25
30
|
roles_mask :integer
|
31
|
+
authenticate_user :boolean
|
32
|
+
|
33
|
+
# Menu stuff
|
34
|
+
menu :boolean
|
35
|
+
menu_name :string
|
36
|
+
menu_url :string
|
37
|
+
menu_position :integer
|
26
38
|
|
27
39
|
timestamps
|
28
40
|
end
|
@@ -32,11 +44,20 @@ module Effective
|
|
32
44
|
|
33
45
|
validates :template, presence: true
|
34
46
|
|
47
|
+
# validates :menu_name, if: -> { menu? },
|
48
|
+
# presence: true, inclusion: { in: EffectivePages.menus }
|
49
|
+
|
50
|
+
# validates :menu_position, if: -> { menu? },
|
51
|
+
# presence: true, uniqueness: { scope: [:menu_name, :menu_parent_id] }
|
52
|
+
|
35
53
|
scope :drafts, -> { where(draft: true) }
|
36
54
|
scope :published, -> { where(draft: false) }
|
37
55
|
scope :sorted, -> { order(:title) }
|
38
56
|
scope :except_home, -> { where.not(title: 'Home') }
|
39
57
|
|
58
|
+
scope :menuable, -> { where(menu: true).order(:menu_position) }
|
59
|
+
scope :for_menu, -> (name) { menuable.where(menu_name: name) }
|
60
|
+
|
40
61
|
def to_s
|
41
62
|
title
|
42
63
|
end
|
@@ -18,12 +18,11 @@
|
|
18
18
|
= f.text_field :meta_description, hint: "A one or two sentence summary of this page. Appears on Google search results underneath the page title.", input_html: { maxlength: 150 }
|
19
19
|
|
20
20
|
= render partial: '/admin/pages/additional_fields', locals: { page: page, form: f, f: f }
|
21
|
-
|
22
|
-
= f.rich_text_area :body, hint: 'The main body of your page'
|
21
|
+
= render partial: '/admin/pages/rich_texts', locals: { page: page, form: f, f: f }
|
23
22
|
|
24
23
|
= f.check_box :draft, label: 'Save this page as a draft. It will not be accessible on the website.'
|
25
24
|
|
26
|
-
- if
|
25
|
+
- if EffectivePages.use_effective_roles
|
27
26
|
= render partial: '/admin/pages/roles', locals: { page: page, form: f, f: f }
|
28
27
|
|
29
28
|
= effective_submit(f)
|
data/config/effective_pages.rb
CHANGED
@@ -3,8 +3,8 @@ EffectivePages.setup do |config|
|
|
3
3
|
config.menus_table_name = :menus
|
4
4
|
config.menu_items_table_name = :menu_items
|
5
5
|
|
6
|
-
#
|
7
|
-
config.
|
6
|
+
# The menu names a page can belong to
|
7
|
+
config.menus = [:main, :footer]
|
8
8
|
|
9
9
|
# The directory where your page templates live
|
10
10
|
# Any files in this directory will be automatically available when
|
data/config/routes.rb
CHANGED
@@ -1,9 +1,3 @@
|
|
1
|
-
class EffectivePagesConstraint
|
2
|
-
def self.matches?(request)
|
3
|
-
Effective::Page.find(request.path_parameters[:id] || '/').present? rescue false
|
4
|
-
end
|
5
|
-
end
|
6
|
-
|
7
1
|
EffectivePages::Engine.routes.draw do
|
8
2
|
namespace :admin do
|
9
3
|
resources :pages, except: [:show]
|
@@ -11,7 +5,9 @@ EffectivePages::Engine.routes.draw do
|
|
11
5
|
end
|
12
6
|
|
13
7
|
scope module: 'effective' do
|
14
|
-
|
8
|
+
match '*id', to: 'pages#show', via: :get, as: :page, constraints: lambda { |req|
|
9
|
+
Effective::Page.find_by_slug_or_id(req.path_parameters[:id] || '/').present?
|
10
|
+
}
|
15
11
|
end
|
16
12
|
end
|
17
13
|
|
@@ -4,13 +4,21 @@ class CreateEffectivePages < ActiveRecord::Migration[4.2]
|
|
4
4
|
t.string :title
|
5
5
|
t.string :meta_description
|
6
6
|
|
7
|
-
t.boolean :draft, :
|
7
|
+
t.boolean :draft, default: false
|
8
8
|
|
9
|
-
t.string :layout, :
|
9
|
+
t.string :layout, default: 'application'
|
10
10
|
t.string :template
|
11
11
|
|
12
12
|
t.string :slug
|
13
|
-
|
13
|
+
|
14
|
+
t.boolean :authenticate_user, default: false
|
15
|
+
t.integer :roles_mask, default: 0
|
16
|
+
|
17
|
+
t.integer :menu_parent_id
|
18
|
+
t.boolean :menu, default: true
|
19
|
+
t.string :menu_name
|
20
|
+
t.string :menu_url
|
21
|
+
t.integer :menu_position
|
14
22
|
|
15
23
|
t.datetime :updated_at
|
16
24
|
t.datetime :created_at
|
data/lib/effective_pages.rb
CHANGED
@@ -12,7 +12,7 @@ module EffectivePages
|
|
12
12
|
:site_og_image, :site_og_image_width, :site_og_image_height,
|
13
13
|
:site_title, :site_title_suffix, :fallback_meta_description,
|
14
14
|
:silence_missing_page_title_warnings, :silence_missing_meta_description_warnings, :silence_missing_canonical_url_warnings,
|
15
|
-
:use_effective_roles, :
|
15
|
+
:use_effective_roles, :menus, :menu, :layout
|
16
16
|
]
|
17
17
|
end
|
18
18
|
|
@@ -39,10 +39,4 @@ module EffectivePages
|
|
39
39
|
end.compact.sort
|
40
40
|
end
|
41
41
|
|
42
|
-
def self.permitted_params
|
43
|
-
@permitted_params ||= [
|
44
|
-
:title, :meta_description, :draft, :layout, :template, :slug, roles: []
|
45
|
-
]
|
46
|
-
end
|
47
|
-
|
48
42
|
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.1
|
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-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -95,6 +95,7 @@ files:
|
|
95
95
|
- app/views/admin/menus/show.html.haml
|
96
96
|
- app/views/admin/pages/_additional_fields.html.haml
|
97
97
|
- app/views/admin/pages/_form.html.haml
|
98
|
+
- app/views/admin/pages/_rich_texts.html.haml
|
98
99
|
- app/views/admin/pages/_roles.html.haml
|
99
100
|
- config/effective_pages.rb
|
100
101
|
- config/routes.rb
|