effective_pages 2.0.5 → 2.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 64d6ac4c034e7b55034c50c15f907f937110daa117af3bb2579547fd1da3a4c3
4
- data.tar.gz: 61b61f6a912e821e77c07298723f8864c4fc6669e4f5719f8a6c98190bd4164b
3
+ metadata.gz: 4c9f8085e8926499de3786ac923688c20ca98ac0961fa91d46918dc4061684af
4
+ data.tar.gz: 96520c4452017a88c201c7d37378f57a421ae6f7ddefe5dc22803589d4768d38
5
5
  SHA512:
6
- metadata.gz: 4b5eb44075781cf1a5790e7e5cf7b24af4ed58fb849e4270c5be20c3a51069ccea30ff0327c29aa0f6464f0282cd53b79d2568499627511cdb19b0fefe737e54
7
- data.tar.gz: 0ad912da27c0cb8b7b3c625fd9e1d90025290fa987b3db6a4f1385d843972d1fa8a59287d4061ddd21ef441a94ca81634764d9125084520d9d351f18ec8f6d13
6
+ metadata.gz: 953b7b048450e900a145d65611f06b2b53ecfa8437470d48cc6c7a438d7736a892032da7b3592073cc0f01c3f10942efd980ed53556e40438724ef96e3b753e4
7
+ data.tar.gz: 1ee0ed1d174602c4c91f009f1e29bb79deb67b6bf39474ae47cdcc55b2b8efc5fa85377e05b2461abb901ccf07a0047d1164ad8a7114bb0ac9e522eb37327539
data/README.md CHANGED
@@ -11,11 +11,11 @@ Built ontop of effective_regions and effective_ckeditor.
11
11
 
12
12
  ## effective_pages 2.0
13
13
 
14
- This is the 2.0 series of effective_pages.
14
+ This is the 2.0 / bootstrap4 series of effective_pages.
15
15
 
16
16
  This requires Twitter Bootstrap 4 and Rails 5.1+
17
17
 
18
- Please check out [bootstrap3 branch](https://github.com/code-and-effect/effective_datatables/tree/bootstrap3) for more information using this gem with Bootstrap 3.
18
+ Please check out [bootstrap3 branch](https://github.com/code-and-effect/effective_pages/tree/bootstrap3) for more information using this gem with Bootstrap 3.
19
19
 
20
20
 
21
21
  ## Getting Started
@@ -250,5 +250,3 @@ MIT License. Copyright [Code and Effect Inc.](http://www.codeandeffect.com/)
250
250
  4. Push to the branch (`git push origin my-new-feature`)
251
251
  5. Bonus points for test coverage
252
252
  6. Create new Pull Request
253
-
254
-
@@ -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,17 +11,18 @@ 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
18
+ @canonical_url = effective_pages.page_url(@page)
16
19
 
17
20
  if EffectivePages.authorized?(self, :admin, :effective_pages)
18
21
  flash.now[:warning] = [
19
22
  'Hi Admin!',
20
23
  ('You are viewing a hidden page.' unless @page.published?),
21
24
  'Click here to',
22
- ("<a href='#{effective_regions.edit_path(effective_pages.page_path(@page))}' class='alert-link'>edit page content</a> or" unless admin_edit?),
25
+ ("<a href='#{effective_regions.edit_path(effective_pages.page_path(@page))}' class='alert-link' data-no-turbolink='true' data-turbolinks='false'>edit page content</a> or" unless admin_edit?),
23
26
  ("<a href='#{effective_pages.edit_admin_page_path(@page)}' class='alert-link'>edit page settings</a>.")
24
27
  ].compact.join(' ')
25
28
  end
@@ -2,7 +2,7 @@ module EffectivePagesHelper
2
2
 
3
3
  def effective_pages_body_classes
4
4
  [
5
- params[:controller].parameterize,
5
+ params[:controller].to_s.parameterize,
6
6
  params[:action],
7
7
  ((user_signed_in? ? 'signed-in'.freeze : 'not-signed-in'.freeze) rescue nil),
8
8
  (@page.template rescue nil),
@@ -39,14 +39,18 @@ module EffectivePagesHelper
39
39
  ]
40
40
 
41
41
  if EffectivePages.site_og_image_width.present?
42
- tags << tag(:meta, property: 'og:image:width', content: EffectivePages.site_og_image_width)
42
+ tags << tag(:meta, property: 'og:image:width', content: EffectivePages.site_og_image_width)
43
43
  end
44
44
 
45
45
  if EffectivePages.site_og_image_height.present?
46
- tags << tag(:meta, property: 'og:image:height', content: EffectivePages.site_og_image_height)
46
+ tags << tag(:meta, property: 'og:image:height', content: EffectivePages.site_og_image_height)
47
47
  end
48
48
  end
49
49
 
50
+ if effective_pages_canonical_url.present?
51
+ tags << tag(:link, rel: 'canonical', href: effective_pages_canonical_url)
52
+ end
53
+
50
54
  tags.compact.join("\n").html_safe
51
55
  end
52
56
 
@@ -70,6 +74,14 @@ module EffectivePagesHelper
70
74
  truncate((@meta_description || EffectivePages.fallback_meta_description).to_s, length: 150)
71
75
  end
72
76
 
77
+ def effective_pages_canonical_url
78
+ unless @canonical_url.present? || EffectivePages.silence_missing_canonical_url_warnings
79
+ Rails.logger.error("WARNING: (effective_pages) Expected @canonical_url to be present. Please assign a @canonical_url variable in your controller action.")
80
+ end
81
+
82
+ @canonical_url
83
+ end
84
+
73
85
  def effective_pages_og_type
74
86
  @effective_pages_og_type || 'website'
75
87
  end
@@ -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
-
@@ -7,7 +7,7 @@
7
7
  All menu editing may be done from the fullscreen editor. Just drag and drop menu items.
8
8
  .col-sm-6
9
9
  %p.text-right
10
- = link_to "Edit #{@menu}", effective_regions.edit_path('/'), class: 'btn btn-primary', 'data-no-turbolink': true, target: '_blank'
10
+ = link_to "Edit #{@menu}", effective_regions.edit_path('/'), class: 'btn btn-primary', 'data-no-turbolink': true, 'data-turbolinks': false, target: '_blank'
11
11
 
12
12
  - if defined?(EffectiveRoles)
13
13
  %h2 Menu Items
@@ -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, target: '_blank'
4
- = dropdown_link_to 'View', effective_pages.page_path(page), 'data-no-turbolink': true, 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
@@ -37,6 +40,8 @@ EffectivePages.setup do |config|
37
40
  # Turn off missing meta page title and meta description warnings
38
41
  config.silence_missing_page_title_warnings = false
39
42
  config.silence_missing_meta_description_warnings = false
43
+ config.silence_missing_canonical_url_warnings = false
44
+
40
45
 
41
46
  # Display the effective roles 'choose roles' input when an admin creates a new post
42
47
  config.use_effective_roles = false
@@ -23,8 +23,10 @@ module EffectivePages
23
23
 
24
24
  mattr_accessor :silence_missing_page_title_warnings
25
25
  mattr_accessor :silence_missing_meta_description_warnings
26
-
26
+ mattr_accessor :silence_missing_canonical_url_warnings
27
+
27
28
  mattr_accessor :use_effective_roles
29
+ mattr_accessor :authenticate_user
28
30
 
29
31
  mattr_accessor :menu
30
32
  mattr_accessor :authorization_method
@@ -1,3 +1,3 @@
1
1
  module EffectivePages
2
- VERSION = '2.0.5'.freeze
2
+ VERSION = '2.1.0'.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.5
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-03 00:00:00.000000000 Z
11
+ date: 2021-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -132,7 +132,7 @@ homepage: https://github.com/code-and-effect/effective_pages
132
132
  licenses:
133
133
  - MIT
134
134
  metadata: {}
135
- post_install_message:
135
+ post_install_message:
136
136
  rdoc_options: []
137
137
  require_paths:
138
138
  - lib
@@ -147,8 +147,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  - !ruby/object:Gem::Version
148
148
  version: '0'
149
149
  requirements: []
150
- rubygems_version: 3.0.3
151
- signing_key:
150
+ rubygems_version: 3.1.2
151
+ signing_key:
152
152
  specification_version: 4
153
153
  summary: Content pages for your rails app
154
154
  test_files: []