Module: Refinery::MetaHelper
- Defined in:
- app/helpers/refinery/meta_helper.rb
Instance Method Summary collapse
-
#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.
- #canonical_id(page) ⇒ Object
-
#page_title(options = {}) ⇒ Object
you can override the object used for the title by supplying options.
- #view_template_class(page) ⇒ Object
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 '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 '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 'app/helpers/refinery/meta_helper.rb', line 15 def page_title( = {}) object = .fetch(:object, @meta) .delete(:object) = Refinery::Pages.page_title.merge() title = [] objects = ([: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 [:link] && obj.respond_to?(:url) title << link_to(obj_title, obj.url) else title << obj_title end end final_title = title.pop if ([:page_title][:wrap_if_not_chained] and title.empty?) and [:page_title][:tag].present? css = " class='#{[:page_title][:class]}'" if [:page_title][:class].present? final_title = "<#{[:page_title][:tag]}#{css}>#{final_title}</#{[:page_title][:tag]}>" end if title.empty? final_title.to_s.html_safe else tag = "<#{[:ancestors][:tag]} class='#{[:ancestors][:class]}'>" tag << title.join([:ancestors][:separator]) tag << [:ancestors][:separator] tag << "</#{[:ancestors][:tag]}>#{final_title}" tag.html_safe end end |
#view_template_class(page) ⇒ Object
55 56 57 |
# File 'app/helpers/refinery/meta_helper.rb', line 55 def view_template_class(page) "template-#{page.view_template}" if page end |