Module: Blacklight

Extended by:
SearchFields, Deprecation
Defined in:
lib/blacklight/facet.rb,
lib/blacklight.rb,
lib/blacklight/utils.rb,
lib/blacklight/routes.rb,
lib/blacklight/engine.rb,
lib/blacklight/version.rb,
lib/blacklight/exceptions.rb,
lib/blacklight/solr_helper.rb,
lib/blacklight/configuration.rb,
lib/blacklight/search_builder.rb,
lib/blacklight/solr_repository.rb,
lib/blacklight/request_builders.rb,
lib/blacklight/document_presenter.rb,
lib/blacklight/configuration/field.rb,
lib/blacklight/abstract_repository.rb,
lib/blacklight/configuration/fields.rb,
lib/blacklight/configuration/sort_field.rb,
lib/blacklight/configuration/solr_field.rb,
lib/blacklight/configuration/tool_config.rb,
lib/blacklight/configuration/facet_field.rb,
lib/generators/blacklight/user_generator.rb,
lib/blacklight/configuration/search_field.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,
lib/generators/blacklight/controller_generator.rb,
lib/blacklight/catalog/component_configuration.rb,
lib/generators/blacklight/test_support_generator.rb,
app/helpers/blacklight/component_helper_behavior.rb,
lib/generators/blacklight/search_builder_generator.rb

Overview

These are methods that are used at both the view helper and controller layers They are only dependent on `blacklight_config` and `@response`

Defined Under Namespace

Modules: Base, BlacklightHelperBehavior, Bookmarks, Catalog, CatalogHelperBehavior, ComponentHelperBehavior, Configurable, ConfigurationHelperBehavior, Controller, Document, Exceptions, Facet, FacetsHelperBehavior, HashAsHiddenFieldsHelperBehavior, RenderConstraintsHelperBehavior, RenderPartialsHelper, RequestBuilders, SearchFields, SearchHelper, SearchHistoryConstraintsHelperBehavior, Solr, SolrHelper, TokenBasedUser, UrlHelperBehavior, User, Utils Classes: AbstractRepository, Assets, Configuration, ControllerGenerator, DocumentGenerator, DocumentPresenter, Engine, Install, ModelsGenerator, NestedOpenStructWithHashAccess, OpenStructWithHashAccess, Routes, SearchBuilder, SearchBuilderGenerator, SolrRepository, SolrResponse, TestSupport, UserGenerator

Constant Summary

VERSION =
self.version
@@secret_key =
nil

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from SearchFields

default_search_field, label_for_search_field, search_field_def_for_key, search_field_list

Class Attribute Details

.solrObject

Returns the value of attribute solr



45
46
47
# File 'lib/blacklight.rb', line 45

def solr
  @solr
end

.solr_configObject

Returns the value of attribute solr_config



45
46
47
# File 'lib/blacklight.rb', line 45

def solr_config
  @solr_config
end

Class Method Details

.add_routes(router, options = {}) ⇒ Object



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

def self.add_routes(router, options = {})
  Blacklight::Routes.new(router, options).draw
end

.blacklight_config_fileObject



58
59
60
# File 'lib/blacklight.rb', line 58

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

.blacklight_ymlObject



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

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

  return @blacklight_yml if @blacklight_yml
  unless File.exists?(blacklight_config_file)
    if File.exists?(solr_file)
      Deprecation.warn Blacklight, "Configuration is now done via blacklight.yml. Suppport for solr.yml will be removed in blacklight 6.0.0"
      return solr_yml
    else
      raise "You are missing a configuration file: #{blacklight_config_file}. Have you run \"rails generate blacklight:install\"?"
    end
  end

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

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

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

  return @blacklight_yml
end

.connection_configObject



80
81
82
83
84
85
# File 'lib/blacklight.rb', line 80

def self.connection_config
  @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

.default_indexObject



71
72
73
# File 'lib/blacklight.rb', line 71

def self.default_index
  @default_index ||=  Blacklight::SolrRepository.new(Blacklight::Configuration.new)
end

.loggerObject



148
149
150
151
152
# File 'lib/blacklight.rb', line 148

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

.logger=(logger) ⇒ Object



154
155
156
# File 'lib/blacklight.rb', line 154

def self.logger= logger
  @logger = logger
end

.rootObject

returns the full path the the blacklight plugin installation



167
168
169
# File 'lib/blacklight.rb', line 167

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

.solr_fileObject

Deprecated.


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

def self.solr_file
  "#{::Rails.root.to_s}/config/solr.yml"
end

.solr_ymlObject



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/blacklight.rb', line 120

def self.solr_yml
  require 'erb'
  require 'yaml'

  return @solr_yml if @solr_yml
  unless File.exists?(solr_file)
    raise "You are missing a solr configuration file: #{solr_file}. Have you run \"rails generate blacklight:install\"?"  
  end

  begin
    @solr_erb = ERB.new(IO.read(solr_file)).result(binding)
  rescue Exception => e
    raise("solr.yml was found, but could not be parsed with ERB. \n#{$!.inspect}")
  end

  begin
    @solr_yml = YAML::load(@solr_erb)
  rescue StandardError => e
    raise("solr.yml was found, but could not be parsed.\n")
  end

  if @solr_yml.nil? || !@solr_yml.is_a?(Hash)
    raise("solr.yml was found, but was blank or malformed.\n")
  end

  return @solr_yml
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