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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a262f391f673a4b0d27dca076bbc5cfc306547e1
4
- data.tar.gz: 796159e1cdd9cbfea0e09a534f7bfa5a1ae97e56
3
+ metadata.gz: 6519c072e0f33034dd230778c59212f604c6c15e
4
+ data.tar.gz: 5b828b12af25626e858df9c74dd2a3b6cc4bc9b0
5
5
  SHA512:
6
- metadata.gz: 5e7bc28fd83ff3f5b923c5848d5c52cad7bc7f7dd476916b39a530e6ed1f6668536f2c81adf9d4b3c43469126bfa9dc65ea55e65f267a51c40cc0008c6669fbb
7
- data.tar.gz: f0e511ec45b3c4cefac7087f74beae2856261a2a21eb2a32c920d6f9fbbc0a96c3b45943395405fe5125ce79a3a774bf272909a423cc260c56abd43e3d9af513
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 page.
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 if params[:edit].to_s != 'true'
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
- effective_pages_meta_description_tag
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
- (@page_title ? @page_title.to_s : "#{params[:controller].try(:titleize)} #{params[:action].try(:titleize)}") + EffectivePages.site_title_suffix.to_s
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 effective_pages_meta_description_tag
25
- if @meta_description.present?
26
- "<meta content='#{truncate(@meta_description, :length => 150)}' name='description' />"
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' and r.defaults[:controller] == 'Effective::Pages' and r.defaults[:action] == 'show' }.defaults[:id] rescue nil
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
@@ -1,7 +1,6 @@
1
1
  class EffectivePagesRoutingConstraint
2
2
  def self.matches?(request)
3
- id = request.path_parameters[:id] || '/'
4
- Effective::Page.find(id).present? rescue false
3
+ Effective::Page.find(request.path_parameters[:id] || '/').present? rescue false
5
4
  end
6
5
  end
7
6
 
@@ -1,3 +1,3 @@
1
1
  module EffectivePages
2
- VERSION = '1.0.12'.freeze
2
+ VERSION = '1.0.13'.freeze
3
3
  end
@@ -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: can?(action, resource)
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.12
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-21 00:00:00.000000000 Z
11
+ date: 2016-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails