Class: Dbla::DocumentPresenter
- Inherits:
-
Object
- Object
- Dbla::DocumentPresenter
- Extended by:
- Deprecation
- Includes:
- ActionView::Helpers::OutputSafetyHelper, ActionView::Helpers::TagHelper
- Defined in:
- lib/dbla/document_presenter.rb
Instance Method Summary collapse
-
#document_heading ⇒ String
Get the value of the document’s “title” field, or a placeholder value (if empty).
-
#document_show_html_title ⇒ String
Get the document’s “title” to display in the <title> element.
-
#field_value_separator ⇒ String
Default separator to use in #render_field_value.
-
#get_field_values(field, field_config, options = {}) ⇒ Object
Get the value for a document’s field, and prepare to render it.
-
#initialize(document, controller, configuration = controller.blacklight_config) ⇒ DocumentPresenter
constructor
A new instance of DocumentPresenter.
-
#render_document_index_label(field, opts = {}) ⇒ Object
Render the document index heading.
-
#render_document_show_field_value(field, options = {}) ⇒ Object
Render the show field value for a document.
-
#render_field_value(value = nil, field_config = nil) ⇒ String
Render a value (or array of values) from a field.
-
#render_index_field_value(field, options = {}) ⇒ Object
Render the index field label for a document.
Constructor Details
#initialize(document, controller, configuration = controller.blacklight_config) ⇒ DocumentPresenter
Returns a new instance of DocumentPresenter.
10 11 12 13 14 |
# File 'lib/dbla/document_presenter.rb', line 10 def initialize(document, controller, configuration = controller.blacklight_config) @document = document @configuration = configuration @controller = controller end |
Instance Method Details
#document_heading ⇒ String
Get the value of the document’s “title” field, or a placeholder value (if empty)
21 22 23 |
# File 'lib/dbla/document_presenter.rb', line 21 def document_heading @document['sourceResource']['title'] end |
#document_show_html_title ⇒ String
Get the document’s “title” to display in the <title> element. (by default, use the #document_heading)
30 31 32 |
# File 'lib/dbla/document_presenter.rb', line 30 def document_show_html_title @document['sourceResource']['title'] end |
#field_value_separator ⇒ String
Default separator to use in #render_field_value
103 104 105 |
# File 'lib/dbla/document_presenter.rb', line 103 def field_value_separator ', ' end |
#get_field_values(field, field_config, options = {}) ⇒ Object
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”
96 97 |
# File 'lib/dbla/document_presenter.rb', line 96 def get_field_values field, field_config, = {} end |
#render_document_index_label(field, opts = {}) ⇒ Object
Render the document index heading
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/dbla/document_presenter.rb', line 49 def render_document_index_label field, opts ={} if Symbol === field # these are shenanigans to find a nested field field.to_s.split('/').inject(@document) {|m,v| m[v]} elsif Proc === field field.call else field end end |
#render_document_show_field_value(field, 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
@param [String] field
@param [Hash] options
@options opts [String] :value
78 79 |
# File 'lib/dbla/document_presenter.rb', line 78 def render_document_show_field_value field, ={} end |
#render_field_value(value = nil, field_config = nil) ⇒ String
Render a value (or array of values) from a field
39 40 |
# File 'lib/dbla/document_presenter.rb', line 39 def render_field_value value=nil, field_config=nil end |
#render_index_field_value(field, options = {}) ⇒ Object
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
67 68 69 |
# File 'lib/dbla/document_presenter.rb', line 67 def render_index_field_value field, = {} end |