effective_pages 2.0.1 → 2.0.2
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 +4 -4
- data/app/controllers/admin/pages_controller.rb +19 -2
- data/app/controllers/effective/pages_controller.rb +18 -1
- data/app/models/effective/page.rb +20 -0
- data/app/views/admin/pages/_actions.html.haml +1 -1
- data/app/views/admin/pages/_form.html.haml +17 -12
- data/config/effective_pages.rb +3 -0
- data/lib/effective_pages/version.rb +1 -1
- data/lib/effective_pages.rb +3 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fdc3d90510d3e7f24698870169dea7d15a2860ed
|
4
|
+
data.tar.gz: 374484d7237ab1dba337f02702db6f9164a1f4bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5f47e1f8e314a26935c3ac1cd038fd11e879dd9f556440c7bec032c4b6587791f4ee105586e8f6dc6463fed38f9e717daa9f79399c3267d78715ea26afd65c1
|
7
|
+
data.tar.gz: 535476f8e040412731310432f35e2de38a8385bacf1f032c0cca4298978fa394e12a5796a1019596bcd7d4b7970e1ad6aab8a856500ada3cc4c738ec6e1f88cd
|
@@ -25,10 +25,13 @@ module Admin
|
|
25
25
|
authorize_effective_pages!
|
26
26
|
|
27
27
|
if @page.save
|
28
|
-
if params[:commit] == 'Save and Edit Content'
|
28
|
+
if params[:commit] == 'Save and Edit Content'
|
29
29
|
redirect_to effective_regions.edit_path(effective_pages.page_path(@page), :exit => effective_pages.edit_admin_page_path(@page))
|
30
30
|
elsif params[:commit] == 'Save and Add New'
|
31
|
+
flash[:success] = 'Successfully created page'
|
31
32
|
redirect_to effective_pages.new_admin_page_path
|
33
|
+
elsif params[:commit] == 'Save and View'
|
34
|
+
redirect_to effective_pages.page_path(@page)
|
32
35
|
else
|
33
36
|
flash[:success] = 'Successfully created page'
|
34
37
|
redirect_to effective_pages.edit_admin_page_path(@page)
|
@@ -53,10 +56,24 @@ module Admin
|
|
53
56
|
authorize_effective_pages!
|
54
57
|
|
55
58
|
if @page.update_attributes(page_params)
|
56
|
-
if params[:commit] == 'Save and Edit Content'
|
59
|
+
if params[:commit] == 'Save and Edit Content'
|
57
60
|
redirect_to effective_regions.edit_path(effective_pages.page_path(@page), :exit => effective_pages.edit_admin_page_path(@page))
|
58
61
|
elsif params[:commit] == 'Save and Add New'
|
62
|
+
flash[:success] = 'Successfully updated page'
|
59
63
|
redirect_to effective_pages.new_admin_page_path
|
64
|
+
elsif params[:commit] == 'Save and View'
|
65
|
+
redirect_to effective_pages.page_path(@page)
|
66
|
+
elsif params[:commit] == 'Duplicate'
|
67
|
+
begin
|
68
|
+
page = @page.duplicate!
|
69
|
+
flash[:success] = 'Successfully saved and duplicated page.'
|
70
|
+
flash[:info] = "You are now editting the duplicated page. This new page has been created as a Draft."
|
71
|
+
rescue => e
|
72
|
+
flash.delete(:success)
|
73
|
+
flash[:danger] = "Unable to duplicate page: #{e.message}"
|
74
|
+
end
|
75
|
+
|
76
|
+
redirect_to effective_pages.edit_admin_page_path(page || @page)
|
60
77
|
else
|
61
78
|
flash[:success] = 'Successfully updated page'
|
62
79
|
redirect_to effective_pages.edit_admin_page_path(@page)
|
@@ -2,7 +2,7 @@ module Effective
|
|
2
2
|
class PagesController < ApplicationController
|
3
3
|
def show
|
4
4
|
@pages = Effective::Page.all
|
5
|
-
@pages = @pages.published unless (
|
5
|
+
@pages = @pages.published unless EffectivePosts.authorized?(self, :admin, :effective_pages)
|
6
6
|
|
7
7
|
@page = @pages.find(params[:id])
|
8
8
|
|
@@ -14,7 +14,24 @@ module Effective
|
|
14
14
|
@page_title = @page.title
|
15
15
|
@meta_description = @page.meta_description
|
16
16
|
|
17
|
+
if EffectivePages.authorized?(self, :admin, :effective_pages)
|
18
|
+
flash.now[:warning] = [
|
19
|
+
'Hi Admin!',
|
20
|
+
('You are viewing a hidden page.' unless @page.published?),
|
21
|
+
'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?),
|
23
|
+
("<a href='#{effective_pages.edit_admin_page_path(@page)}' class='alert-link'>edit page settings</a>.")
|
24
|
+
].compact.join(' ')
|
25
|
+
end
|
26
|
+
|
17
27
|
render @page.template, layout: @page.layout, locals: { page: @page }
|
18
28
|
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def admin_edit?
|
33
|
+
EffectivePages.authorized?(self, :admin, :effective_posts) && (params[:edit].to_s == 'true')
|
34
|
+
end
|
35
|
+
|
19
36
|
end
|
20
37
|
end
|
@@ -37,6 +37,26 @@ module Effective
|
|
37
37
|
def to_s
|
38
38
|
title
|
39
39
|
end
|
40
|
+
|
41
|
+
def published?
|
42
|
+
!draft?
|
43
|
+
end
|
44
|
+
|
45
|
+
# Returns a duplicated post object, or throws an exception
|
46
|
+
def duplicate!
|
47
|
+
Page.new(attributes.except('id', 'updated_at', 'created_at')).tap do |page|
|
48
|
+
page.title = page.title + ' (Copy)'
|
49
|
+
page.slug = page.slug + '-copy'
|
50
|
+
page.draft = true
|
51
|
+
|
52
|
+
regions.each do |region|
|
53
|
+
page.regions.build(region.attributes.except('id', 'updated_at', 'created_at'))
|
54
|
+
end
|
55
|
+
|
56
|
+
page.save!
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
40
60
|
end
|
41
61
|
|
42
62
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
= dropdown(variation: :dropleft) do
|
2
2
|
= dropdown_link_to 'Edit', effective_pages.edit_admin_page_path(page)
|
3
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
|
4
|
+
= dropdown_link_to 'View', effective_pages.page_path(page), 'data-no-turbolink': true, target: '_blank'
|
5
5
|
|
6
6
|
= dropdown_link_to "Delete #{page}", effective_pages.admin_page_path(page),
|
7
7
|
data: { method: :delete, confirm: "Really delete #{page}?" }
|
@@ -1,14 +1,5 @@
|
|
1
1
|
= effective_form_with(model: page, url: (page.persisted? ? effective_pages.admin_page_path(page.id) : effective_pages.admin_pages_path)) do |f|
|
2
2
|
= f.text_field :title, hint: 'The title of your page.', input_html: { maxlength: 255 }
|
3
|
-
= f.check_box :draft, label: 'Save this page as a draft. It will not be accessible on the website.'
|
4
|
-
|
5
|
-
- if f.object.persisted? || f.object.errors.include?(:slug)
|
6
|
-
- current_url = (effective_pages.page_url(f.object) rescue nil)
|
7
|
-
= f.text_field :slug, hint: "The slug controls this page's internet address. Be careful, changing the slug will break links that other websites may have to the old address.<br>#{('This page is currently reachable via ' + link_to(current_url.gsub(f.object.slug, '<strong>' + f.object.slug + '</strong>').html_safe, current_url)) if current_url }".html_safe
|
8
|
-
|
9
|
-
= render partial: '/admin/pages/additional_fields', locals: { page: page, form: f, f: f }
|
10
|
-
|
11
|
-
= 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 }
|
12
3
|
|
13
4
|
- if (templates = EffectivePages.templates).length == 1
|
14
5
|
= f.hidden_field :template, value: templates.first
|
@@ -20,8 +11,22 @@
|
|
20
11
|
- else
|
21
12
|
= f.select :layout, layouts
|
22
13
|
|
14
|
+
- if f.object.persisted? || f.object.errors.include?(:slug)
|
15
|
+
- current_url = (effective_pages.page_url(f.object) rescue nil)
|
16
|
+
= f.text_field :slug, hint: "The slug controls this page's internet address. Be careful, changing the slug will break links that other websites may have to the old address.<br>#{('This page is currently reachable via ' + link_to(current_url.gsub(f.object.slug, '<strong>' + f.object.slug + '</strong>').html_safe, current_url)) if current_url }".html_safe
|
17
|
+
|
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
|
+
|
20
|
+
= render partial: '/admin/pages/additional_fields', locals: { page: page, form: f, f: f }
|
21
|
+
|
22
|
+
= f.check_box :draft, label: 'Save this page as a draft. It will not be accessible on the website.'
|
23
|
+
|
24
|
+
- if defined?(EffectiveRoles) and f.object.respond_to?(:roles) && EffectivePages.use_effective_roles
|
25
|
+
= f.checks :roles, EffectiveRoles.roles_collection(f.object), hint: '* leave blank for a regular public page that anyone can view'
|
26
|
+
|
23
27
|
= f.submit do
|
24
28
|
= f.save 'Save'
|
25
|
-
= f.save 'Save and Edit Content'
|
26
|
-
= f.save 'Save and
|
27
|
-
|
29
|
+
= f.save 'Save and Edit Content', class: 'btn btn-secondary'
|
30
|
+
= f.save 'Save and View', class: 'btn btn-secondary'
|
31
|
+
- if f.object.persisted?
|
32
|
+
= f.save 'Duplicate', class: 'btn btn-info'
|
data/config/effective_pages.rb
CHANGED
@@ -38,6 +38,9 @@ EffectivePages.setup do |config|
|
|
38
38
|
config.silence_missing_page_title_warnings = false
|
39
39
|
config.silence_missing_meta_description_warnings = false
|
40
40
|
|
41
|
+
# Display the effective roles 'choose roles' input when an admin creates a new post
|
42
|
+
config.use_effective_roles = false
|
43
|
+
|
41
44
|
# Authorization Method
|
42
45
|
#
|
43
46
|
# This method is called by all controller actions with the appropriate action and resource
|
data/lib/effective_pages.rb
CHANGED
@@ -23,10 +23,12 @@ module EffectivePages
|
|
23
23
|
|
24
24
|
mattr_accessor :silence_missing_page_title_warnings
|
25
25
|
mattr_accessor :silence_missing_meta_description_warnings
|
26
|
+
|
27
|
+
mattr_accessor :use_effective_roles
|
26
28
|
|
29
|
+
mattr_accessor :menu
|
27
30
|
mattr_accessor :authorization_method
|
28
31
|
mattr_accessor :layout
|
29
|
-
mattr_accessor :menu
|
30
32
|
|
31
33
|
def self.setup
|
32
34
|
yield self
|
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.
|
4
|
+
version: 2.0.2
|
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: 2019-04-
|
11
|
+
date: 2019-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|