Sha256: e741221ae267467f9e5b4b7cba7d0495967375eac63c14f9b28ead1aa2302ad9

Contents?: true

Size: 1.17 KB

Versions: 12

Compression:

Stored size: 1.17 KB

Contents

module EffectivePagesHelper

  def effective_pages_body_classes
    [
      params[:controller].parameterize,
      params[:action],
      ((user_signed_in? ? 'signed-in' : 'not-signed-in') rescue nil),
      (@page.template rescue nil),
      @body_classes
    ].compact.join(' ')
  end

  def effective_pages_header_tags
    [
      content_tag(:title, effective_pages_site_title),
      effective_pages_meta_description_tag
    ].compact.join("\n").html_safe
  end

  def effective_pages_site_title
    (@page_title ? @page_title.to_s : "#{params[:controller].try(:titleize)} #{params[:action].try(:titleize)}") + EffectivePages.site_title_suffix.to_s
  end

  def effective_pages_meta_description_tag
    if @meta_description.present?
      "<meta content='#{truncate(@meta_description, :length => 150)}' name='description' />"
    elsif @page.try(:meta_description).present?
      "<meta content='#{@page.meta_description}' name='description' />"
    end
  end

  def application_root_to_effective_pages_slug
    Rails.application.routes.routes.find { |r| r.name == 'root' and r.defaults[:controller] == 'Effective::Pages' and r.defaults[:action] == 'show' }.defaults[:id] rescue nil
  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
effective_pages-1.0.12 app/helpers/effective_pages_helper.rb
effective_pages-1.0.11 app/helpers/effective_pages_helper.rb
effective_pages-1.0.10 app/helpers/effective_pages_helper.rb
effective_pages-1.0.9 app/helpers/effective_pages_helper.rb
effective_pages-1.0.8 app/helpers/effective_pages_helper.rb
effective_pages-1.0.7 app/helpers/effective_pages_helper.rb
effective_pages-1.0.6 app/helpers/effective_pages_helper.rb
effective_pages-1.0.5 app/helpers/effective_pages_helper.rb
effective_pages-1.0.4 app/helpers/effective_pages_helper.rb
effective_pages-1.0.3 app/helpers/effective_pages_helper.rb
effective_pages-1.0.2 app/helpers/effective_pages_helper.rb
effective_pages-1.0.1 app/helpers/effective_pages_helper.rb