Class: Spotlight::BlacklightConfiguration
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Spotlight::BlacklightConfiguration
- Includes:
- BlacklightConfigurationDefaults
- Defined in:
- app/models/spotlight/blacklight_configuration.rb
Instance Method Summary collapse
-
#blacklight_config ⇒ Object
Serialize this configuration to a Blacklight::Configuration object appropriate to the current view.
- #custom_index_fields ⇒ Object
-
#default_blacklight_config ⇒ Object
Get the “upstream” blacklight configuration to use.
Instance Method Details
#blacklight_config ⇒ Object
Serialize this configuration to a Blacklight::Configuration object appropriate to the current view. If a value isn’t set in this record, it will use the configuration set upstream (in default_blacklight_config)
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'app/models/spotlight/blacklight_configuration.rb', line 54 def blacklight_config @blacklight_config ||= begin # Create a new config based on the defaults config = default_blacklight_config.inheritable_copy config.show.merge! show unless show.blank? config.index.merge! index unless index.blank? unless exhibit.searchable? config..partials[:saved_searches].if = false config..partials[:search_history].if = false end config.default_autocomplete_solr_params[:fl] ||= "#{config.solr_document_model.unique_key} #{config.view_config(:show).title_field} #{config.view_config(:show).thumbnail_field}" config.default_solr_params = config.default_solr_params.merge(default_solr_params) config.show.partials.insert(2, "spotlight/catalog/tags") # Add any custom fields config.index_fields.merge! custom_index_fields config.index_fields = Hash[config.index_fields.sort_by { |k,v| field_weight(index_fields, k) }] # Update with customizations config.index_fields.each do |k, v| if index_fields[k] v.merge! index_fields[k].symbolize_keys elsif custom_index_fields[k] set_custom_field_defaults(v) else set_index_field_defaults(v) end v.if = :field_enabled? v.normalize! config v.validate! end config.show_fields = config.index_fields unless sort_fields.blank? config.sort_fields = Hash[config.sort_fields.sort_by { |k,v| field_weight(sort_fields, k) }] config.sort_fields.each do |k, v| v.if = ((sort_fields[k] || {})[:enabled] == true) next if sort_fields[k].blank? v.merge! sort_fields[k].symbolize_keys v.normalize! config v.validate! end end unless facet_fields.blank? config.facet_fields = Hash[config.facet_fields.sort_by { |k,v| field_weight(facet_fields, k) }] config.facet_fields.each do |k, v| next if facet_fields[k].blank? v.merge! facet_fields[k].symbolize_keys v.if = v.enabled v.normalize! config v.validate! end end config.per_page = (config.per_page & per_page) unless per_page.blank? if default_per_page config.per_page.delete(default_per_page) config.per_page.unshift(default_per_page) end config.view.each do |k,v| config.view[k].key = k config.view[k].if = :enabled_in_spotlight_view_type_configuration? end unless document_index_view_types.blank? config end end |
#custom_index_fields ⇒ Object
138 139 140 141 142 143 |
# File 'app/models/spotlight/blacklight_configuration.rb', line 138 def custom_index_fields Hash[exhibit.custom_fields.map do |x| field = Blacklight::Configuration::IndexField.new x.configuration.merge(field: x.field) [x.field, field] end] end |
#default_blacklight_config ⇒ Object
Get the “upstream” blacklight configuration to use
147 148 149 150 151 152 153 |
# File 'app/models/spotlight/blacklight_configuration.rb', line 147 def default_blacklight_config @default_blacklight_config ||= begin config = ::CatalogController.blacklight_config.deep_copy config.add_facet_field Spotlight::SolrDocument.solr_field_for_tagger(exhibit), label: "Exhibit Tags", show: false config end end |