Class: Blacklight::ShowPresenter

Inherits:
Object
  • Object
show all
Extended by:
Deprecation
Defined in:
app/presenters/blacklight/show_presenter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(document, view_context, configuration = view_context.blacklight_config) ⇒ ShowPresenter

Returns a new instance of ShowPresenter.

Parameters:

  • document (SolrDocument)
  • view_context (ActionView::Base)

    scope for linking and generating urls

  • configuration (Blacklight::Configuration) (defaults to: view_context.blacklight_config)


12
13
14
15
16
# File 'app/presenters/blacklight/show_presenter.rb', line 12

def initialize(document, view_context, configuration = view_context.blacklight_config)
  @document = document
  @view_context = view_context
  @configuration = configuration
end

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration.



7
8
9
# File 'app/presenters/blacklight/show_presenter.rb', line 7

def configuration
  @configuration
end

#documentObject (readonly)

Returns the value of attribute document.



7
8
9
# File 'app/presenters/blacklight/show_presenter.rb', line 7

def document
  @document
end

#view_contextObject (readonly)

Returns the value of attribute view_context.



7
8
9
# File 'app/presenters/blacklight/show_presenter.rb', line 7

def view_context
  @view_context
end

Instance Method Details

#document_headingObject

Deprecated.


67
68
69
# File 'app/presenters/blacklight/show_presenter.rb', line 67

def document_heading
  heading
end

#document_show_html_titleObject

Deprecated.


49
50
51
# File 'app/presenters/blacklight/show_presenter.rb', line 49

def document_show_html_title
  html_title
end

#field_value(field_or_name, options = {}) ⇒ Object

Render the show field value for a document

Allow an extention point where information in the document may drive the value of the field

Parameters:

Options Hash (options):

  • :value (String)


80
81
82
83
84
85
86
87
88
89
90
91
# File 'app/presenters/blacklight/show_presenter.rb', line 80

def field_value field_or_name, options={}
  field = case field_or_name
          when String
            Deprecation.warn(self, "You provided a String value to ShowPresenter#field_value " \
            "Provide a Blacklight::Configuration::Field instead. field_value() will not accept " \
            "strings in Blacklight 7")
            field_config(field_or_name)
          else
            field_or_name
          end
  field_values(field_config(field), options)
end

#get_field_values(field_config, options = {}) ⇒ Object

Deprecated.


100
101
102
# File 'app/presenters/blacklight/show_presenter.rb', line 100

def get_field_values(field_config, options={})
  field_values(field_config, options)
end

#headingString

Get the value of the document's “title” field, or a placeholder value (if empty)

Returns:

  • (String)


59
60
61
62
63
64
# File 'app/presenters/blacklight/show_presenter.rb', line 59

def heading
  fields = Array.wrap(view_config.title_field)
  f = fields.detect { |field| document.has? field }
  f ||= configuration.document_model.unique_key
  field_values(field_config(f), value: document[f])
end

#html_titleString

Get the document's “title” to display in the <title> element. (by default, use the #document_heading)

Returns:

  • (String)

See Also:



37
38
39
40
41
42
43
44
45
46
# File 'app/presenters/blacklight/show_presenter.rb', line 37

def html_title
  if view_config.html_title_field
    fields = Array.wrap(view_config.html_title_field)
    f = fields.detect { |field| document.has? field }
    f ||= 'id'
    field_values(field_config(f))
  else
    heading
  end
end
Deprecated.

moved to ShowPresenter#link_rel_alternates

Create <link rel=“alternate”> links from a documents dynamically provided export formats. Returns empty string if no links available.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :unique (Boolean)

    ensures only one link is output for every content type, e.g. as required by atom

  • :exclude (Array<String>)

    array of format shortnames to not include in the output



27
28
29
# File 'app/presenters/blacklight/show_presenter.rb', line 27

def link_rel_alternates(options = {})
  LinkAlternatePresenter.new(view_context, document, options).render
end

#render_document_show_field_value(*args) ⇒ Object

Deprecated.


94
95
96
# File 'app/presenters/blacklight/show_presenter.rb', line 94

def render_document_show_field_value(*args)
  field_value(*args)
end

#render_field_values(values, field_config = Configuration::NullField.new) ⇒ Object

Deprecated.


106
107
108
# File 'app/presenters/blacklight/show_presenter.rb', line 106

def render_field_values(values, field_config = Configuration::NullField.new)
  field_values(field_config, value: Array(values))
end

#render_values(values, field_config = Configuration::NullField.new) ⇒ Object

Deprecated.


112
113
114
# File 'app/presenters/blacklight/show_presenter.rb', line 112

def render_values(values, field_config = Configuration::NullField.new)
  field_values(field_config, value: Array(values))
end