Module: SeoHelper::Helper

Defined in:
lib/seo_helper/helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#page_descriptionObject (readonly)

Returns the value of attribute page_description.



40
41
42
# File 'lib/seo_helper/helper.rb', line 40

def page_description
  @page_description
end

#page_imageObject (readonly)

Returns the value of attribute page_image.



40
41
42
# File 'lib/seo_helper/helper.rb', line 40

def page_image
  @page_image
end

#page_keywordsObject (readonly)

Returns the value of attribute page_keywords.



40
41
42
# File 'lib/seo_helper/helper.rb', line 40

def page_keywords
  @page_keywords
end

#page_titleObject (readonly)

Returns the value of attribute page_title.



40
41
42
# File 'lib/seo_helper/helper.rb', line 40

def page_title
  @page_title
end

Instance Method Details

#description_meta_tag(content, with_site_name = false) ⇒ Object

<meta name=“description” content=“…” />



17
18
19
20
21
22
# File 'lib/seo_helper/helper.rb', line 17

def description_meta_tag(content, with_site_name=false)
  title = SeoHelper.format_site_name(title, SeoHelper.configuration.site_name) if with_site_name == true
  # use String.new to avoid always (html_save == true) which makes h() inactive
  content = h(String.new(strip_tags(content)))
  tag(:meta, { :name => "description", :content => content })
end

<link rel=“image_src” content=“…” />



31
32
33
# File 'lib/seo_helper/helper.rb', line 31

def image_src_link_tag(image_url)
  tag(:link, { :rel => "image_src", :href => image_url })
end

#keywords_meta_tag(keywords) ⇒ Object

<meta name=“keywords” content=“…” />



25
26
27
28
# File 'lib/seo_helper/helper.rb', line 25

def keywords_meta_tag(keywords)
  keywords = keywords.join(',') if keywords.is_a? Array
  tag(:meta, {:name => "keywords", :content => h(keywords)})
end

#render_page_description_meta_tagObject

———----------------——————- present | @page_xxx | @page_xxx blank | (no output) | default_page_xxx



56
57
58
59
# File 'lib/seo_helper/helper.rb', line 56

def render_page_description_meta_tag
  return if SeoHelper.configuration.skip_blank && page_description.blank?
  description_meta_tag(page_description || SeoHelper.configuration.default_page_description)
end


66
67
68
69
# File 'lib/seo_helper/helper.rb', line 66

def render_page_image_link_tag
  return if SeoHelper.configuration.skip_blank && page_image.blank?
  image_src_link_tag(page_image || SeoHelper.configuration.default_page_image)
end

#render_page_keywords_meta_tagObject



61
62
63
64
# File 'lib/seo_helper/helper.rb', line 61

def render_page_keywords_meta_tag
  return if SeoHelper.configuration.skip_blank && page_keywords.blank?
  keywords_meta_tag(page_keywords || SeoHelper.configuration.default_page_keywords)
end

#render_page_title_meta_tagObject



47
48
49
# File 'lib/seo_helper/helper.rb', line 47

def render_page_title_meta_tag
  title_meta_tag(page_title || SeoHelper.configuration.site_name)
end

#render_page_title_tagObject



42
43
44
45
# File 'lib/seo_helper/helper.rb', line 42

def render_page_title_tag
  # fallback to site_name if @page_title has never been set
  title_tag(page_title || SeoHelper.configuration.site_name)
end

#robots_meta_tag(content = "INDEX,FOLLOW") ⇒ Object

<meta name=“robots” content=“INDEX,FOLLOW” />



36
37
38
# File 'lib/seo_helper/helper.rb', line 36

def robots_meta_tag(content = "INDEX,FOLLOW")
  tag(:meta, { :name => "robots", :content => content })
end

#title_meta_tag(title, with_site_name = false) ⇒ Object

<meta name=“title” content=“…” />



11
12
13
14
# File 'lib/seo_helper/helper.rb', line 11

def title_meta_tag(title, with_site_name=false)
  title = SeoHelper.format_site_name(title, SeoHelper.configuration.site_name) if with_site_name == true
  tag(:meta, {:name => "title", :content => h(title)})
end

#title_tag(title, with_site_name = false) ⇒ Object

<title>…</title>



5
6
7
8
# File 'lib/seo_helper/helper.rb', line 5

def title_tag(title, with_site_name=false)
  title = SeoHelper.format_site_name(title, SeoHelper.configuration.site_name) if with_site_name == true
  (:title, h(title), nil, false)  # option=nil, escape=false
end