Module: Blacklight

Extended by:
Deprecation
Defined in:
app/helpers/blacklight/layout_helper_behavior.rb,
lib/blacklight.rb,
lib/blacklight/solr.rb,
lib/blacklight/utils.rb,
lib/blacklight/engine.rb,
lib/blacklight/routes.rb,
lib/blacklight/version.rb,
lib/blacklight/parameters.rb,
lib/blacklight/exceptions.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/configuration/field.rb,
lib/blacklight/abstract_repository.rb,
lib/blacklight/configuration/fields.rb,
lib/blacklight/configuration/context.rb,
app/models/blacklight/suggest_search.rb,
app/models/blacklight/facet_paginator.rb,
lib/blacklight/configuration/sort_field.rb,
lib/blacklight/configuration/null_field.rb,
app/services/blacklight/field_retriever.rb,
lib/blacklight/configuration/facet_field.rb,
lib/blacklight/configuration/tool_config.rb,
lib/generators/blacklight/user_generator.rb,
app/presenters/blacklight/show_presenter.rb,
app/presenters/blacklight/json_presenter.rb,
app/presenters/blacklight/rendering/join.rb,
lib/blacklight/configuration/search_field.rb,
lib/generators/blacklight/solr5_generator.rb,
lib/generators/blacklight/solr4_generator.rb,
app/controllers/concerns/blacklight/facet.rb,
app/presenters/blacklight/index_presenter.rb,
app/presenters/blacklight/field_presenter.rb,
lib/generators/blacklight/assets_generator.rb,
lib/generators/blacklight/models_generator.rb,
lib/generators/blacklight/install_generator.rb,
lib/generators/blacklight/document_generator.rb,
app/presenters/blacklight/rendering/pipeline.rb,
app/presenters/blacklight/rendering/microdata.rb,
lib/generators/blacklight/controller_generator.rb,
app/helpers/blacklight/suggest_helper_behavior.rb,
app/presenters/blacklight/rendering/terminator.rb,
app/models/concerns/blacklight/suggest/response.rb,
lib/generators/blacklight/test_support_generator.rb,
app/helpers/blacklight/component_helper_behavior.rb,
app/presenters/blacklight/rendering/helper_method.rb,
app/presenters/blacklight/rendering/abstract_step.rb,
app/presenters/blacklight/rendering/link_to_facet.rb,
lib/generators/blacklight/search_builder_generator.rb,
app/controllers/concerns/blacklight/search_history.rb,
app/controllers/concerns/blacklight/saved_searches.rb,
app/presenters/blacklight/link_alternate_presenter.rb,
app/controllers/concerns/blacklight/request_builders.rb,
app/controllers/concerns/blacklight/default_component_configuration.rb

Overview

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

Defined Under Namespace

Modules: Base, BlacklightHelperBehavior, Bookmarks, Catalog, CatalogHelperBehavior, ComponentHelperBehavior, Configurable, ConfigurationHelperBehavior, Controller, DefaultComponentConfiguration, Document, Exceptions, Facet, FacetsHelperBehavior, HashAsHiddenFieldsHelperBehavior, LayoutHelperBehavior, Parameters, RenderConstraintsHelperBehavior, RenderPartialsHelperBehavior, Rendering, RequestBuilders, Routes, SavedSearches, SearchContext, SearchFields, SearchHelper, SearchHistory, SearchHistoryConstraintsHelperBehavior, Solr, Suggest, SuggestHelperBehavior, TokenBasedUser, UrlHelperBehavior, User, Utils Classes: AbstractRepository, Assets, Configuration, ControllerGenerator, DocumentGenerator, Engine, FacetPaginator, FieldPresenter, FieldRetriever, IndexPresenter, Install, JsonPresenter, LinkAlternatePresenter, ModelsGenerator, NestedOpenStructWithHashAccess, OpenStructWithHashAccess, RuntimeRegistry, SearchBuilder, SearchBuilderGenerator, SearchState, ShowPresenter, Solr4Generator, Solr5Generator, SuggestSearch, TestSupport, UserGenerator

Constant Summary

VERSION =
self.version

Class Method Summary collapse

Class Method Details

.blacklight_config_fileObject



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

def self.blacklight_config_file
  "#{::Rails.root}/config/blacklight.yml"
end

.blacklight_ymlObject



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

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

  return @blacklight_yml if @blacklight_yml
  unless File.exist?(blacklight_config_file)
    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.load(blacklight_erb)
  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

.connection_configObject



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

def self.connection_config
  Blacklight::RuntimeRegistry.connection_config ||= begin
    raise "The #{::Rails.env} environment settings were not found in the blacklight.yml config" unless blacklight_yml[::Rails.env]
    blacklight_yml[::Rails.env].symbolize_keys
  end
end

.connection_config=(value) ⇒ Object



66
67
68
# File 'lib/blacklight.rb', line 66

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

.default_configurationObject

The default Blacklight configuration.



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

def self.default_configuration
  Blacklight::Configuration.new
end

.default_indexObject

The default index connection for the search index



29
30
31
# File 'lib/blacklight.rb', line 29

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

.default_index=(repository) ⇒ Object



33
34
35
# File 'lib/blacklight.rb', line 33

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

.loggerObject



98
99
100
101
102
# File 'lib/blacklight.rb', line 98

def self.logger
  @logger ||= begin
    ::Rails.logger if defined? Rails and Rails.respond_to? :logger
  end
end

.logger=(logger) ⇒ Object



104
105
106
# File 'lib/blacklight.rb', line 104

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


41
42
43
44
45
46
47
48
49
50
51
# File 'lib/blacklight.rb', line 41

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



117
118
119
# File 'lib/blacklight.rb', line 117

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