Module: EffectivePagesHelper
- Defined in:
- app/helpers/effective_pages_helper.rb
Instance Method Summary collapse
- #application_root_to_effective_pages_slug ⇒ Object
- #effective_pages_body_classes ⇒ Object
- #effective_pages_header_tags ⇒ Object
- #effective_pages_meta_description ⇒ Object
- #effective_pages_site_title ⇒ Object
Instance Method Details
#application_root_to_effective_pages_slug ⇒ Object
36 37 38 |
# File 'app/helpers/effective_pages_helper.rb', line 36 def application_root_to_effective_pages_slug Rails.application.routes.routes.find { |r| r.name == 'root' && r.defaults[:controller] == 'Effective::Pages' && r.defaults[:action] == 'show' }.defaults[:id] rescue nil end |
#effective_pages_body_classes ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'app/helpers/effective_pages_helper.rb', line 3 def effective_pages_body_classes [ params[:controller].parameterize, params[:action], ((user_signed_in? ? 'signed-in'.freeze : 'not-signed-in'.freeze) rescue nil), (@page.template rescue nil), @body_classes ].compact.join(' ') end |
#effective_pages_header_tags ⇒ Object
13 14 15 16 17 18 |
# File 'app/helpers/effective_pages_helper.rb', line 13 def [ content_tag(:title, effective_pages_site_title), tag(:meta, name: 'description'.freeze, content: ) ].compact.join("\n").html_safe end |
#effective_pages_meta_description ⇒ Object
28 29 30 31 32 33 34 |
# File 'app/helpers/effective_pages_helper.rb', line 28 def unless @meta_description.present? || EffectivePages. Rails.logger.error("WARNING: Expected @meta_description to be present. Please assign a @meta_description variable in your controller action.") end truncate((@meta_description || EffectivePages.).to_s, length: 150) end |
#effective_pages_site_title ⇒ Object
20 21 22 23 24 25 26 |
# File 'app/helpers/effective_pages_helper.rb', line 20 def effective_pages_site_title unless @page_title.present? || EffectivePages.silence_missing_page_title_warnings Rails.logger.error("WARNING: Expected @page_title to be present. Please assign a @page_title variable in your controller action.") end (@page_title || "#{params[:controller].try(:titleize)} #{params[:action].try(:titleize)}") + EffectivePages.site_title_suffix.to_s end |