From 5e5a58a57f55fa6688a8e3f5d5d08c6356c6d0e5 Mon Sep 17 00:00:00 2001 From: Aditya Ranaganath Date: Mon, 3 Feb 2020 15:51:36 -0800 Subject: [PATCH] add blacklight range limit --- Gemfile | 2 + Gemfile.lock | 379 +++++++++++++++++++ app/assets/javascripts/application.js | 6 + app/assets/stylesheets/application.css | 7 +- app/controllers/catalog_controller.rb | 4 +- app/controllers/search_history_controller.rb | 7 + app/models/search_builder.rb | 2 + config/routes.rb | 3 + 8 files changed, 408 insertions(+), 2 deletions(-) create mode 100644 Gemfile.lock create mode 100644 app/controllers/search_history_controller.rb diff --git a/Gemfile b/Gemfile index d19b6a9..5a5ddb9 100644 --- a/Gemfile +++ b/Gemfile @@ -71,3 +71,5 @@ gem 'twitter-typeahead-rails', '0.11.1.pre.corejavascript' gem 'jquery-rails' gem 'devise' gem 'devise-guests', '~> 0.6' + +gem "blacklight_range_limit" diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..3338e80 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,379 @@ +GEM + remote: https://rubygems.org/ + specs: + actioncable (5.2.4) + actionpack (= 5.2.4) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailer (5.2.4) + actionpack (= 5.2.4) + actionview (= 5.2.4) + activejob (= 5.2.4) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.2.4) + actionview (= 5.2.4) + activesupport (= 5.2.4) + rack (~> 2.0) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.2.4) + activesupport (= 5.2.4) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.2.4) + activesupport (= 5.2.4) + globalid (>= 0.3.6) + activemodel (5.2.4) + activesupport (= 5.2.4) + activerecord (5.2.4) + activemodel (= 5.2.4) + activesupport (= 5.2.4) + arel (>= 9.0) + activestorage (5.2.4) + actionpack (= 5.2.4) + activerecord (= 5.2.4) + marcel (~> 0.3.1) + activesupport (5.2.4) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) + arel (9.0.0) + autoprefixer-rails (9.7.3) + execjs + bcrypt (3.1.13) + bindex (0.8.1) + blacklight (7.4.1) + deprecation + globalid + jbuilder (~> 2.7) + kaminari (>= 0.15) + rails (>= 5.1, < 7) + blacklight_range_limit (7.4.0) + blacklight (>= 7.0) + bootsnap (1.4.5) + msgpack (~> 1.0) + bootstrap (4.4.1) + autoprefixer-rails (>= 9.1.0) + popper_js (>= 1.14.3, < 2) + sassc-rails (>= 2.0.0) + builder (3.2.3) + byebug (11.0.1) + capybara (3.29.0) + addressable + mini_mime (>= 0.1.3) + nokogiri (~> 1.8) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (~> 1.5) + xpath (~> 3.2) + childprocess (3.0.0) + coderay (1.1.2) + coffee-rails (4.2.2) + coffee-script (>= 2.2.0) + railties (>= 4.0.0) + coffee-script (2.4.1) + coffee-script-source + execjs + coffee-script-source (1.12.2) + concurrent-ruby (1.1.5) + config (2.0.0) + activesupport (>= 4.2) + deep_merge (~> 1.2, >= 1.2.1) + dry-schema (~> 1.0) + crass (1.0.5) + deep_merge (1.2.1) + deprecation (1.0.0) + activesupport + devise (4.7.1) + bcrypt (~> 3.0) + orm_adapter (~> 0.1) + railties (>= 4.1.0) + responders + warden (~> 1.2.3) + devise-guests (0.7.0) + devise + dry-configurable (0.9.0) + concurrent-ruby (~> 1.0) + dry-core (~> 0.4, >= 0.4.7) + dry-container (0.7.2) + concurrent-ruby (~> 1.0) + dry-configurable (~> 0.1, >= 0.1.3) + dry-core (0.4.9) + concurrent-ruby (~> 1.0) + dry-equalizer (0.3.0) + dry-inflector (0.2.0) + dry-initializer (3.0.2) + dry-logic (1.0.5) + concurrent-ruby (~> 1.0) + dry-core (~> 0.2) + dry-equalizer (~> 0.2) + dry-schema (1.4.1) + concurrent-ruby (~> 1.0) + dry-configurable (~> 0.8, >= 0.8.3) + dry-core (~> 0.4) + dry-equalizer (~> 0.2) + dry-initializer (~> 3.0) + dry-logic (~> 1.0) + dry-types (~> 1.2) + dry-types (1.2.1) + concurrent-ruby (~> 1.0) + dry-container (~> 0.3) + dry-core (~> 0.4, >= 0.4.4) + dry-equalizer (~> 0.2, >= 0.2.2) + dry-inflector (~> 0.1, >= 0.1.2) + dry-logic (~> 1.0, >= 1.0.2) + erubi (1.9.0) + execjs (2.7.0) + faraday (0.17.1) + multipart-post (>= 1.2, < 3) + faraday_middleware (0.13.1) + faraday (>= 0.7.4, < 1.0) + ffi (1.11.3) + font-awesome-rails (4.7.0.5) + railties (>= 3.2, < 6.1) + geo_combine (0.4.0) + activesupport + json-schema + net-http-persistent (~> 2.0) + nokogiri + rsolr + sanitize + thor + geoblacklight (2.2.1) + blacklight (~> 7.0) + coderay + config + deprecation + faraday + faraday_middleware + font-awesome-rails + geo_combine (~> 0.4) + geoblacklight-icons (>= 0.2) + handlebars_assets + mime-types + rails (~> 5.0) + webpacker + geoblacklight-icons (1.4.0) + globalid (0.4.2) + activesupport (>= 4.2.0) + handlebars_assets (0.23.7) + execjs (~> 2.0) + sprockets (>= 2.0.0) + tilt (>= 1.2) + i18n (1.7.0) + concurrent-ruby (~> 1.0) + jbuilder (2.9.1) + activesupport (>= 4.2.0) + jquery-rails (4.3.5) + rails-dom-testing (>= 1, < 3) + railties (>= 4.2.0) + thor (>= 0.14, < 2.0) + json-schema (2.8.1) + addressable (>= 2.4) + kaminari (1.1.1) + activesupport (>= 4.1.0) + kaminari-actionview (= 1.1.1) + kaminari-activerecord (= 1.1.1) + kaminari-core (= 1.1.1) + kaminari-actionview (1.1.1) + actionview + kaminari-core (= 1.1.1) + kaminari-activerecord (1.1.1) + activerecord + kaminari-core (= 1.1.1) + kaminari-core (1.1.1) + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) + loofah (2.4.0) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) + method_source (0.9.2) + mime-types (3.3) + mime-types-data (~> 3.2015) + mime-types-data (3.2019.1009) + mimemagic (0.3.3) + mini_mime (1.0.2) + mini_portile2 (2.4.0) + minitest (5.13.0) + msgpack (1.3.1) + multipart-post (2.1.1) + net-http-persistent (2.9.4) + nio4r (2.5.2) + nokogiri (1.10.7) + mini_portile2 (~> 2.4.0) + nokogumbo (2.0.2) + nokogiri (~> 1.8, >= 1.8.4) + orm_adapter (0.5.0) + popper_js (1.14.5) + public_suffix (4.0.1) + puma (3.12.2) + rack (2.1.2) + rack-proxy (0.6.5) + rack + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (5.2.4) + actioncable (= 5.2.4) + actionmailer (= 5.2.4) + actionpack (= 5.2.4) + actionview (= 5.2.4) + activejob (= 5.2.4) + activemodel (= 5.2.4) + activerecord (= 5.2.4) + activestorage (= 5.2.4) + activesupport (= 5.2.4) + bundler (>= 1.3.0) + railties (= 5.2.4) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) + railties (5.2.4) + actionpack (= 5.2.4) + activesupport (= 5.2.4) + method_source + rake (>= 0.8.7) + thor (>= 0.19.0, < 2.0) + rake (13.0.1) + rb-fsevent (0.10.3) + rb-inotify (0.10.0) + ffi (~> 1.0) + regexp_parser (1.6.0) + responders (3.0.0) + actionpack (>= 5.0) + railties (>= 5.0) + retriable (3.1.2) + rsolr (2.2.1) + builder (>= 2.1.2) + faraday (>= 0.9.0) + ruby-progressbar (1.10.1) + ruby_dep (1.5.0) + rubyzip (2.0.0) + sanitize (5.1.0) + crass (~> 1.0.2) + nokogiri (>= 1.8.0) + nokogumbo (~> 2.0) + sass (3.7.4) + sass-listen (~> 4.0.0) + sass-listen (4.0.0) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + sass-rails (5.1.0) + railties (>= 5.2.0) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + sassc (2.2.1) + ffi (~> 1.9) + sassc-rails (2.1.2) + railties (>= 4.0.0) + sassc (>= 2.0) + sprockets (> 3.0) + sprockets-rails + tilt + selenium-webdriver (3.142.7) + childprocess (>= 0.5, < 4.0) + rubyzip (>= 1.2.2) + solr_wrapper (2.1.0) + faraday + retriable + ruby-progressbar + rubyzip + spring (2.1.0) + spring-watcher-listen (2.0.1) + listen (>= 2.7, < 4.0) + spring (>= 1.2, < 3.0) + sprockets (3.7.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + sqlite3 (1.3.13) + thor (0.20.3) + thread_safe (0.3.6) + tilt (2.0.10) + turbolinks (5.2.1) + turbolinks-source (~> 5.2) + turbolinks-source (5.2.0) + twitter-typeahead-rails (0.11.1.pre.corejavascript) + actionpack (>= 3.1) + jquery-rails + railties (>= 3.1) + tzinfo (1.2.5) + thread_safe (~> 0.1) + uglifier (4.2.0) + execjs (>= 0.3.0, < 3) + warden (1.2.8) + rack (>= 2.0.6) + web-console (3.7.0) + actionview (>= 5.0) + activemodel (>= 5.0) + bindex (>= 0.4.0) + railties (>= 5.0) + webdrivers (4.2.0) + nokogiri (~> 1.6) + rubyzip (>= 1.3.0) + selenium-webdriver (>= 3.0, < 4.0) + webpacker (4.2.0) + activesupport (>= 4.2) + rack-proxy (>= 0.6.1) + railties (>= 4.2) + websocket-driver (0.7.1) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.4) + xpath (3.2.0) + nokogiri (~> 1.8) + +PLATFORMS + ruby + +DEPENDENCIES + blacklight (= 7.4.1) + blacklight_range_limit + bootsnap (>= 1.1.0) + bootstrap (~> 4.0) + byebug + capybara (>= 2.15) + coffee-rails (~> 4.2) + devise + devise-guests (~> 0.6) + geoblacklight (~> 2.0) + jbuilder (~> 2.5) + jquery-rails + listen (>= 3.0.5, < 3.2) + puma (~> 3.11) + rails (~> 5.2.4) + rsolr (>= 1.0, < 3) + sass-rails (~> 5.0) + solr_wrapper (>= 0.3) + spring + spring-watcher-listen (~> 2.0.0) + sqlite3 (~> 1.3.6) + turbolinks (~> 5) + twitter-typeahead-rails (= 0.11.1.pre.corejavascript) + tzinfo-data + uglifier (>= 1.3.0) + web-console (>= 3.3.0) + webdrivers + webpacker + +BUNDLED WITH + 1.17.3 diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 0d2665f..fba2258 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -23,3 +23,9 @@ //= require blacklight/blacklight //= require_tree . + + +// For blacklight_range_limit built-in JS, if you don't want it you don't need +// this: +//= require 'blacklight_range_limit' + diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 54a07cf..5f9bd94 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -12,7 +12,12 @@ * *= require_tree . *= require_self - */ + + * + * Used by blacklight_range_limit + *= require 'blacklight_range_limit' + * +*/ .navbar-brand { background: none; diff --git a/app/controllers/catalog_controller.rb b/app/controllers/catalog_controller.rb index 6a1508e..dfda8aa 100644 --- a/app/controllers/catalog_controller.rb +++ b/app/controllers/catalog_controller.rb @@ -3,6 +3,8 @@ class CatalogController < ApplicationController + include BlacklightRangeLimit::ControllerOverride + include Blacklight::Catalog configure_blacklight do |config| @@ -92,7 +94,7 @@ class CatalogController < ApplicationController config.add_facet_field Settings.FIELDS.SPATIAL_COVERAGE, :label => 'Place', :limit => 8 config.add_facet_field Settings.FIELDS.PART_OF, :label => 'Collection', :limit => 8 - config.add_facet_field Settings.FIELDS.YEAR, :label => 'Year', :limit => 10 + config.add_facet_field Settings.FIELDS.YEAR, :label => 'Year', :limit => 10, range: true config.add_facet_field Settings.FIELDS.RIGHTS, label: 'Access', limit: 8, partial: "icon_facet" config.add_facet_field Settings.FIELDS.GEOM_TYPE, label: 'Data type', limit: 8, partial: "icon_facet" diff --git a/app/controllers/search_history_controller.rb b/app/controllers/search_history_controller.rb new file mode 100644 index 0000000..83a21bb --- /dev/null +++ b/app/controllers/search_history_controller.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true +class SearchHistoryController < ApplicationController + include Blacklight::SearchHistory + + helper BlacklightRangeLimit::ViewHelperOverride + helper RangeLimitHelper +end diff --git a/app/models/search_builder.rb b/app/models/search_builder.rb index 6a1a76a..19e97fa 100644 --- a/app/models/search_builder.rb +++ b/app/models/search_builder.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true class SearchBuilder < Blacklight::SearchBuilder include Blacklight::Solr::SearchBuilderBehavior + include BlacklightRangeLimit::RangeLimitBuilder + include Geoblacklight::SpatialSearchBehavior ## diff --git a/config/routes.rb b/config/routes.rb index 27b4f19..e200544 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,11 +1,14 @@ Rails.application.routes.draw do + concern :range_searchable, BlacklightRangeLimit::Routes::RangeSearchable.new mount Blacklight::Engine => '/' root to: "catalog#index" concern :searchable, Blacklight::Routes::Searchable.new resource :catalog, only: [:index], as: 'catalog', path: '/catalog', controller: 'catalog' do concerns :searchable + concerns :range_searchable + end devise_for :users concern :exportable, Blacklight::Routes::Exportable.new