Module: Refinery::MetaHelper

Defined in:
core/app/helpers/refinery/meta_helper.rb

Instance Method Summary collapse

Instance Method Details

#browser_title(yield_title = nil) ⇒ Object

This is used to display the title of the current object (normally a page) in the browser's titlebar.



6
7
8
9
10
11
12
# File 'core/app/helpers/refinery/meta_helper.rb', line 6

def browser_title(yield_title = nil)
  [
    yield_title,
    @meta.browser_title.presence || @meta.path,
    Refinery::Core.site_name
  ].reject(&:blank?).join(" - ")
end

#canonical_id(page) ⇒ Object



51
52
53
# File 'core/app/helpers/refinery/meta_helper.rb', line 51

def canonical_id(page)
  "#{page.canonical_slug}-page" if page
end

#page_title(options = {}) ⇒ Object

you can override the object used for the title by supplying options



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'core/app/helpers/refinery/meta_helper.rb', line 15

def page_title(options = {})
  object = options.fetch(:object, @meta)
  options.delete(:object)
  options = Refinery::Pages.page_title.merge(options)

  title = []
  objects = (options[:chain_page_title] and object.respond_to?(:ancestors)) ? [object.ancestors, object] : [object]

  objects.flatten.compact.each do |obj|
    obj_title = obj.title if obj.title

    # Only link when the object responds to a url method.
    if options[:link] && obj.respond_to?(:url)
      title << link_to(obj_title, obj.url)
    else
      title << obj_title
    end
  end

  final_title = title.pop
  if (options[:page_title][:wrap_if_not_chained] and title.empty?) and options[:page_title][:tag].present?
    css = " class='#{options[:page_title][:class]}'" if options[:page_title][:class].present?
    final_title = "<#{options[:page_title][:tag]}#{css}>#{final_title}</#{options[:page_title][:tag]}>"
  end

  if title.empty?
    final_title.to_s.html_safe
  else
    tag = "<#{options[:ancestors][:tag]} class='#{options[:ancestors][:class]}'>"
    tag << title.join(options[:ancestors][:separator])
    tag << options[:ancestors][:separator]
    tag << "</#{options[:ancestors][:tag]}>#{final_title}"
    tag.html_safe
  end
end

#view_template_class(page) ⇒ Object



55
56
57
# File 'core/app/helpers/refinery/meta_helper.rb', line 55

def view_template_class(page)
  "template-#{page.view_template}" if page
end