Module: SeoHelper::Helper
- Defined in:
- lib/seo_helper/helper.rb
Instance Attribute Summary collapse
-
#page_description ⇒ Object
readonly
Returns the value of attribute page_description.
-
#page_image ⇒ Object
readonly
Returns the value of attribute page_image.
-
#page_keywords ⇒ Object
readonly
Returns the value of attribute page_keywords.
-
#page_title ⇒ Object
readonly
Returns the value of attribute page_title.
Instance Method Summary collapse
-
#description_meta_tag(content, with_site_name = false) ⇒ Object
<meta name=“description” content=“…” />.
-
#image_src_link_tag(image_url) ⇒ Object
<link rel=“image_src” content=“…” />.
-
#keywords_meta_tag(keywords) ⇒ Object
<meta name=“keywords” content=“…” />.
-
#render_page_description_meta_tag ⇒ Object
———-
---------------
——————- present | @page_xxx | @page_xxx blank | (no output) | default_page_xxx. - #render_page_image_link_tag ⇒ Object
- #render_page_keywords_meta_tag ⇒ Object
- #render_page_title_meta_tag ⇒ Object
- #render_page_title_tag ⇒ Object
-
#robots_meta_tag(content = "INDEX,FOLLOW") ⇒ Object
<meta name=“robots” content=“INDEX,FOLLOW” />.
-
#title_meta_tag(title, with_site_name = false) ⇒ Object
<meta name=“title” content=“…” />.
-
#title_tag(title, with_site_name = false) ⇒ Object
<title>…</title>.
Instance Attribute Details
#page_description ⇒ Object (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_image ⇒ Object (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_keywords ⇒ Object (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_title ⇒ Object (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 (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((content))) tag(:meta, { :name => "description", :content => content }) end |
#image_src_link_tag(image_url) ⇒ Object
<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) keywords = keywords.join(',') if keywords.is_a? Array tag(:meta, {:name => "keywords", :content => h(keywords)}) end |
#render_page_description_meta_tag ⇒ Object
———----------------
——————- present | @page_xxx | @page_xxx blank | (no output) | default_page_xxx
56 57 58 59 |
# File 'lib/seo_helper/helper.rb', line 56 def return if SeoHelper.configuration.skip_blank && page_description.blank? (page_description || SeoHelper.configuration.default_page_description) end |
#render_page_image_link_tag ⇒ Object
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_tag ⇒ Object
61 62 63 64 |
# File 'lib/seo_helper/helper.rb', line 61 def return if SeoHelper.configuration.skip_blank && page_keywords.blank? (page_keywords || SeoHelper.configuration.default_page_keywords) end |
#render_page_title_meta_tag ⇒ Object
47 48 49 |
# File 'lib/seo_helper/helper.rb', line 47 def (page_title || SeoHelper.configuration.site_name) end |
#render_page_title_tag ⇒ Object
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 (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, 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 content_tag(:title, h(title), nil, false) # option=nil, escape=false end |