Skip to content

Commit

Permalink
Configure the date range widget so it works on the home page and add …
Browse files Browse the repository at this point in the history
…a hijri range field
  • Loading branch information
cbeer committed Nov 27, 2019
1 parent 0664201 commit 0956bd4
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 9 additions & 1 deletion app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions app/controllers/spotlight/home_pages_controller.rb
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 0956bd4

Please sign in to comment.