Module: SeoPages::ApplicationHelper

Defined in:
app/helpers/seo_pages/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#seo_data ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'app/helpers/seo_pages/application_helper.rb', line 3

def seo_data
  @seo_default ||= SeoPages::SeoPageDefault.first
  @seo = SeoPages::SeoPage.where(url_identifier: request.fullpath).first || SeoPages::SeoPage.new
  
  @seo.page_title ||= @seo_default.page_title
  @seo.meta_keywords ||= @seo_default.meta_keywords
  @seo.meta_description ||= @seo_default.meta_description
  
  @seo
end

#seo_meta_tag(type, content) ⇒ Object



19
20
21
# File 'app/helpers/seo_pages/application_helper.rb', line 19

def seo_meta_tag(type, content)
  "<meta name='#{type}' content='#{content}'>"
end

#seo_page ⇒ Object



23
24
25
26
27
28
# File 'app/helpers/seo_pages/application_helper.rb', line 23

def seo_page
  s_title = seo_title_tag(content_for?(:title) ? content_for(:title) : seo_data.page_title)
  s_desc  = seo_meta_tag('description', content_for?(:meta_description) ? content_for(:meta_description) : "#{seo_data.meta_description}")
  s_keywords  = seo_meta_tag('keywords', content_for?(:meta_keywords) ? content_for(:meta_keywords) : "#{seo_data.meta_keywords}")
  raw("#{s_title} \n #{s_desc} \n #{s_keywords}")
end

#seo_page_meta_description(content) ⇒ Object



34
35
36
# File 'app/helpers/seo_pages/application_helper.rb', line 34

def seo_page_meta_description(content)
  content_for(:meta_description) { content }
end

#seo_page_meta_keywrods(content) ⇒ Object



38
39
40
# File 'app/helpers/seo_pages/application_helper.rb', line 38

def seo_page_meta_keywrods(content)
  content_for(:meta_keywords) { content }
end

#seo_page_title(content) ⇒ Object



30
31
32
# File 'app/helpers/seo_pages/application_helper.rb', line 30

def seo_page_title(content)
  content_for(:title) { content }
end

#seo_title_tag(content) ⇒ Object



14
15
16
# File 'app/helpers/seo_pages/application_helper.rb', line 14

def seo_title_tag(content)
  "<title>#{content}</title>"
end