From 029144b03a5f0319e5ca7c0664906b38c3235451 Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Tue, 21 Nov 2023 08:46:33 -0800 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=8E=81=20make=20facet=20options=20mat?= =?UTF-8?q?ch=20adventist-dl=20proper?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Deletes the default hyku proper facets and use the adventist proper's settings instead, for feature parity with the original application. Issue: - https://github.com/scientist-softserv/adventist-dl/issues/659 --- .../catalog_controller_decorator.rb | 31 ++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/app/controllers/catalog_controller_decorator.rb b/app/controllers/catalog_controller_decorator.rb index 4379bb76..b52c1565 100644 --- a/app/controllers/catalog_controller_decorator.rb +++ b/app/controllers/catalog_controller_decorator.rb @@ -6,9 +6,23 @@ # Use locally customized AdvSearchBuilder so we can enable blacklight_advanced_search config.search_builder_class = AdvSearchBuilder + # Delete Hyku's default settings + config.facet_fields.delete('human_readable_type_sim') + config.facet_fields.delete('resource_type_sim') + config.facet_fields.delete('creator_sim') + config.facet_fields.delete('contributor_sim') + config.facet_fields.delete('keyword_sim') + config.facet_fields.delete('subject_sim') + config.facet_fields.delete('language_sim') + config.facet_fields.delete('based_near_label_sim') + config.facet_fields.delete('publisher_sim') + config.facet_fields.delete('file_format_sim') + config.facet_fields.delete('member_of_collections_ssim') + # solr fields that will be treated as facets by the blacklight application # The ordering of the field names is the order of the display config.add_facet_field 'source_sim', label: 'Source', limit: 5, collapse: false, helper_method: :iconify_auto_link + config.add_facet_field 'human_readable_type_sim', label: "Type", limit: 5, collapse: false config.add_facet_field( 'sorted_year_isi', label: 'Date Range', @@ -22,17 +36,18 @@ }, facet_field_label: 'Date Range' ) - - # Delete Hyku version so we can add the Author label - config.facet_fields.delete('creator_sim') + config.add_facet_field 'resource_type_sim', label: "Resource Type", limit: 5 config.add_facet_field 'creator_sim', label: "Author", limit: 5 - - # Delete default Hyku facets that are no applicable for this Knapsack - config.facet_fields.delete('contributor_sim') - config.facet_fields.delete('file_format_sim') - + config.add_facet_field 'publisher_sim', limit: 5 + config.add_facet_field 'keyword_sim', limit: 5 + config.add_facet_field 'subject_sim', limit: 5 + config.add_facet_field 'language_sim', limit: 5 + config.add_facet_field 'based_near_label_sim', limit: 5 config.add_facet_field 'part_sim', limit: 5, label: 'Part' config.add_facet_field 'part_of_sim', limit: 5 + # config.add_facet_field 'file_format_sim', limit: 5 + # config.add_facet_field 'contributor_sim', label: "Contributor", limit: 5 + config.add_facet_field 'member_of_collections_ssim', limit: 5, label: 'Collections' config.add_facet_field 'refereed_sim', limit: 5 # Clobber all existing index and show fields that come from Hyku base but skip From ab743a395af0c80c1c913ec8388653c70acf2992 Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Tue, 21 Nov 2023 10:51:09 -0800 Subject: [PATCH 2/3] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20dynamically=20delete?= =?UTF-8?q?=20Hyku's=20default=20facet=20settings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously this was hardcoded but what if Hyku changes? This commit implements a dynamic method to delete hyku's default settings. --- .../catalog_controller_decorator.rb | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/app/controllers/catalog_controller_decorator.rb b/app/controllers/catalog_controller_decorator.rb index b52c1565..a6ca48ff 100644 --- a/app/controllers/catalog_controller_decorator.rb +++ b/app/controllers/catalog_controller_decorator.rb @@ -2,22 +2,19 @@ CatalogController.include DogBiscuits::Blacklight::Commands +def delete_default_facet_fields(config) + default_facet_field_keys = CatalogController.configure_blacklight.facet_fields.keys + default_facet_field_keys.each do |key| + config.facet_fields.delete(key) + end +end + CatalogController.configure_blacklight do |config| # Use locally customized AdvSearchBuilder so we can enable blacklight_advanced_search config.search_builder_class = AdvSearchBuilder # Delete Hyku's default settings - config.facet_fields.delete('human_readable_type_sim') - config.facet_fields.delete('resource_type_sim') - config.facet_fields.delete('creator_sim') - config.facet_fields.delete('contributor_sim') - config.facet_fields.delete('keyword_sim') - config.facet_fields.delete('subject_sim') - config.facet_fields.delete('language_sim') - config.facet_fields.delete('based_near_label_sim') - config.facet_fields.delete('publisher_sim') - config.facet_fields.delete('file_format_sim') - config.facet_fields.delete('member_of_collections_ssim') + delete_default_facet_fields(config) # solr fields that will be treated as facets by the blacklight application # The ordering of the field names is the order of the display From bfdb613c9f62dabf6c091a314c25851303a44493 Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Tue, 21 Nov 2023 13:54:27 -0800 Subject: [PATCH 3/3] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Replace=20delete=20met?= =?UTF-8?q?hod=20with=20clear?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ruby has a method called #clear that will clear the hash, which is basically what the method was previously doing but much more efficiently. --- app/controllers/catalog_controller_decorator.rb | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/app/controllers/catalog_controller_decorator.rb b/app/controllers/catalog_controller_decorator.rb index a6ca48ff..fcb1fc53 100644 --- a/app/controllers/catalog_controller_decorator.rb +++ b/app/controllers/catalog_controller_decorator.rb @@ -2,19 +2,12 @@ CatalogController.include DogBiscuits::Blacklight::Commands -def delete_default_facet_fields(config) - default_facet_field_keys = CatalogController.configure_blacklight.facet_fields.keys - default_facet_field_keys.each do |key| - config.facet_fields.delete(key) - end -end - CatalogController.configure_blacklight do |config| # Use locally customized AdvSearchBuilder so we can enable blacklight_advanced_search config.search_builder_class = AdvSearchBuilder # Delete Hyku's default settings - delete_default_facet_fields(config) + config.facet_fields.clear # solr fields that will be treated as facets by the blacklight application # The ordering of the field names is the order of the display