class Dbla::DocumentPresenter

Constants

DESCRIPTIVE_METADATA_KEY

Public Class Methods

new(document, controller, configuration = controller.blacklight_config) click to toggle source

@param [Item or Collection] document @param [ActionController::Base] controller scope for linking and generating urls @param [Blacklight::Configuration] configuration

# File lib/dbla/document_presenter.rb, line 12
def initialize(document, controller, configuration = controller.blacklight_config)
  @document = document
  @configuration = configuration
  @controller = controller
end

Public Instance Methods

document_heading() click to toggle source

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

@param [SolrDocument] document @return [String]

# File lib/dbla/document_presenter.rb, line 26
def document_heading
  source_resource_title
end
document_show_html_title() click to toggle source

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

@see document_heading @return [String]

# File lib/dbla/document_presenter.rb, line 35
def document_show_html_title
  source_resource_title
end
field_value_separator() click to toggle source

Default separator to use in render_field_value

@return [String]

# File lib/dbla/document_presenter.rb, line 104
def field_value_separator
  ', '
end
get_field_values(field, field_config, options = {}) click to toggle source

Get the value for a document’s field, and prepare to render it.

  • highlight_field

  • accessor

  • solr field

Rendering:

- helper_method
- link_to_search

TODO : maybe this should be merged with render_field_value, and the ugly signature simplified by pushing some of this logic into the “model” @param [SolrDocument] document @param [String] field name @param [Blacklight::Solr::Configuration::Field] solr field configuration @param [Hash] options additional options to pass to the rendering helpers

Calls superclass method
# File lib/dbla/document_presenter.rb, line 96
def get_field_values field, field_config, options = {}
    super
end
render_document_index_label(field, opts ={}) click to toggle source

Render the document index heading

@param [Hash] opts (Deprecated) @option opts [Symbol] :label Render the given field from the document @option opts [Proc] :label Evaluate the given proc @option opts [String] :label Render the given string @param [Symbol, Proc, String] field Render the given field or evaluate the proc or render the given string

Calls superclass method
# File lib/dbla/document_presenter.rb, line 55
def render_document_index_label field, opts ={}
  super
end
render_document_show_field_value(field, options={}) click to toggle source

Render the show field value for a document

Allow an extention point where information in the document
may drive the value of the field
@param [String] field
@param [Hash] options
@options opts [String] :value
Calls superclass method
# File lib/dbla/document_presenter.rb, line 77
def render_document_show_field_value field, options={}
    super
end
render_field_value(value=nil, field_config=nil) click to toggle source

Render a value (or array of values) from a field

@param [String] value or list of values to display @param [Blacklight::Solr::Configuration::Field] solr field configuration @return [String]

Calls superclass method
# File lib/dbla/document_presenter.rb, line 44
def render_field_value value=nil, field_config=nil
    super
end
render_index_field_value(field, options = {}) click to toggle source

Render the index field label for a document

Allow an extention point where information in the document
may drive the value of the field
@param [String] field
@param [Hash] opts
@options opts [String] :value
Calls superclass method
# File lib/dbla/document_presenter.rb, line 66
def render_index_field_value field, options = {}
    super
end
source_resource_title() click to toggle source
# File lib/dbla/document_presenter.rb, line 17
def source_resource_title
  @document[DESCRIPTIVE_METADATA_KEY] ? (@document[DESCRIPTIVE_METADATA_KEY]['title'] || @document['id']) : @document['id']
end