From 82e658a7388155590850e9948ba5205e5f55d117 Mon Sep 17 00:00:00 2001 From: Chris Beer Date: Wed, 28 Sep 2022 15:41:40 -0700 Subject: [PATCH 1/6] Support view_component 2.74; fixes #2816 --- lib/blacklight/component.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/blacklight/component.rb b/lib/blacklight/component.rb index 8aab8e112f..faccbb8973 100644 --- a/lib/blacklight/component.rb +++ b/lib/blacklight/component.rb @@ -8,6 +8,8 @@ def compiler @__vc_compiler ||= EngineCompiler.new(self) end # rubocop:enable Naming/MemoizedInstanceVariableName + + alias sidecar_files _sidecar_files unless ViewComponent::Base.respond_to? :sidecar_files end class EngineCompiler < ::ViewComponent::Compiler @@ -23,7 +25,7 @@ def templates @templates ||= begin extensions = ActionView::Template.template_handler_extensions - component_class._sidecar_files(extensions).each_with_object([]) do |path, memo| + component_class.sidecar_files(extensions).each_with_object([]) do |path, memo| pieces = File.basename(path).split(".") app_path = "#{Rails.root}/#{path.slice(path.index(component_class.view_component_path)..-1)}" From 17ea164d5738dc5736018293f4d81e942760ba8a Mon Sep 17 00:00:00 2001 From: Chris Beer Date: Thu, 29 Sep 2022 07:06:29 -0700 Subject: [PATCH 2/6] Allow view type configuration to pass icon components --- .../blacklight/response/view_type_button_component.rb | 3 +++ lib/blacklight/configuration/view_config.rb | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/components/blacklight/response/view_type_button_component.rb b/app/components/blacklight/response/view_type_button_component.rb index fbb67b0e04..0d763b838d 100644 --- a/app/components/blacklight/response/view_type_button_component.rb +++ b/app/components/blacklight/response/view_type_button_component.rb @@ -15,6 +15,9 @@ def initialize(view:, key: nil, selected: false, search_state: nil, classes: 'bt end def icon + return render(@view.icon.new) if @view.icon.is_a?(Class) + return render(@view.icon) if @view.icon.is_a?(ViewComponent::Base) + Deprecation.silence(Blacklight::CatalogHelperBehavior) do helpers.render_view_type_group_icon(@view.icon || @key) end diff --git a/lib/blacklight/configuration/view_config.rb b/lib/blacklight/configuration/view_config.rb index 7b1576b70d..f9fd5b6533 100644 --- a/lib/blacklight/configuration/view_config.rb +++ b/lib/blacklight/configuration/view_config.rb @@ -14,7 +14,7 @@ class ViewConfig < Blacklight::OpenStructWithHashAccess # @!attribute display_type_field # @return [String, Symbol] solr field to use to render format-specific partials # @!attribute icon - # @return [String, Symbol] icon file to use in the view picker + # @return [String, Symbol, Blacklight::Icons::IconComponent] icon file to use in the view picker # @!attribute document_actions # @return [NestedOpenStructWithHashAccess{Symbol => Blacklight::Configuration::ToolConfig}] 'tools' to render for each document # @!attribute facet_group_component From c526641c388dae7aa5f8417994f6b5db2ef8c1ce Mon Sep 17 00:00:00 2001 From: Chris Beer Date: Thu, 29 Sep 2022 07:11:14 -0700 Subject: [PATCH 3/6] Extract Blacklight::Icons::IconComponent base class for a little easier time creating new icons --- .../blacklight/icons/icon_component.rb | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 app/components/blacklight/icons/icon_component.rb diff --git a/app/components/blacklight/icons/icon_component.rb b/app/components/blacklight/icons/icon_component.rb new file mode 100644 index 0000000000..63106d0e71 --- /dev/null +++ b/app/components/blacklight/icons/icon_component.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module Blacklight + module Icons + # This is the list icon for the search button. + # You can override the default svg by setting: + # Blacklight::Icons::ListComponent.svg = 'your SVG here' + class IconComponent < ::ViewComponent::Base + def initialize(svg: nil) + self.svg = svg if svg + end + + def call + svg&.html_safe # rubocop:disable Rails/OutputSafety + end + + class_attribute :svg + end + end +end From a7cc5d6d4542ebe8e1605edf7955a6d0214b429f Mon Sep 17 00:00:00 2001 From: David Kinzer Date: Fri, 16 Sep 2022 10:48:19 -0400 Subject: [PATCH 4/6] Fix broken link to solr config readme. The REAME_SOLR file was removed from the wiki. This change updtes the link to a different wiki page regarding Solr configurations. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4399b88ccb..6d5d581579 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ rails generate blacklight:install Code contributions are always welcome, instructions for contributing can be found at [CONTRIBUTING.md](https://github.com/projectblacklight/blacklight/blob/main/CONTRIBUTING.md). ## Configuring Apache Solr -You'll also want some information about how Blacklight expects [Apache Solr](http://lucene.apache.org/solr ) to run, which you can find in [README_SOLR](https://github.com/projectblacklight/blacklight/wiki/README_SOLR) +You'll also want some information about how Blacklight expects [Apache Solr](http://lucene.apache.org/solr ) to run, which you can find in [Solr Configuration](https://github.com/projectblacklight/blacklight/wiki/Solr-Configuration#solr-configuration) ## Building the javascript The javascript is built by npm from sources in `app/javascript` into a bundle From ab71d7f72c12923ecfc559395967cde4695a0c32 Mon Sep 17 00:00:00 2001 From: Justin Coyne Date: Thu, 4 Aug 2022 09:55:09 -0500 Subject: [PATCH 5/6] Add documentation on SearchBuilder#where --- lib/blacklight/search_builder.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/blacklight/search_builder.rb b/lib/blacklight/search_builder.rb index bd46dc7101..ae56510449 100644 --- a/lib/blacklight/search_builder.rb +++ b/lib/blacklight/search_builder.rb @@ -45,6 +45,9 @@ def with(blacklight_params_or_search_state = {}) ## # Update the :q (query) parameter + # @param [Hash] conditions the field and values to query on + # @example + # search_builder.where(id: [1,2,3]) # produces: q:"{!lucene}id:(1 OR 2 OR 3)" def where(conditions) Deprecation.warn(Blacklight::SearchBuilder, "SearchBuilder#where must be called with a hash, received #{conditions.inspect}.") unless conditions.is_a? Hash params_will_change! From 88b3978ad7a04fbd9054b01f97aa0c83b482f043 Mon Sep 17 00:00:00 2001 From: Chris Beer Date: Mon, 11 Jul 2022 11:58:52 -0700 Subject: [PATCH 6/6] Use a HashWithIndifferentAccess to contain configuration data --- lib/blacklight/configuration/fields.rb | 2 +- spec/models/blacklight/configuration_spec.rb | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/blacklight/configuration/fields.rb b/lib/blacklight/configuration/fields.rb index 5040797260..91723bc416 100644 --- a/lib/blacklight/configuration/fields.rb +++ b/lib/blacklight/configuration/fields.rb @@ -13,7 +13,7 @@ module Fields def define_field_access(key, base_class_name = nil, class: nil) key = key.to_s if respond_to? :to_s - default_values[key.pluralize.to_sym] = ActiveSupport::OrderedHash.new + default_values[key.pluralize.to_sym] = ActiveSupport::HashWithIndifferentAccess.new @field_type_for_class ||= {} @field_type_for_class[key] = binding.local_variable_get(:class) || base_class_name diff --git a/spec/models/blacklight/configuration_spec.rb b/spec/models/blacklight/configuration_spec.rb index a61a7f9180..19f4945cdb 100644 --- a/spec/models/blacklight/configuration_spec.rb +++ b/spec/models/blacklight/configuration_spec.rb @@ -39,13 +39,13 @@ end it "has ordered hashes for field configuration" do - expect(config.facet_fields).to be_a_kind_of ActiveSupport::OrderedHash - expect(config.index_fields).to be_a_kind_of ActiveSupport::OrderedHash - expect(config.show_fields).to be_a_kind_of ActiveSupport::OrderedHash - expect(config.search_fields).to be_a_kind_of ActiveSupport::OrderedHash - expect(config.show_fields).to be_a_kind_of ActiveSupport::OrderedHash - expect(config.search_fields).to be_a_kind_of ActiveSupport::OrderedHash - expect(config.sort_fields).to be_a_kind_of ActiveSupport::OrderedHash + expect(config.facet_fields).to be_a_kind_of ActiveSupport::HashWithIndifferentAccess + expect(config.index_fields).to be_a_kind_of ActiveSupport::HashWithIndifferentAccess + expect(config.show_fields).to be_a_kind_of ActiveSupport::HashWithIndifferentAccess + expect(config.search_fields).to be_a_kind_of ActiveSupport::HashWithIndifferentAccess + expect(config.show_fields).to be_a_kind_of ActiveSupport::HashWithIndifferentAccess + expect(config.search_fields).to be_a_kind_of ActiveSupport::HashWithIndifferentAccess + expect(config.sort_fields).to be_a_kind_of ActiveSupport::HashWithIndifferentAccess end end