effective_pages 2.0.8 → 2.0.9

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: 215d1a7ca112ac8f5f799b186fa6fab449340ea338e77da1676cb5c4745fff0c
4
- data.tar.gz: 6332e9e8799752a6ff3d93117fb7f0b10b78ef3691e6b62faccf73a76e4da587
3
+ metadata.gz: b298b87af43901b5d92f8bcb5cf504fa4d3c713f1b64814a45791d491d1b5d81
4
+ data.tar.gz: c6306cc6b24c38e9155ae875db90c2c16745a48fcf4da456653011fdff364b44
5
5
  SHA512:
6
- metadata.gz: 3c2329ad44abe3d85007d94e4e76e487a9b2decda4e4ea91f9f7c61676a576ac20b6a77dc7b1b1481904903611152e024b3b7aadcd9ea1a9767ac91d9b7a8c85
7
- data.tar.gz: fb1f224d1b1696c7f4bacbc9a0563760d1d7e4727a9d35b9cc842cae1ebeb5f87e453fa59ed2ff66dc2b8e8bc01c4baa1998838e277fbd066a7ff65777ad9f51
6
+ metadata.gz: dcd50073b96b4ded0b1e15c67187e8f9fe92936562df620cbdb2f600adeb4d5f36ccbe7a19bf7e1dcc81ab1ae7e8b62c09b83c2e9e888872bb17402f5326103d
7
+ data.tar.gz: fe88e46fd6782778b8b2ea2283ca91c4f223bcd8b998f78ef234f94a11c26098634af5ef309caf0efd481cfd3b1f6af3193c6b829bb1af182995f754a1256d4d
@@ -45,8 +45,8 @@ module Admin
45
45
  private
46
46
 
47
47
  def authorize_effective_menus!
48
- EffectivePages.authorized?(self, :admin, :effective_pages)
49
- EffectivePages.authorized?(self, action_name.to_sym, @menu || Effective::Menu)
48
+ EffectivePages.authorize!(self, :admin, :effective_pages)
49
+ EffectivePages.authorize!(self, action_name.to_sym, @menu || Effective::Menu)
50
50
  end
51
51
 
52
52
  def menu_params
@@ -101,8 +101,8 @@ module Admin
101
101
  private
102
102
 
103
103
  def authorize_effective_pages!
104
- EffectivePages.authorized?(self, :admin, :effective_pages)
105
- EffectivePages.authorized?(self, action_name.to_sym, @page|| Effective::Page)
104
+ EffectivePages.authorize!(self, :admin, :effective_pages)
105
+ EffectivePages.authorize!(self, action_name.to_sym, @page || Effective::Page)
106
106
  end
107
107
 
108
108
  def page_params
@@ -1,5 +1,7 @@
1
1
  module Effective
2
2
  class PagesController < ApplicationController
3
+ before_action(:authenticate_user!) if EffectivePages.authenticate_user # Devise
4
+
3
5
  def show
4
6
  @pages = Effective::Page.all
5
7
  @pages = @pages.published unless EffectivePages.authorized?(self, :admin, :effective_pages)
@@ -9,7 +11,7 @@ module Effective
9
11
  raise ActiveRecord::RecordNotFound unless @page.present? # Incase .find() isn't raising it
10
12
  raise Effective::AccessDenied.new('Access Denied', :show, @page) unless @page.roles_permit?(current_user)
11
13
 
12
- EffectivePages.authorized?(self, :show, @page)
14
+ EffectivePages.authorize!(self, :show, @page)
13
15
 
14
16
  @page_title = @page.title
15
17
  @meta_description = @page.meta_description
@@ -42,6 +42,14 @@ module Effective
42
42
  !draft?
43
43
  end
44
44
 
45
+ def content
46
+ region(:content).content
47
+ end
48
+
49
+ def content=(input)
50
+ region(:content).content = input
51
+ end
52
+
45
53
  # Returns a duplicated post object, or throws an exception
46
54
  def duplicate!
47
55
  Page.new(attributes.except('id', 'updated_at', 'created_at')).tap do |page|
@@ -60,7 +68,3 @@ module Effective
60
68
  end
61
69
 
62
70
  end
63
-
64
-
65
-
66
-
@@ -1,7 +1,11 @@
1
1
  = dropdown(variation: :dropleft) do
2
- = dropdown_link_to 'Edit', effective_pages.edit_admin_page_path(page)
3
- = dropdown_link_to 'Edit Content', effective_regions.edit_path(page), 'data-no-turbolink': true, 'data-turbolinks': false, target: '_blank'
4
- = dropdown_link_to 'View', effective_pages.page_path(page), 'data-no-turbolink': true, 'data-turbolinks': false, target: '_blank'
2
+ - if EffectivePages.authorized?(self, :edit, page)
3
+ = dropdown_link_to 'Edit', effective_pages.edit_admin_page_path(page)
4
+ = dropdown_link_to 'Edit Content', effective_regions.edit_path(page), 'data-no-turbolink': true, 'data-turbolinks': false, target: '_blank'
5
5
 
6
- = dropdown_link_to "Delete #{page}", effective_pages.admin_page_path(page),
7
- data: { method: :delete, confirm: "Really delete #{page}?" }
6
+ - if EffectivePages.authorized?(self, :show, page)
7
+ = dropdown_link_to 'View', effective_pages.page_path(page), 'data-no-turbolink': true, 'data-turbolinks': false, target: '_blank'
8
+
9
+ - if EffectivePages.authorized?(self, :destroy, page)
10
+ = dropdown_link_to "Delete #{page}", effective_pages.admin_page_path(page),
11
+ data: { method: :delete, confirm: "Really delete #{page}?" }
@@ -3,6 +3,9 @@ EffectivePages.setup do |config|
3
3
  config.menus_table_name = :menus
4
4
  config.menu_items_table_name = :menu_items
5
5
 
6
+ # Call devise authenticate_user! as a before_action on Effective::Pages#show
7
+ config.authenticate_user = false
8
+
6
9
  # The directory where your page templates live
7
10
  # Any files in this directory will be automatically available when
8
11
  # creating/editting an Effective::Page from the Admin screens
@@ -26,6 +26,7 @@ module EffectivePages
26
26
  mattr_accessor :silence_missing_canonical_url_warnings
27
27
 
28
28
  mattr_accessor :use_effective_roles
29
+ mattr_accessor :authenticate_user
29
30
 
30
31
  mattr_accessor :menu
31
32
  mattr_accessor :authorization_method
@@ -1,3 +1,3 @@
1
1
  module EffectivePages
2
- VERSION = '2.0.8'.freeze
2
+ VERSION = '2.0.9'.freeze
3
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: 2.0.8
4
+ version: 2.0.9
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: 2020-07-30 00:00:00.000000000 Z
11
+ date: 2020-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails