Class: Hyrax::PageTitleDecorator

Inherits:
Draper::Decorator
  • Object
show all
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

Instance Method Details

#page_titleString

Returns a title for pages about this object.

Returns:

  • (String)

    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

#titleString

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.

Returns:

  • (String)

    a displayable title for this object



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