Module: Blacklight

Extended by:
Deprecation
Defined in:
app/services/blacklight/search_service.rb,
lib/blacklight.rb,
lib/blacklight/solr.rb,
lib/blacklight/engine.rb,
lib/blacklight/routes.rb,
lib/blacklight/version.rb,
lib/blacklight/component.rb,
lib/blacklight/exceptions.rb,
lib/blacklight/parameters.rb,
app/models/blacklight/icon.rb,
app/values/blacklight/types.rb,
lib/blacklight/search_state.rb,
lib/blacklight/configuration.rb,
lib/blacklight/search_builder.rb,
lib/blacklight/runtime_registry.rb,
lib/blacklight/routes/exportable.rb,
lib/blacklight/routes/searchable.rb,
lib/blacklight/abstract_repository.rb,
lib/blacklight/configuration/field.rb,
lib/blacklight/configuration/fields.rb,
app/models/blacklight/suggest_search.rb,
lib/blacklight/configuration/context.rb,
app/models/blacklight/facet_paginator.rb,
app/builders/blacklight/action_builder.rb,
app/services/blacklight/field_retriever.rb,
lib/blacklight/configuration/null_field.rb,
lib/blacklight/configuration/show_field.rb,
lib/blacklight/configuration/sort_field.rb,
app/presenters/blacklight/json_presenter.rb,
app/presenters/blacklight/rendering/join.rb,
app/presenters/blacklight/show_presenter.rb,
app/services/blacklight/document_factory.rb,
lib/blacklight/configuration/facet_field.rb,
lib/blacklight/configuration/index_field.rb,
lib/blacklight/configuration/tool_config.rb,
lib/blacklight/search_state/filter_field.rb,
lib/generators/blacklight/solr_generator.rb,
lib/generators/blacklight/user_generator.rb,
app/components/blacklight/facet_component.rb,
app/controllers/concerns/blacklight/facet.rb,
app/presenters/blacklight/field_presenter.rb,
app/presenters/blacklight/index_presenter.rb,
lib/blacklight/configuration/search_field.rb,
app/components/blacklight/header_component.rb,
app/presenters/blacklight/clause_presenter.rb,
lib/blacklight/configuration/display_field.rb,
lib/generators/blacklight/assets_generator.rb,
lib/generators/blacklight/models_generator.rb,
lib/blacklight/open_struct_with_hash_access.rb,
lib/generators/blacklight/install_generator.rb,
app/components/blacklight/content_areas_shim.rb,
app/components/blacklight/document_component.rb,
app/presenters/blacklight/document_presenter.rb,
app/presenters/blacklight/rendering/pipeline.rb,
lib/generators/blacklight/document_generator.rb,
app/helpers/blacklight/layout_helper_behavior.rb,
app/presenters/blacklight/rendering/microdata.rb,
app/presenters/blacklight/thumbnail_presenter.rb,
app/components/blacklight/constraint_component.rb,
app/components/blacklight/facet_item_component.rb,
app/components/blacklight/icons/icon_component.rb,
app/components/blacklight/search_bar_component.rb,
app/components/blacklight/top_navbar_component.rb,
app/helpers/blacklight/suggest_helper_behavior.rb,
app/presenters/blacklight/facet_item_presenter.rb,
app/presenters/blacklight/rendering/terminator.rb,
app/presenters/blacklight/search_bar_presenter.rb,
lib/generators/blacklight/controller_generator.rb,
app/components/blacklight/constraints_component.rb,
app/components/blacklight/facet_field_component.rb,
app/models/concerns/blacklight/suggest/response.rb,
app/presenters/blacklight/facet_field_presenter.rb,
app/components/blacklight/system/modal_component.rb,
app/helpers/blacklight/component_helper_behavior.rb,
app/services/blacklight/search_params_yaml_coder.rb,
lib/blacklight/deprecations/engine_configuration.rb,
lib/generators/blacklight/test_support_generator.rb,
app/components/blacklight/response/sort_component.rb,
app/components/blacklight/search_button_component.rb,
app/components/blacklight/search_navbar_component.rb,
app/presenters/blacklight/rendering/abstract_step.rb,
app/presenters/blacklight/rendering/helper_method.rb,
app/presenters/blacklight/rendering/link_to_facet.rb,
app/components/blacklight/document/group_component.rb,
app/components/blacklight/document_title_component.rb,
app/components/blacklight/metadata_field_component.rb,
app/components/blacklight/search_context_component.rb,
app/controllers/concerns/blacklight/search_history.rb,
app/presenters/blacklight/link_alternate_presenter.rb,
lib/blacklight/nested_open_struct_with_hash_access.rb,
lib/generators/blacklight/search_builder_generator.rb,
app/components/blacklight/document/action_component.rb,
app/components/blacklight/search/per_page_component.rb,
app/components/blacklight/system/dropdown_component.rb,
app/components/blacklight/document/actions_component.rb,
app/components/blacklight/facet_field_list_component.rb,
app/components/blacklight/facet_item_pivot_component.rb,
lib/generators/blacklight/assets/importmap_generator.rb,
lib/generators/blacklight/assets/propshaft_generator.rb,
lib/generators/blacklight/assets/sprockets_generator.rb,
app/components/blacklight/constraint_layout_component.rb,
app/components/blacklight/document/bookmark_component.rb,
app/components/blacklight/document/citation_component.rb,
app/components/blacklight/document_metadata_component.rb,
app/components/blacklight/start_over_button_component.rb,
app/components/blacklight/document/thumbnail_component.rb,
app/components/blacklight/facet_field_filter_component.rb,
app/components/blacklight/response/view_type_component.rb,
app/presenters/blacklight/facet_grouped_item_presenter.rb,
lib/blacklight/deprecations/search_state_normalization.rb,
app/components/blacklight/hidden_search_state_component.rb,
app/components/blacklight/response/pagination_component.rb,
app/components/blacklight/response/spellcheck_component.rb,
app/components/blacklight/advanced_search_form_component.rb,
app/components/blacklight/response/facet_group_component.rb,
app/components/blacklight/system/flash_message_component.rb,
app/presenters/blacklight/inclusive_facet_item_presenter.rb,
app/components/blacklight/facet_field_no_layout_component.rb,
app/components/blacklight/metadata_field_layout_component.rb,
app/components/blacklight/facet_field_checkboxes_component.rb,
app/components/blacklight/facet_field_pagination_component.rb,
app/components/blacklight/system/dropdown_button_component.rb,
app/components/blacklight/document/more_like_this_component.rb,
app/components/blacklight/response/view_type_button_component.rb,
app/controllers/concerns/blacklight/default_component_configuration.rb,
app/components/blacklight/facet_field_inclusive_constraint_component.rb,
app/components/blacklight/search_history_constraint_layout_component.rb,
app/components/blacklight/search_context/server_item_pagination_component.rb

Overview

Methods added to this helper will be available to all templates in the hosting application

Defined Under Namespace

Modules: Assets, Base, BlacklightHelperBehavior, Bookmarks, Catalog, CatalogHelperBehavior, ComponentHelperBehavior, Configurable, ConfigurationHelperBehavior, ContentAreasShim, Controller, DefaultComponentConfiguration, Deprecations, Document, Exceptions, Facet, FacetsHelperBehavior, HashAsHiddenFieldsHelperBehavior, IconHelperBehavior, Icons, LayoutHelperBehavior, RenderConstraintsHelperBehavior, RenderPartialsHelperBehavior, Rendering, Response, Routes, Search, SearchContext, SearchFields, SearchHistory, SearchHistoryConstraintsHelperBehavior, Searchable, Solr, Suggest, SuggestHelperBehavior, System, TokenBasedUser, Types, UrlHelperBehavior, User Classes: AbstractRepository, ActionBuilder, AdvancedSearchFormComponent, AssetsGenerator, ClausePresenter, Component, Configuration, ConstraintComponent, ConstraintLayoutComponent, ConstraintsComponent, ControllerGenerator, DocumentComponent, DocumentFactory, DocumentGenerator, DocumentMetadataComponent, DocumentPresenter, DocumentTitleComponent, Engine, FacetComponent, FacetFieldCheckboxesComponent, FacetFieldComponent, FacetFieldFilterComponent, FacetFieldInclusiveConstraintComponent, FacetFieldListComponent, FacetFieldNoLayoutComponent, FacetFieldPaginationComponent, FacetFieldPresenter, FacetGroupedItemPresenter, FacetItemComponent, FacetItemPivotComponent, FacetItemPresenter, FacetPaginator, FieldPresenter, FieldRetriever, HeaderComponent, HiddenSearchStateComponent, Icon, InclusiveFacetItemPresenter, IndexPresenter, Install, JsonPresenter, LinkAlternatePresenter, MetadataFieldComponent, MetadataFieldLayoutComponent, ModelsGenerator, NestedOpenStructWithHashAccess, OpenStructWithHashAccess, Parameters, RuntimeRegistry, SearchBarComponent, SearchBarPresenter, SearchBuilder, SearchBuilderGenerator, SearchButtonComponent, SearchContextComponent, SearchHistoryConstraintLayoutComponent, SearchNavbarComponent, SearchParamsYamlCoder, SearchService, SearchState, ShowPresenter, SolrGenerator, StartOverButtonComponent, SuggestSearch, TestSupport, ThumbnailPresenter, TopNavbarComponent, UserGenerator

Constant Summary collapse

VERSION =
version

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.blacklight_config_fileObject



14
15
16
# File 'lib/blacklight.rb', line 14

def self.blacklight_config_file
  Rails.root.join("config/blacklight.yml")
end

.blacklight_ymlObject



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
# File 'lib/blacklight.rb', line 69

def self.blacklight_yml
  require 'erb'
  require 'yaml'

  return @blacklight_yml if @blacklight_yml
  unless blacklight_yml?
    raise "You are missing a configuration file: #{blacklight_config_file}. Have you run \"rails generate blacklight:install\"?"
  end

  begin
    blacklight_erb = ERB.new(IO.read(blacklight_config_file)).result(binding)
  rescue StandardError, SyntaxError => e
    raise("#{blacklight_config_file} was found, but could not be parsed with ERB. \n#{e.inspect}")
  end

  begin
    @blacklight_yml = YAML.safe_load(blacklight_erb, aliases: true)
  rescue => e
    raise("#{blacklight_config_file} was found, but could not be parsed.\n#{e.inspect}")
  end

  if @blacklight_yml.nil? || !@blacklight_yml.is_a?(Hash)
    raise("#{blacklight_config_file} was found, but was blank or malformed.\n")
  end

  @blacklight_yml
end

.blacklight_yml?Boolean

Returns:

  • (Boolean)


97
98
99
# File 'lib/blacklight.rb', line 97

def self.blacklight_yml?
  File.exist?(blacklight_config_file)
end

.connection_configObject



51
52
53
# File 'lib/blacklight.rb', line 51

def self.connection_config
  Blacklight::RuntimeRegistry.connection_config ||= blacklight_yml[::Rails.env]&.symbolize_keys if blacklight_yml?
end

.connection_config=(value) ⇒ Object



55
56
57
# File 'lib/blacklight.rb', line 55

def self.connection_config=(value)
  Blacklight::RuntimeRegistry.connection_config = value
end

.default_configurationObject

The default Blacklight configuration.



47
48
49
# File 'lib/blacklight.rb', line 47

def self.default_configuration
  Blacklight::Configuration.new
end

.default_indexObject

The default index connection for the search index



20
21
22
# File 'lib/blacklight.rb', line 20

def self.default_index
  Blacklight::RuntimeRegistry.connection ||= repository_class.new(default_configuration)
end

.default_index=(repository) ⇒ Object



24
25
26
# File 'lib/blacklight.rb', line 24

def self.default_index=(repository)
  Blacklight::RuntimeRegistry.connection = repository
end

.loggerObject



101
102
103
104
105
# File 'lib/blacklight.rb', line 101

def self.logger
  @logger ||= begin
    ::Rails.logger if defined? Rails && Rails.respond_to?(:logger)
  end
end

.logger=(logger) ⇒ Object



107
108
109
# File 'lib/blacklight.rb', line 107

def self.logger= logger
  @logger = logger
end

.repository_classObject

The configured repository class. By convention, this is the class Blacklight::(name of the adapter)::Repository, e.g.

elastic_search => Blacklight::ElasticSearch::Repository


32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/blacklight.rb', line 32

def self.repository_class
  case connection_config[:adapter]
  when 'solr'
    Blacklight::Solr::Repository
  when /::/
    connection_config[:adapter].constantize
  else
    raise "The value for :adapter was not found in the blacklight.yml config" unless connection_config.key? :adapter

    Blacklight.const_get("#{connection_config.fetch(:adapter)}/Repository".classify)
  end
end

.rootObject

returns the full path the the blacklight plugin installation



120
121
122
# File 'lib/blacklight.rb', line 120

def self.root
  @root ||= File.expand_path(File.dirname(File.dirname(__FILE__)))
end

.versionObject



4
5
6
# File 'lib/blacklight/version.rb', line 4

def self.version
  @version ||= File.read(File.join(File.dirname(__FILE__), '..', '..', 'VERSION')).chomp
end

Instance Method Details

#defaults_versionObject



59
60
61
62
63
64
65
66
67
# File 'lib/blacklight.rb', line 59

def defaults_version
  @defaults_version ||= blacklight_yml['load_defaults'] ||
                        # this config parameter was introduced in Blacklight 7.11, so to be safe,
                        # we pin any 7.x app to the 7.10 behavior
                        (Blacklight::VERSION.starts_with?('7') && '7.10.0') ||
                        Blacklight::VERSION

  @defaults_version == 'latest' ? Blacklight::VERSION : @defaults_version
end