diff --git a/Gemfile.lock b/Gemfile.lock index d1f13dab..b3a67b34 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -137,7 +137,7 @@ GEM blacklight (~> 7.0) rails ruby-oembed - blacklight_range_limit (7.3.0) + blacklight_range_limit (7.3.1) blacklight (>= 7.0) bootsnap (1.4.5) msgpack (~> 1.0) diff --git a/app/controllers/catalog_controller.rb b/app/controllers/catalog_controller.rb index 65f5790c..9c6e5698 100644 --- a/app/controllers/catalog_controller.rb +++ b/app/controllers/catalog_controller.rb @@ -136,7 +136,15 @@ class CatalogController < ApplicationController config.add_facet_field 'spatial', field: 'cho_spatial_ssim', limit: true config.add_facet_field 'temporal', field: 'cho_temporal_ssim', limit: true config.add_facet_field 'source_date', field: 'cho_date_ssim', limit: true - config.add_facet_field 'cho_date_range_norm_isim', field: 'cho_date_range_norm_isim', range: true + # Using an explicit partial for the date ranges so the configuration works for the home page + config.add_facet_field 'cho_date_range_norm_isim', + field: 'cho_date_range_norm_isim', + range: true, + partial: 'blacklight_range_limit/range_limit_panel' + config.add_facet_field 'cho_date_range_hijri_isim', + field: 'cho_date_range_hijri_isim', + range: true, + partial: 'blacklight_range_limit/range_limit_panel' config.add_facet_field 'creator', field: 'cho_creator_ssim', limit: true config.add_facet_field 'contributor', field: 'cho_contributor_ssim', limit: true config.add_facet_field 'medium', field: 'cho_medium_ssim', limit: true diff --git a/app/controllers/spotlight/home_pages_controller.rb b/app/controllers/spotlight/home_pages_controller.rb new file mode 100644 index 00000000..ee5f801c --- /dev/null +++ b/app/controllers/spotlight/home_pages_controller.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +# This unpleasantness allows us to include the upstream controller before overriding it +# rubocop:disable Rails/DynamicFindBy +spotlight_path = Gem::Specification.find_by_name('blacklight-spotlight').full_gem_path +require_dependency File.join(spotlight_path, 'app/controllers/spotlight/home_pages_controller') +# rubocop:enable Rails/DynamicFindBy + +module Spotlight + # Override the upstream HomePagesController in order to inject range limit behaviors + class HomePagesController + include BlacklightRangeLimit::ControllerOverride + end +end diff --git a/config/routes.rb b/config/routes.rb index 0357d1a1..dbae949d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -35,6 +35,9 @@ resource :statistics, only: :show get "catalog/range_limit" => "spotlight/catalog#range_limit" + get "home/range_limit" => "spotlight/home_pages#range_limit" + get "catalog/range_limit_panel/:id" => "spotlight/catalog#range_limit_panel" + get "home/range_limit_panel/:id" => "spotlight/home_pages#range_limit_panel" end resource :transform, only: [:show, :create]