Class: Blacklight::Configuration
- Inherits:
-
OpenStructWithHashAccess
- Object
- OpenStruct
- OpenStructWithHashAccess
- Blacklight::Configuration
- Extended by:
- ActiveSupport::Autoload
- Includes:
- Fields
- Defined in:
- lib/blacklight/configuration.rb,
lib/blacklight/configuration/fields.rb,
lib/blacklight/configuration/context.rb,
lib/blacklight/configuration/view_config.rb
Overview
Blacklight::Configuration holds the configuration for a Blacklight::Controller, including fields to display, facets to show, sort options, and search fields.
Defined Under Namespace
Modules: Fields Classes: Context, DisplayField, FacetField, Field, IndexField, NullField, SearchField, ShowField, SortField, ToolConfig, ViewConfig
Constant Summary collapse
- BASIC_SEARCH_PARAMETERS =
[:q, :qt, :page, :per_page, :search_field, :sort, :controller, :action, :'facet.page', :'facet.prefix', :'facet.sort', :rows, :format, :view].freeze
- ADVANCED_SEARCH_PARAMETERS =
[{ clause: {} }, :op].freeze
Instance Attribute Summary collapse
- #action_mapping ⇒ Hash{Symbol => Blacklight::Configuration::ViewConfig}
- #advanced_search ⇒ #enabled
- #autocomplete_suggester ⇒ String
-
#connection_config ⇒ Class
repository connection configuration.
-
#crawler_detector ⇒ <nil, Proc>
proc for determining whether the session is a crawler/bot ex.: crawler_detector: lambda { |req| req.env =~ /bot/ }.
-
#default_document_solr_params ⇒ Hash
Default values of parameters to send with every single-document request.
- #default_facet_limit ⇒ Integer
- #default_more_limit ⇒ Integer
- #default_per_page ⇒ Integer
-
#default_solr_params ⇒ Hash
Default values of parameters to send with every search request.
-
#document_factory ⇒ Object
A class that builds documents.
-
#document_model ⇒ Class
the model to use for each response document.
-
#document_pagination_params ⇒ Hash
Default values of parameters to send when getting the previous + next documents.
-
#document_solr_path ⇒ String
The url path (relative to the solr base url) to use when requesting only a single document.
-
#document_solr_request_handler ⇒ String
The solr request handler to use when requesting only a single document.
-
#document_unique_id_param ⇒ Symbol
The solr query parameter used for sending the unique identifiers for one or more documents.
- #email ⇒ Blacklight::Configuration::ViewConfig
- #email_fields ⇒ Hash{Symbol=>Blacklight::Configuration::DisplayField}
- #enable_search_bar_autofocus ⇒ Boolean
- #facet_fields ⇒ Hash{Symbol=>Blacklight::Configuration::FacetField}
-
#facet_paginator_class ⇒ Class
Class for paginating long lists of facet fields.
-
#fetch_many_document_params ⇒ Hash
Default values of parameters to send with every multi-document request.
-
#filter_search_state_fields ⇒ Boolean
Have SearchState filter out unknown request parameters.
-
#http_method ⇒ :get, :post
HTTP method used for search.
-
#index ⇒ Blacklight::Configuration::ViewConfig::Index
General configuration for all views.
- #index_fields ⇒ Hash{Symbol=>Blacklight::Configuration::IndexField}
-
#max_per_page ⇒ Integer
Maximum number of results to show per page.
- #navbar ⇒ #partials
-
#per_page ⇒ Array<Integer>
Options for the user for number of results to show per page.
- #raw_endpoint ⇒ #enabled
-
#repository_class ⇒ Class
Class for sending and receiving requests from a search index.
-
#response_model ⇒ Class
model that maps index responses to the blacklight response model.
-
#search_builder_class ⇒ Class
Class for converting Blacklight parameters to request parameters for the repository_class.
- #search_fields ⇒ Hash{Symbol=>Blacklight::Configuration::SearchField}
-
#search_history_window ⇒ Integer
how many searches to save in session history.
-
#search_state_fields ⇒ Array<Symbol>
List the request parameters that compose the SearchState.
-
#show ⇒ Blacklight::Configuration::ViewConfig::Show
Additional configuration when displaying a single document.
- #show_fields ⇒ Hash{Symbol=>Blacklight::Configuration::ShowField}
- #sms ⇒ Blacklight::Configuration::ViewConfig
- #sms_fields ⇒ Hash{Symbol=>Blacklight::Configuration::DisplayField}
-
#solr_path ⇒ String
The path to send requests to solr.
- #sort_fields ⇒ Hash{Symbol=>Blacklight::Configuration::SortField}
-
#spell_max ⇒ Integer
Maxiumum number of spelling suggestions to offer.
- #track_search_session ⇒ Boolean
-
#view ⇒ Hash{Symbol => Blacklight::Configuration::ViewConfig}
Configurations for specific types of index views.
Class Method Summary collapse
Instance Method Summary collapse
- #add_email_field(config_key, hash_or_field_or_array) ⇒ Blacklight::Configuration::DisplayField
- #add_facet_field(config_key, hash_or_field_or_array) ⇒ Blacklight::Configuration::FacetField
-
#add_facet_fields_to_solr_request!(*fields) ⇒ Object
Add any configured facet fields to the default solr parameters hash.
-
#add_field_configuration_to_solr_request!(*fields) ⇒ Object
Add any configured facet fields to the default solr parameters hash.
- #add_index_field(config_key, hash_or_field_or_array) ⇒ Blacklight::Configuration::IndexField
-
#add_nav_action(name, opts = {}) ⇒ Object
Add a partial to the header navbar.
-
#add_results_collection_tool(name, opts = {}) ⇒ Object
Add a tool for the search result list itself.
-
#add_results_document_tool(name, opts = {}) ⇒ Object
Add a partial to the tools for each document in the search results.
- #add_search_field(config_key, hash_or_field_or_array) ⇒ Blacklight::Configuration::SearchField
- #add_show_field(config_key, hash_or_field_or_array) ⇒ Blacklight::Configuration::ShowField
-
#add_show_tools_partial(name, opts = {}) ⇒ Object
Add a partial to the tools when rendering a document.
- #add_sms_field(config_key, hash_or_field_or_array) ⇒ Blacklight::Configuration::DisplayField
- #add_sort_field(config_key, hash_or_field_or_array) ⇒ Blacklight::Configuration::SortField
-
#build(klass) ⇒ Object
(also: #inheritable_copy)
builds a copy for the provided controller class.
-
#configure {|config| ... } ⇒ Blacklight::Configuration
DSL helper.
-
#deep_copy ⇒ Object
Provide a 'deep copy' of Blacklight::Configuration that can be modified without effecting the original Blacklight::Configuration instance.
-
#default_search_field ⇒ Blacklight::Configuration::SearchField
Returns default search field, used for simpler display in history, etc.
-
#default_sort_field ⇒ Blacklight::Configuration::SortField
Returns default sort field, used for simpler display in history, etc.
- #default_title_field ⇒ String
-
#facet_configuration_for_field(field) ⇒ Blacklight::Configuration::FacetField
Blacklight facet configuration for the solr field.
-
#facet_field_names(group = nil) ⇒ Array<String>
A list of the facet field names from the configuration.
-
#facet_fields_in_group(group) ⇒ Array<Blacklight::Configuration::FacetField>
A list of facet fields.
-
#facet_group_names ⇒ Array<String>
A list of facet groups.
-
#for_display_type(display_type, &_block) ⇒ Object
Add a section of config that only applies to documents with a matching display type.
-
#index_fields_for(document_or_display_types) ⇒ Object
Return a list of fields for the index display that should be used for the provided document.
-
#initialize(hash = {}) {|_self| ... } ⇒ Configuration
constructor
A new instance of Configuration.
- #locate_search_builder_class ⇒ Object
- #repository ⇒ Blacklight::Repository
-
#show_fields_for(document_or_display_types) ⇒ Object
Return a list of fields for the show page that should be used for the provided document.
-
#view_config(view_type = nil, action_name: :index) ⇒ Blacklight::Configuration::ViewConfig
Get a view configuration for the given view type + action.
Methods included from Fields
Methods inherited from OpenStructWithHashAccess
#deep_dup, #merge, #merge!, #reverse_merge, #select, #sort_by, #sort_by!, #to_h, #try
Constructor Details
#initialize(hash = {}) {|_self| ... } ⇒ Configuration
Returns a new instance of Configuration.
359 360 361 362 363 364 |
# File 'lib/blacklight/configuration.rb', line 359 def initialize(hash = {}) super(self.class.default_values.deep_dup.merge(hash)) yield(self) if block_given? @view_config ||= {} end |
Instance Attribute Details
#action_mapping ⇒ Hash{Symbol => Blacklight::Configuration::ViewConfig}
197 198 199 200 201 202 |
# File 'lib/blacklight/configuration.rb', line 197 property :action_mapping, default: NestedOpenStructWithHashAccess.new( ViewConfig, default: { top_level_config: :index }, show: { top_level_config: :show }, citation: { parent_config: :show } ) |
#advanced_search ⇒ #enabled
291 |
# File 'lib/blacklight/configuration.rb', line 291 property :advanced_search, default: OpenStruct.new(enabled: false) |
#autocomplete_suggester ⇒ String
276 |
# File 'lib/blacklight/configuration.rb', line 276 property :autocomplete_suggester, default: 'mySuggester' |
#connection_config ⇒ Class
repository connection configuration
136 |
# File 'lib/blacklight/configuration.rb', line 136 property :connection_config, default: nil |
#crawler_detector ⇒ <nil, Proc>
proc for determining whether the session is a crawler/bot ex.: crawler_detector: lambda { |req| req.env =~ /bot/ }
271 |
# File 'lib/blacklight/configuration.rb', line 271 property :crawler_detector, default: nil |
#default_document_solr_params ⇒ Hash
Returns Default values of parameters to send with every single-document request.
61 |
# File 'lib/blacklight/configuration.rb', line 61 property :default_document_solr_params, default: {} |
#default_facet_limit ⇒ Integer
260 |
# File 'lib/blacklight/configuration.rb', line 260 property :default_facet_limit, default: 10 |
#default_more_limit ⇒ Integer
264 |
# File 'lib/blacklight/configuration.rb', line 264 property :default_more_limit, default: 20 |
#default_per_page ⇒ Integer
247 |
# File 'lib/blacklight/configuration.rb', line 247 property :default_per_page, default: nil |
#default_solr_params ⇒ Hash
Returns Default values of parameters to send with every search request.
44 |
# File 'lib/blacklight/configuration.rb', line 44 property :default_solr_params, default: {} |
#document_factory ⇒ Object
A class that builds documents
106 |
# File 'lib/blacklight/configuration.rb', line 106 property :document_factory, default: nil |
#document_model ⇒ Class
the model to use for each response document
114 |
# File 'lib/blacklight/configuration.rb', line 114 property :document_model, default: nil |
#document_pagination_params ⇒ Hash
Returns Default values of parameters to send when getting the previous + next documents.
68 |
# File 'lib/blacklight/configuration.rb', line 68 property :document_pagination_params, default: {} |
#document_solr_path ⇒ String
Returns The url path (relative to the solr base url) to use when requesting only a single document.
54 |
# File 'lib/blacklight/configuration.rb', line 54 property :document_solr_path, default: 'get' |
#document_solr_request_handler ⇒ String
Returns The solr request handler to use when requesting only a single document.
50 |
# File 'lib/blacklight/configuration.rb', line 50 property :document_solr_request_handler, default: nil |
#document_unique_id_param ⇒ Symbol
Returns The solr query parameter used for sending the unique identifiers for one or more documents.
58 |
# File 'lib/blacklight/configuration.rb', line 58 property :document_unique_id_param, default: :ids |
#email ⇒ Blacklight::Configuration::ViewConfig
212 |
# File 'lib/blacklight/configuration.rb', line 212 property :email, default: ViewConfig.new |
#email_fields ⇒ Hash{Symbol=>Blacklight::Configuration::DisplayField}
357 |
# File 'lib/blacklight/configuration.rb', line 357 define_field_access :email_field, Blacklight::Configuration::DisplayField |
#enable_search_bar_autofocus ⇒ Boolean
296 |
# File 'lib/blacklight/configuration.rb', line 296 property :enable_search_bar_autofocus, default: false |
#facet_fields ⇒ Hash{Symbol=>Blacklight::Configuration::FacetField}
339 |
# File 'lib/blacklight/configuration.rb', line 339 define_field_access :facet_field, Blacklight::Configuration::FacetField |
#facet_paginator_class ⇒ Class
Class for paginating long lists of facet fields
127 |
# File 'lib/blacklight/configuration.rb', line 127 property :facet_paginator_class, default: nil |
#fetch_many_document_params ⇒ Hash
Returns Default values of parameters to send with every multi-document request.
65 |
# File 'lib/blacklight/configuration.rb', line 65 property :fetch_many_document_params, default: {} |
#filter_search_state_fields ⇒ Boolean
Have SearchState filter out unknown request parameters
313 |
# File 'lib/blacklight/configuration.rb', line 313 property :filter_search_state_fields, default: false |
#http_method ⇒ :get, :post
Returns HTTP method used for search.
38 |
# File 'lib/blacklight/configuration.rb', line 38 property :http_method, default: :get |
#index ⇒ Blacklight::Configuration::ViewConfig::Index
General configuration for all views
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/blacklight/configuration.rb', line 152 property :index, default: ViewConfig::Index.new( # document presenter class used by helpers and views document_presenter_class: nil, # component class used to render a document document_component: nil, # solr field to use to render a document title title_field: nil, # solr field to use to render format-specific partials display_type_field: nil, # partials to render for each document(see #render_document_partials) partials: [:index_header, :thumbnail, :index], document_actions: NestedOpenStructWithHashAccess.new(ToolConfig), collection_actions: NestedOpenStructWithHashAccess.new(ToolConfig), # what field, if any, to use to render grouped results group: false, # additional response formats for search results respond_to: OpenStructWithHashAccess.new, # component class used to render the facet grouping facet_group_component: nil, # component class used to render search constraints constraints_component: nil, # component class used to render the search bar search_bar_component: nil ) |
#index_fields ⇒ Hash{Symbol=>Blacklight::Configuration::IndexField}
342 |
# File 'lib/blacklight/configuration.rb', line 342 define_field_access :index_field, Blacklight::Configuration::IndexField |
#max_per_page ⇒ Integer
Maximum number of results to show per page
240 |
# File 'lib/blacklight/configuration.rb', line 240 property :max_per_page, default: 100 |
#navbar ⇒ #partials
147 |
# File 'lib/blacklight/configuration.rb', line 147 property :navbar, default: OpenStructWithHashAccess.new(partials: {}) |
#per_page ⇒ Array<Integer>
Options for the user for number of results to show per page
244 |
# File 'lib/blacklight/configuration.rb', line 244 property :per_page, default: [10, 20, 50, 100] |
#raw_endpoint ⇒ #enabled
281 |
# File 'lib/blacklight/configuration.rb', line 281 property :raw_endpoint, default: OpenStructWithHashAccess.new(enabled: false) |
#repository_class ⇒ Class
Returns Class for sending and receiving requests from a search index.
75 |
# File 'lib/blacklight/configuration.rb', line 75 property :repository_class, default: nil |
#response_model ⇒ Class
model that maps index responses to the blacklight response model
94 |
# File 'lib/blacklight/configuration.rb', line 94 property :response_model, default: nil |
#search_builder_class ⇒ Class
Returns class for converting Blacklight parameters to request parameters for the repository_class.
82 |
# File 'lib/blacklight/configuration.rb', line 82 property :search_builder_class, default: nil |
#search_fields ⇒ Hash{Symbol=>Blacklight::Configuration::SearchField}
348 |
# File 'lib/blacklight/configuration.rb', line 348 define_field_access :search_field, Blacklight::Configuration::SearchField |
#search_history_window ⇒ Integer
how many searches to save in session history
256 |
# File 'lib/blacklight/configuration.rb', line 256 property :search_history_window, default: 100 |
#search_state_fields ⇒ Array<Symbol>
List the request parameters that compose the SearchState. If you use a plugin that adds to the search state, then you can add the parameters by modifiying this field.
306 |
# File 'lib/blacklight/configuration.rb', line 306 property :search_state_fields, default: BASIC_SEARCH_PARAMETERS + ADVANCED_SEARCH_PARAMETERS |
#show ⇒ Blacklight::Configuration::ViewConfig::Show
Additional configuration when displaying a single document
180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/blacklight/configuration.rb', line 180 property :show, default: ViewConfig::Show.new( # document presenter class used by helpers and views document_presenter_class: nil, document_component: nil, display_type_field: nil, # Default route parameters for 'show' requests. # Set this to a hash with additional arguments to merge into the route, # or set `controller: :current` to route to the current controller. route: nil, # partials to render for each document(see #render_document_partials) partials: [:show_header, :show], document_actions: NestedOpenStructWithHashAccess.new(ToolConfig) ) |
#show_fields ⇒ Hash{Symbol=>Blacklight::Configuration::ShowField}
345 |
# File 'lib/blacklight/configuration.rb', line 345 define_field_access :show_field, Blacklight::Configuration::ShowField |
#sms ⇒ Blacklight::Configuration::ViewConfig
207 |
# File 'lib/blacklight/configuration.rb', line 207 property :sms, default: ViewConfig.new |
#sms_fields ⇒ Hash{Symbol=>Blacklight::Configuration::DisplayField}
354 |
# File 'lib/blacklight/configuration.rb', line 354 define_field_access :sms_field, Blacklight::Configuration::DisplayField |
#solr_path ⇒ String
Returns The path to send requests to solr.
41 |
# File 'lib/blacklight/configuration.rb', line 41 property :solr_path, default: 'select' |
#sort_fields ⇒ Hash{Symbol=>Blacklight::Configuration::SortField}
351 |
# File 'lib/blacklight/configuration.rb', line 351 define_field_access :sort_field, Blacklight::Configuration::SortField |
#spell_max ⇒ Integer
Maxiumum number of spelling suggestions to offer
235 |
# File 'lib/blacklight/configuration.rb', line 235 property :spell_max, default: 5 |
#track_search_session ⇒ Boolean
286 |
# File 'lib/blacklight/configuration.rb', line 286 property :track_search_session, default: true |
#view ⇒ Hash{Symbol => Blacklight::Configuration::ViewConfig}
Configurations for specific types of index views
217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/blacklight/configuration.rb', line 217 property :view, default: NestedOpenStructWithHashAccess.new(ViewConfig, list: {}, atom: { if: false, # by default, atom should not show up as an alternative view partials: [:document], summary_partials: [:index] }, rss: { if: false, # by default, rss should not show up as an alternative view partials: [:document] }) |
Class Method Details
.default_values ⇒ Object
29 30 31 |
# File 'lib/blacklight/configuration.rb', line 29 def default_values @default_values ||= {} end |
.property(key, default: nil) ⇒ Object
25 26 27 |
# File 'lib/blacklight/configuration.rb', line 25 def property(key, default: nil) default_values[key] = default end |
Instance Method Details
#add_email_field(config_key, options) ⇒ Blacklight::Configuration::DisplayField #add_email_field(config_key, field) ⇒ Blacklight::Configuration::DisplayField #add_email_field(config_key, array) ⇒ Blacklight::Configuration::DisplayField
357 |
# File 'lib/blacklight/configuration.rb', line 357 define_field_access :email_field, Blacklight::Configuration::DisplayField |
#add_facet_field(config_key, options) ⇒ Blacklight::Configuration::FacetField #add_facet_field(config_key, field) ⇒ Blacklight::Configuration::FacetField #add_facet_field(config_key, array) ⇒ Blacklight::Configuration::FacetField
339 |
# File 'lib/blacklight/configuration.rb', line 339 define_field_access :facet_field, Blacklight::Configuration::FacetField |
#add_facet_fields_to_solr_request! ⇒ Object #add_facet_fields_to_solr_request!(field, field, etc) ⇒ Object
Add any configured facet fields to the default solr parameters hash
434 435 436 437 438 439 440 |
# File 'lib/blacklight/configuration.rb', line 434 def add_facet_fields_to_solr_request!(*fields) if fields.empty? self.add_facet_fields_to_solr_request = true else facet_fields.slice(*fields).each_value { |v| v.include_in_request = true } end end |
#add_field_configuration_to_solr_request! ⇒ Object #add_field_configuration_to_solr_request!(field, field, etc) ⇒ Object
Add any configured facet fields to the default solr parameters hash
447 448 449 450 451 452 453 454 455 |
# File 'lib/blacklight/configuration.rb', line 447 def add_field_configuration_to_solr_request!(*fields) if fields.empty? self.add_field_configuration_to_solr_request = true else index_fields.slice(*fields).each_value { |v| v.include_in_request = true } show_fields.slice(*fields).each_value { |v| v.include_in_request = true } facet_fields.slice(*fields).each_value { |v| v.include_in_request = true } end end |
#add_index_field(config_key, options) ⇒ Blacklight::Configuration::IndexField #add_index_field(config_key, field) ⇒ Blacklight::Configuration::IndexField #add_index_field(config_key, array) ⇒ Blacklight::Configuration::IndexField
342 |
# File 'lib/blacklight/configuration.rb', line 342 define_field_access :index_field, Blacklight::Configuration::IndexField |
#add_nav_action(name, opts = {}) ⇒ Object
Add a partial to the header navbar
535 536 537 |
# File 'lib/blacklight/configuration.rb', line 535 def add_nav_action(name, opts = {}) add_action(.partials, name, opts) end |
#add_results_collection_tool(name, opts = {}) ⇒ Object
Add a tool for the search result list itself
523 524 525 |
# File 'lib/blacklight/configuration.rb', line 523 def add_results_collection_tool(name, opts = {}) add_action(index.collection_actions, name, opts) end |
#add_results_document_tool(name, opts = {}) ⇒ Object
Add a partial to the tools for each document in the search results.
529 530 531 |
# File 'lib/blacklight/configuration.rb', line 529 def add_results_document_tool(name, opts = {}) add_action(index.document_actions, name, opts) end |
#add_search_field(config_key, options) ⇒ Blacklight::Configuration::SearchField #add_search_field(config_key, field) ⇒ Blacklight::Configuration::SearchField #add_search_field(config_key, array) ⇒ Blacklight::Configuration::SearchField
348 |
# File 'lib/blacklight/configuration.rb', line 348 define_field_access :search_field, Blacklight::Configuration::SearchField |
#add_show_field(config_key, options) ⇒ Blacklight::Configuration::ShowField #add_show_field(config_key, field) ⇒ Blacklight::Configuration::ShowField #add_show_field(config_key, array) ⇒ Blacklight::Configuration::ShowField
345 |
# File 'lib/blacklight/configuration.rb', line 345 define_field_access :show_field, Blacklight::Configuration::ShowField |
#add_show_tools_partial(name, opts = {}) ⇒ Object
Add a partial to the tools when rendering a document.
514 515 516 517 518 |
# File 'lib/blacklight/configuration.rb', line 514 def add_show_tools_partial(name, opts = {}) opts[:partial] ||= 'document_action' add_action(show.document_actions, name, opts) klass && ActionBuilder.new(klass, name, opts).build end |
#add_sms_field(config_key, options) ⇒ Blacklight::Configuration::DisplayField #add_sms_field(config_key, field) ⇒ Blacklight::Configuration::DisplayField #add_sms_field(config_key, array) ⇒ Blacklight::Configuration::DisplayField
354 |
# File 'lib/blacklight/configuration.rb', line 354 define_field_access :sms_field, Blacklight::Configuration::DisplayField |
#add_sort_field(config_key, options) ⇒ Blacklight::Configuration::SortField #add_sort_field(config_key, field) ⇒ Blacklight::Configuration::SortField #add_sort_field(config_key, array) ⇒ Blacklight::Configuration::SortField
351 |
# File 'lib/blacklight/configuration.rb', line 351 define_field_access :sort_field, Blacklight::Configuration::SortField |
#build(klass) ⇒ Object Also known as: inheritable_copy
builds a copy for the provided controller class
468 469 470 471 472 |
# File 'lib/blacklight/configuration.rb', line 468 def build(klass) deep_copy.tap do |conf| conf.klass = klass end end |
#configure {|config| ... } ⇒ Blacklight::Configuration
DSL helper
375 376 377 378 |
# File 'lib/blacklight/configuration.rb', line 375 def configure yield self if block_given? self end |
#deep_copy ⇒ Object
Provide a 'deep copy' of Blacklight::Configuration that can be modified without effecting the original Blacklight::Configuration instance.
Note: Rails provides `#deep_dup`, but it aggressively `#dup`'s class names too, turning them into anonymous class instances.
462 463 464 |
# File 'lib/blacklight/configuration.rb', line 462 def deep_copy deep_transform_values_in_object(self, &method(:_deep_copy)) end |
#default_search_field ⇒ Blacklight::Configuration::SearchField
Returns default search field, used for simpler display in history, etc. if not set, defaults to first defined search field
383 384 385 386 |
# File 'lib/blacklight/configuration.rb', line 383 def default_search_field field = super || search_fields.values.find { |f| f.default == true } field || search_fields.values.first end |
#default_sort_field ⇒ Blacklight::Configuration::SortField
Returns default sort field, used for simpler display in history, etc. if not set, defaults to first defined sort field
391 392 393 394 |
# File 'lib/blacklight/configuration.rb', line 391 def default_sort_field field = super || sort_fields.values.find { |f| f.default == true } field || sort_fields.values.first end |
#default_title_field ⇒ String
397 398 399 |
# File 'lib/blacklight/configuration.rb', line 397 def default_title_field document_model.unique_key || 'id' end |
#facet_configuration_for_field(field) ⇒ Blacklight::Configuration::FacetField
Returns Blacklight facet configuration for the solr field.
403 404 405 406 407 408 409 410 |
# File 'lib/blacklight/configuration.rb', line 403 def facet_configuration_for_field(field) # short-circuit on the common case, where the solr field name and the blacklight field name are the same. return facet_fields[field] if facet_fields[field] && facet_fields[field].field == field # Find the facet field configuration for the solr field, or provide a default. facet_fields.values.find { |v| v.field.to_s == field.to_s } || FacetField.new(field: field).normalize! end |
#facet_field_names(group = nil) ⇒ Array<String>
Returns a list of the facet field names from the configuration.
414 415 416 |
# File 'lib/blacklight/configuration.rb', line 414 def facet_field_names(group = nil) facet_fields_in_group(group).map(&:field) end |
#facet_fields_in_group(group) ⇒ Array<Blacklight::Configuration::FacetField>
Returns a list of facet fields.
420 421 422 |
# File 'lib/blacklight/configuration.rb', line 420 def facet_fields_in_group(group) facet_fields.values.select { |opts| group == opts[:group] } end |
#facet_group_names ⇒ Array<String>
Returns a list of facet groups.
425 426 427 |
# File 'lib/blacklight/configuration.rb', line 425 def facet_group_names facet_fields.map { |_facet, opts| opts[:group] }.uniq end |
#for_display_type(display_type, &_block) ⇒ Object
Add a section of config that only applies to documents with a matching display type
541 542 543 544 545 546 547 |
# File 'lib/blacklight/configuration.rb', line 541 def for_display_type display_type, &_block self.fields_for_type ||= {} (fields_for_type[display_type] ||= self.class.new).tap do |conf| yield(conf) if block_given? end end |
#index_fields_for(document_or_display_types) ⇒ Object
Return a list of fields for the index display that should be used for the provided document. This respects any configuration made using for_display_type
552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 |
# File 'lib/blacklight/configuration.rb', line 552 def index_fields_for(document_or_display_types) display_types = if document_or_display_types.is_a? Blacklight::Document Deprecation.warn self, "Calling index_fields_for with a #{document_or_display_types.class} is deprecated and will be removed in Blacklight 8. Pass the display type instead." document_or_display_types[index.display_type_field || 'format'] else document_or_display_types end fields = {}.with_indifferent_access Array.wrap(display_types).each do |display_type| fields = fields.merge(for_display_type(display_type).index_fields) end fields.merge(index_fields) end |
#locate_search_builder_class ⇒ Object
87 88 89 |
# File 'lib/blacklight/configuration.rb', line 87 def locate_search_builder_class ::SearchBuilder end |
#repository ⇒ Blacklight::Repository
367 368 369 |
# File 'lib/blacklight/configuration.rb', line 367 def repository repository_class.new(self) end |
#show_fields_for(document_or_display_types) ⇒ Object
Return a list of fields for the show page that should be used for the provided document. This respects any configuration made using for_display_type
572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 |
# File 'lib/blacklight/configuration.rb', line 572 def show_fields_for(document_or_display_types) display_types = if document_or_display_types.is_a? Blacklight::Document Deprecation.warn self, "Calling show_fields_for with a #{document_or_display_types.class} is deprecated and will be removed in Blacklight 8. Pass the display type instead." document_or_display_types[show.display_type_field || 'format'] else document_or_display_types end fields = {}.with_indifferent_access Array.wrap(display_types).each do |display_type| fields = fields.merge(for_display_type(display_type).show_fields) end fields.merge(show_fields) end |
#view_config(view_type = nil, action_name: :index) ⇒ Blacklight::Configuration::ViewConfig
Get a view configuration for the given view type + action. The effective view configuration is inherited from:
-
the configuration from blacklight_config.view with the key `view_type`
-
the configuration from blacklight_config.action_mapping with the key `action_name`
-
any parent config for the action map result above
-
the action_mapping default configuration
-
the top-level index/show view configuration
485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 |
# File 'lib/blacklight/configuration.rb', line 485 def view_config(view_type = nil, action_name: :index) view_type &&= view_type.to_sym action_name &&= action_name.to_sym action_name ||= :index if view_type == :show action_name = view_type view_type = nil end @view_config[[view_type, action_name]] ||= begin if view_type.nil? action_config(action_name) else base_config = action_config(action_name) base_config.merge(view.fetch(view_type, {})) end end end |