effective_pages 1.0.12 → 1.0.13
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/README.md +3 -1
- data/app/controllers/effective/pages_controller.rb +2 -1
- data/app/helpers/effective_pages_helper.rb +13 -9
- data/app/views/admin/pages/_actions.html.haml +1 -5
- data/config/routes.rb +1 -2
- data/lib/effective_pages/version.rb +1 -1
- data/lib/effective_pages.rb +5 -0
- data/lib/generators/templates/effective_pages.rb +14 -4
- 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: 6519c072e0f33034dd230778c59212f604c6c15e
|
4
|
+
data.tar.gz: 5b828b12af25626e858df9c74dd2a3b6cc4bc9b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ab242c1cacad6f21e995fb8669f3ac3145ca889c7347024acf4ae16158a21876a463918869d16c57e6bcab32ac75676e2988346cb7c20d19f286cecbf63b888
|
7
|
+
data.tar.gz: 14d28c3a2b97ca4ce480e1cbf7f947eec60bbbc9d4e9db039b0fca23aed1e5321bfa42b208ce72dd96bc8403895ed4527086195922593ddc22758468ab372406
|
data/README.md
CHANGED
@@ -47,7 +47,7 @@ Then migrate the database:
|
|
47
47
|
rake db:migrate
|
48
48
|
```
|
49
49
|
|
50
|
-
Add the following helper to your application layout in the `<head>..</head>` section. This will properly create `<title>` and `<meta description>` tags based on the
|
50
|
+
Add the following helper to your application layout in the `<head>..</head>` section. This will properly create `<title>` and `<meta description>` tags based on the Effective::Page and the controller instance variables `@page_title` and `@meta_description` for non Effective::Page routes.
|
51
51
|
|
52
52
|
```ruby
|
53
53
|
= effective_pages_header_tags
|
@@ -145,6 +145,8 @@ This helper inserts a `<title>...</title>` html tag based on the `@page_title` i
|
|
145
145
|
|
146
146
|
This helper also inserts a `<meta name='description' content='...' />` html tag based on the `@meta_description` instance variable, which you can set anywhere on your non-effective controllers, and whose value is set to the `@page.meta_description` value when displaying an `Effective::Page`. This tag provides the content that search engines use to display their search results. This value will automatically be truncated to 150 characters.
|
147
147
|
|
148
|
+
This helper will also warn about missing `@page_title` and `@meta_description` variables. You can turn off the warnings in the config file.
|
149
|
+
|
148
150
|
This helper is entirely optional and in no way required for effective_pages to work.
|
149
151
|
|
150
152
|
### Body Tag Classes
|
@@ -2,7 +2,7 @@ module Effective
|
|
2
2
|
class PagesController < ApplicationController
|
3
3
|
def show
|
4
4
|
@pages = (Rails::VERSION::MAJOR > 3 ? Effective::Page.all : Effective::Page.scoped)
|
5
|
-
@pages = @pages.published
|
5
|
+
@pages = @pages.published unless (params[:edit] || params[:preview])
|
6
6
|
|
7
7
|
@page = @pages.find(params[:id])
|
8
8
|
|
@@ -12,6 +12,7 @@ module Effective
|
|
12
12
|
EffectivePages.authorized?(self, :show, @page)
|
13
13
|
|
14
14
|
@page_title = @page.title
|
15
|
+
@meta_description = @page.meta_description
|
15
16
|
|
16
17
|
render @page.template, :layout => @page.layout, :locals => {:page => @page}
|
17
18
|
end
|
@@ -4,7 +4,7 @@ module EffectivePagesHelper
|
|
4
4
|
[
|
5
5
|
params[:controller].parameterize,
|
6
6
|
params[:action],
|
7
|
-
((user_signed_in? ? 'signed-in' : 'not-signed-in') rescue nil),
|
7
|
+
((user_signed_in? ? 'signed-in'.freeze : 'not-signed-in'.freeze) rescue nil),
|
8
8
|
(@page.template rescue nil),
|
9
9
|
@body_classes
|
10
10
|
].compact.join(' ')
|
@@ -13,24 +13,28 @@ module EffectivePagesHelper
|
|
13
13
|
def effective_pages_header_tags
|
14
14
|
[
|
15
15
|
content_tag(:title, effective_pages_site_title),
|
16
|
-
|
16
|
+
tag(:meta, name: 'description'.freeze, content: effective_pages_meta_description)
|
17
17
|
].compact.join("\n").html_safe
|
18
18
|
end
|
19
19
|
|
20
20
|
def effective_pages_site_title
|
21
|
-
|
21
|
+
unless @page_title.present? || EffectivePages.silence_missing_page_title_warnings
|
22
|
+
Rails.logger.error("WARNING: Expected @page_title to be present. Please assign a @page_title variable in your controller action.")
|
23
|
+
end
|
24
|
+
|
25
|
+
(@page_title || "#{params[:controller].try(:titleize)} #{params[:action].try(:titleize)}") + EffectivePages.site_title_suffix.to_s
|
22
26
|
end
|
23
27
|
|
24
|
-
def
|
25
|
-
|
26
|
-
"
|
27
|
-
elsif @page.try(:meta_description).present?
|
28
|
-
"<meta content='#{@page.meta_description}' name='description' />"
|
28
|
+
def effective_pages_meta_description
|
29
|
+
unless @meta_description.present? || EffectivePages.silence_missing_meta_description_warnings
|
30
|
+
Rails.logger.error("WARNING: Expected @meta_description to be present. Please assign a @meta_description variable in your controller action.")
|
29
31
|
end
|
32
|
+
|
33
|
+
truncate((@meta_description || EffectivePages.fallback_meta_description).to_s, length: 150)
|
30
34
|
end
|
31
35
|
|
32
36
|
def application_root_to_effective_pages_slug
|
33
|
-
Rails.application.routes.routes.find { |r| r.name == 'root'
|
37
|
+
Rails.application.routes.routes.find { |r| r.name == 'root' && r.defaults[:controller] == 'Effective::Pages' && r.defaults[:action] == 'show' }.defaults[:id] rescue nil
|
34
38
|
end
|
35
39
|
|
36
40
|
end
|
@@ -1,11 +1,7 @@
|
|
1
|
-
- if page.draft?
|
2
|
-
= link_to effective_orders.undraft_admin_page_path(page), title: 'Approve' do
|
3
|
-
%span.glyphicon.glyphicon-ok
|
4
|
-
|
5
1
|
= link_to effective_pages.edit_admin_page_path(page.id), title: 'Settings' do
|
6
2
|
%span.glyphicon.glyphicon-cog
|
7
3
|
|
8
|
-
= link_to effective_pages.page_path(page), title: 'View', target: '_blank' do
|
4
|
+
= link_to effective_pages.page_path(page, (page.draft? ? {preview: true} : nil)), title: 'View', 'data-no-turbolink': true, target: '_blank' do
|
9
5
|
%span.glyphicon.glyphicon-eye-open
|
10
6
|
|
11
7
|
- if defined?(EffectiveRegions)
|
data/config/routes.rb
CHANGED
data/lib/effective_pages.rb
CHANGED
@@ -14,7 +14,12 @@ module EffectivePages
|
|
14
14
|
mattr_accessor :pages_path
|
15
15
|
mattr_accessor :excluded_pages
|
16
16
|
mattr_accessor :excluded_layouts
|
17
|
+
|
17
18
|
mattr_accessor :site_title_suffix
|
19
|
+
mattr_accessor :fallback_meta_description
|
20
|
+
|
21
|
+
mattr_accessor :silence_missing_page_title_warnings
|
22
|
+
mattr_accessor :silence_missing_meta_description_warnings
|
18
23
|
|
19
24
|
mattr_accessor :authorization_method
|
20
25
|
mattr_accessor :simple_form_options
|
@@ -19,6 +19,19 @@ EffectivePages.setup do |config|
|
|
19
19
|
# Any app/views/layouts/ layout files that should be excluded
|
20
20
|
config.excluded_layouts = [:admin]
|
21
21
|
|
22
|
+
# This string will be appended to the effective_pages_header_tags title tag
|
23
|
+
config.site_title_suffix = " | #{Rails.application.class.name.split('::').first.titleize}"
|
24
|
+
|
25
|
+
# When using the effective_pages_header_tags() helper in <head> to set the <meta name='description'>
|
26
|
+
# The value will be populated from an Effective::Page's .meta_description field,
|
27
|
+
# a present @meta_description controller instance variable or this fallback value.
|
28
|
+
# This will be truncated to 150 characters.
|
29
|
+
config.fallback_meta_description = ''
|
30
|
+
|
31
|
+
# Turn off missing meta page title and meta description warnings
|
32
|
+
config.silence_missing_page_title_warnings = false
|
33
|
+
config.silence_missing_meta_description_warnings = false
|
34
|
+
|
22
35
|
# Work with EffectiveAssets
|
23
36
|
# The following will be passed into the acts_as_asset_box for the Effective::Page model
|
24
37
|
# The /admin/pages/new form will create the corresponding inputs
|
@@ -26,7 +39,7 @@ EffectivePages.setup do |config|
|
|
26
39
|
#config.acts_as_asset_box = header_image: true
|
27
40
|
#config.acts_as_asset_box = { header_image: true, body_images: 1..4 }
|
28
41
|
|
29
|
-
# Use CanCan:
|
42
|
+
# Use CanCan: authorize!(action, resource)
|
30
43
|
# Use effective_roles: resource.roles_permit?(current_user)
|
31
44
|
config.authorization_method = Proc.new { |controller, action, resource| true }
|
32
45
|
|
@@ -38,9 +51,6 @@ EffectivePages.setup do |config|
|
|
38
51
|
:admin => 'application'
|
39
52
|
}
|
40
53
|
|
41
|
-
# This string will be appended to the effective_pages_header_tags title tag
|
42
|
-
config.site_title_suffix = " | #{Rails.application.class.name.split('::').first.titleize}"
|
43
|
-
|
44
54
|
# SimpleForm Options
|
45
55
|
# This Hash of options will be passed into any simple_form_for() calls
|
46
56
|
config.simple_form_options = {}
|
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: 1.0.
|
4
|
+
version: 1.0.13
|
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: 2016-03-
|
11
|
+
date: 2016-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|