Class: Blacklight::ShowPresenter
- Inherits:
-
Object
- Object
- Blacklight::ShowPresenter
- Extended by:
- Deprecation
- Defined in:
- app/presenters/blacklight/show_presenter.rb
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#view_context ⇒ Object
readonly
Returns the value of attribute view_context.
Instance Method Summary collapse
- #document_heading ⇒ Object deprecated Deprecated.
- #document_show_html_title ⇒ Object deprecated Deprecated.
-
#field_value(field_or_name, options = {}) ⇒ Object
Render the show field value for a document.
- #get_field_values(field_config, options = {}) ⇒ Object deprecated Deprecated.
-
#heading ⇒ String
Get the value of the document's “title” field, or a placeholder value (if empty).
-
#html_title ⇒ String
Get the document's “title” to display in the <title> element.
-
#initialize(document, view_context, configuration = view_context.blacklight_config) ⇒ ShowPresenter
constructor
A new instance of ShowPresenter.
-
#link_rel_alternates(options = {}) ⇒ Object
deprecated
Deprecated.
moved to ShowPresenter#link_rel_alternates
- #render_document_show_field_value(*args) ⇒ Object deprecated Deprecated.
- #render_field_values(values, field_config = Configuration::NullField.new) ⇒ Object deprecated Deprecated.
- #render_values(values, field_config = Configuration::NullField.new) ⇒ Object deprecated Deprecated.
Constructor Details
#initialize(document, view_context, configuration = view_context.blacklight_config) ⇒ ShowPresenter
Returns a new instance of ShowPresenter.
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
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
7 8 9 |
# File 'app/presenters/blacklight/show_presenter.rb', line 7 def configuration @configuration end |
#document ⇒ Object (readonly)
Returns the value of attribute document.
7 8 9 |
# File 'app/presenters/blacklight/show_presenter.rb', line 7 def document @document end |
#view_context ⇒ Object (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_heading ⇒ Object
67 68 69 |
# File 'app/presenters/blacklight/show_presenter.rb', line 67 def document_heading heading end |
#document_show_html_title ⇒ Object
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
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, ={} 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), ) end |
#get_field_values(field_config, options = {}) ⇒ Object
100 101 102 |
# File 'app/presenters/blacklight/show_presenter.rb', line 100 def get_field_values(field_config, ={}) field_values(field_config, ) end |
#heading ⇒ String
Get the value of the document's “title” field, or a placeholder value (if empty)
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_title ⇒ String
Get the document's “title” to display in the <title> element. (by default, use the #document_heading)
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 |
#link_rel_alternates(options = {}) ⇒ Object
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.
27 28 29 |
# File 'app/presenters/blacklight/show_presenter.rb', line 27 def link_rel_alternates( = {}) LinkAlternatePresenter.new(view_context, document, ).render end |
#render_document_show_field_value(*args) ⇒ Object
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
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
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 |