Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Blacklight::Configuration to load even if the app hasn't been generated yet #2822

Merged
merged 2 commits into from
Oct 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/models/search_builder.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

class SearchBuilder < Blacklight::SearchBuilder
include Blacklight::Solr::SearchBuilderBehavior
end
12 changes: 6 additions & 6 deletions lib/blacklight.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,7 @@ def self.default_configuration
end

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
Blacklight::RuntimeRegistry.connection_config ||= blacklight_yml[::Rails.env]&.symbolize_keys if blacklight_yml?
end

def self.connection_config=(value)
Expand All @@ -84,7 +80,7 @@ def self.blacklight_yml
require 'yaml'

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

Expand All @@ -111,6 +107,10 @@ def self.blacklight_yml
@blacklight_yml
end

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

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