Module: Gluttonberg::Public::PageInfo

Included in:
Gluttonberg::Public
Defined in:
app/helpers/gluttonberg/public/page_info.rb

Instance Method Summary collapse

Instance Method Details

#body_class(page = nil) ⇒ Object



117
118
119
120
121
122
123
124
125
126
127
128
# File 'app/helpers/gluttonberg/public/page_info.rb', line 117

def body_class(page=nil)
  page = @page if page.blank?
  if !page.blank?
   "page #{page.current_localization.slug.blank? ? page.slug : page.current_localization.slug} #{page.home? ? 'home' : ''}"
  else
    object = find_current_object_for_meta_tags
    unless object.blank?
      class_name = (Gluttonberg.constants.include?(:Blog) && object.kind_of?(Gluttonberg::Blog::ArticleLocalization) ? 'post' : object.class.name.demodulize.downcase)
      "#{class_name} #{object.slug}"
    end
  end
end

#og_imageObject Also known as: page_fb_icon_path

This returns absolute path to OG image. It checks for page/article/custom model for fb_icon_id method otherwise it checks for website fb_icon_id from settings



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'app/helpers/gluttonberg/public/page_info.rb', line 42

def og_image
  object = find_current_object_for_meta_tags
  fb_icon_id = Gluttonberg::Setting.get_setting("fb_icon", current_site_config_name)

  if !object.blank? && object.respond_to?(:fb_icon_id) && !object.fb_icon_id.blank?
    fb_icon_id = object.fb_icon_id
  end

  asset = unless fb_icon_id.blank?
    Asset.where(:id => fb_icon_id).first
  end

  if asset
    return "http://#{request.host_with_port}#{asset.url}"
  else
    return nil
  end
end

#og_site_nameObject

It only returns website title from backend settings



33
34
35
36
37
# File 'app/helpers/gluttonberg/public/page_info.rb', line 33

def og_site_name
  og_site_name = Gluttonberg::Setting.get_setting("title", current_site_config_name)
  return og_site_name if !og_site_name.blank?
  return nil
end

#og_titleObject

This returns page title (just text only). It checks for page/article/custom model for (:seo_title, :title, :name, :title_or_name?) methods It only returns page related information



26
27
28
29
30
# File 'app/helpers/gluttonberg/public/page_info.rb', line 26

def og_title
  og_title = _prepare_page_title
  return og_title if !og_title.blank?
  return nil
end

#og_typeObject



130
131
132
133
134
135
136
137
138
# File 'app/helpers/gluttonberg/public/page_info.rb', line 130

def og_type
  if !@page.blank? && @page.home == true
    'website'
  elsif !@blog.blank? && @article.blank?
    'blog'
  else
    'article'
  end
end

#page_descriptionObject

This returns page description if it exits (just text only). It checks for page/article/custom model for seo_description method otherwise it returns website description from settings



66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'app/helpers/gluttonberg/public/page_info.rb', line 66

def page_description
  object = find_current_object_for_meta_tags
  description_settings = Gluttonberg::Setting.get_setting("description", current_site_config_name)
  page_description = if !object.blank? && object.respond_to?(:seo_description)
    object.seo_description
  end

  if !page_description.blank?
    page_description
  else !description_settings.blank?
    description_settings
  end
end

#page_keywordsObject

This returns page keywords if it exits (just text only). It checks for page/article/custom model for seo_keywords method otherwise it returns website keywords from settings



83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'app/helpers/gluttonberg/public/page_info.rb', line 83

def page_keywords
  object = find_current_object_for_meta_tags
  keywords_settings = Gluttonberg::Setting.get_setting("keywords", current_site_config_name)
  page_keywords = if !object.blank? && object.respond_to?(:seo_keywords)
    object.seo_keywords
  end

  if !page_keywords.blank?
    page_keywords
  elsif !keywords_settings.blank?
    keywords_settings
  end
end

#page_titleObject

This returns page title (just text only). It checks for page/article/custom model for (:seo_title, :title, :name, :title_or_name?) methods it concats it with website title (if exists)



10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/helpers/gluttonberg/public/page_info.rb', line 10

def page_title
  title_setting = Gluttonberg::Setting.get_setting("title", current_site_config_name)
  page_title = _prepare_page_title

  if page_title.blank?
    title_setting
  elsif title_setting.blank?
    page_title
  else
    "#{page_title} | #{title_setting}"
  end
end