Module: UsefulHelpers::Helpers::SeoHelper

Defined in:
lib/useful_helpers/helpers/seo_helper.rb

Instance Method Summary collapse

Instance Method Details



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/useful_helpers/helpers/seo_helper.rb', line 29

def breadcrumbs(prefix, links)
  case prefix
    when "root"
      anchor = I18n.t("useful_helpers.breadcrumbs.root")
      path = "/"
    when "dashboard"
      anchor = I18n.t("useful_helpers.breadcrumbs.dashboard")
      path = "/dashboard"
    when "admin"
      anchor = I18n.t("useful_helpers.breadcrumbs.admin")
      path = "/admin"
    else
      anchor, path = nil, nil
  end
  return "" if path.nil?
  first_link = ["<a title=\"#{anchor}\" href=\"#{path}\">#{anchor}</a>"]
  content_for :breadcrumbs do
    raw "<div class=\"breadcrumbs\">#{(first_link+links).flatten.compact.join(delimiter)}</div>"
  end
end

#build_meta_titleObject



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/useful_helpers/helpers/seo_helper.rb', line 50

def build_meta_title
  html = @meta_title
  if @medium_title.present?
    html << " — #{@medium_title}"
  end
  city_abbr = I18n.t("useful_helpers.city_abbr")
  regional_suffix = @city.present? ? @city.formatted : I18n.t("useful_helpers.regional_suffix")
  unless ca('welcome', 'index') || ca('granat_cms/welcome', 'index')
    if html.include?(regional_suffix)
      html << " — #{@site_name}"
    elsif @city.present?
      html << " — #{@site_name}, #{city_abbr} #{@city.ru}"
    else
      html << " — #{@full_site_name}"
    end
  end
  html << " | #{I18n.t('useful_helpers.page')} #{@page_counter}" if @page_counter && @page_counter != 1
  html
end

#canonical(url) ⇒ Object



13
14
15
16
17
# File 'lib/useful_helpers/helpers/seo_helper.rb', line 13

def canonical(url)
  content_for :head do
    raw "<link rel=\"canonical\" href=\"#{url}\" />"
  end
end

#delimiterObject



5
6
7
# File 'lib/useful_helpers/helpers/seo_helper.rb', line 5

def delimiter
  raw '&#32;&#8594;&#32;'
end

#noindexObject



19
20
21
22
23
# File 'lib/useful_helpers/helpers/seo_helper.rb', line 19

def noindex
  content_for :head do
    noindex_tag
  end
end

#noindex_tagObject



25
26
27
# File 'lib/useful_helpers/helpers/seo_helper.rb', line 25

def noindex_tag
  raw '<meta name="robots" content="noindex, nofollow" />'
end

#page_title(page_title) ⇒ Object



9
10
11
# File 'lib/useful_helpers/helpers/seo_helper.rb', line 9

def page_title(page_title)
  content_for(:page_title) { raw("<h1>#{page_title}</h1>") }
end