Class: Spotlight::PageConfigurations
- Inherits:
-
Object
- Object
- Spotlight::PageConfigurations
- Defined in:
- app/models/spotlight/page_configurations.rb
Overview
PageConfigurations is a simple class to gather and return all configurations needed for the various SirTrevor widgets. A downstream application (or gem) can inject its own data through the Spotlight’s engine config like so Spotlight::Engine.config.page_configurations =
'my-key': 'my_val'
You can also pass anything that responds to #call (eg. a lambda or custom ruby class) as the value and it will be evaluted within the PageConfiguration context (which has access to the view context). Spotlight::Engine.config.page_configurations = {
'exhibit-path': ->(context) { context.spotlight.exhibit_path(context.current_exhibit) }
}
Constant Summary collapse
- DOCUMENT_TITLE_KEY =
'__spotlight_document_title___'
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
Instance Method Summary collapse
- #as_json ⇒ Object
-
#initialize(context:, page:) ⇒ PageConfigurations
constructor
A new instance of PageConfigurations.
Constructor Details
#initialize(context:, page:) ⇒ PageConfigurations
Returns a new instance of PageConfigurations.
29 30 31 32 |
# File 'app/models/spotlight/page_configurations.rb', line 29 def initialize(context:, page:) @context = context @page = page end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
27 28 29 |
# File 'app/models/spotlight/page_configurations.rb', line 27 def context @context end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
27 28 29 |
# File 'app/models/spotlight/page_configurations.rb', line 27 def page @page end |
Instance Method Details
#as_json ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/models/spotlight/page_configurations.rb', line 34 def as_json(*) { 'blacklight-configuration-index-fields': , 'blacklight-configuration-search-views': available_view_configs, 'attachment-endpoint': , 'autocomplete-exhibit-catalog-path': exhibit_autocomplete_endpoint, 'autocomplete-exhibit-pages-path': page_autocomplete_endpoint, 'autocomplete-exhibit-browse-groups-path': browse_groups_autocomplete_endpoint, 'autocomplete-exhibit-searches-path': search_autocomplete_endpoint, 'preview-url': page_preview_url }.merge(downstream_parameters) end |