Class: Hyrax::PageTitleDecorator
- Inherits:
-
Draper::Decorator
- Object
- Draper::Decorator
- Hyrax::PageTitleDecorator
- Defined in:
- app/presenters/hyrax/page_title_decorator.rb
Overview
Decorates Work-like objects with a ‘#title` and `#page_title` for display.
Instance Method Summary collapse
-
#page_title ⇒ String
A title for pages about this object.
-
#title ⇒ String
overlays the ‘#title` of the object, making an effort to guarantee a reasonable title is found.
Instance Method Details
#page_title ⇒ String
Returns a title for pages about this object.
24 25 26 27 28 |
# File 'app/presenters/hyrax/page_title_decorator.rb', line 24 def page_title result = "#{object.human_readable_type} [#{object.to_param}] // #{h.application_name}" result = title + ' // ' + result if object.persisted? result end |
#title ⇒ String
overlays the ‘#title` of the object, making an effort to guarantee a reasonable title is found. if one isn’t found, it uses an i18n key to produce a generic ‘No Title’ string.
13 14 15 16 17 18 19 20 |
# File 'app/presenters/hyrax/page_title_decorator.rb', line 13 def title title = Array(object.try(:title)).join(' | ') return title if title.present? label = Array(object.try(:label)).join(' | ') return label if label.present? h.t('hyrax.works.missing_title') end |