From 7b8570c8ab8746fd7fea4120a7b7764dfd0292bb Mon Sep 17 00:00:00 2001 From: David Kinzer Date: Wed, 15 May 2024 09:33:16 -0400 Subject: [PATCH 1/5] Update for rails 7. * Fixes zeitwerk not autoloading classes in rails 7. * Fixes undefined add_show_tools_partial when included. --- .gitignore | 1 + README.md | 4 ++-- .../document/ris_export.rb => ris/document_export.rb} | 2 +- .../document/ris_fields.rb => ris/document_fields.rb} | 2 +- blacklight-ris.gemspec | 3 ++- lib/blacklight/ris.rb | 1 - lib/blacklight/ris/catalog.rb | 2 +- lib/blacklight/ris/engine.rb | 10 +++++----- lib/blacklight/ris/version.rb | 2 +- 9 files changed, 14 insertions(+), 13 deletions(-) rename app/models/concerns/blacklight/{solr/document/ris_export.rb => ris/document_export.rb} (94%) rename app/models/concerns/blacklight/{solr/document/ris_fields.rb => ris/document_fields.rb} (75%) diff --git a/.gitignore b/.gitignore index 71f82cb..72ed05f 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ test/dummy/db/*.sqlite3 test/dummy/db/*.sqlite3-journal test/dummy/log/*.log test/dummy/tmp/ +Gemfile.lock diff --git a/README.md b/README.md index ddfc0dd..00abf21 100644 --- a/README.md +++ b/README.md @@ -31,8 +31,8 @@ class SolrDocument # ...existing code... - include Blacklight::Solr::Document::RisFields - use_extension(Blacklight::Solr::Document::RisExport) + include Blacklight::Ris::DocumentFields + use_extension(Blacklight::Ris:DocumentExport) ris_field_mappings.merge!( # Procs are evaluated in context of SolrDocument instance diff --git a/app/models/concerns/blacklight/solr/document/ris_export.rb b/app/models/concerns/blacklight/ris/document_export.rb similarity index 94% rename from app/models/concerns/blacklight/solr/document/ris_export.rb rename to app/models/concerns/blacklight/ris/document_export.rb index e944f96..4dd9425 100644 --- a/app/models/concerns/blacklight/solr/document/ris_export.rb +++ b/app/models/concerns/blacklight/ris/document_export.rb @@ -1,5 +1,5 @@ -module Blacklight::Solr::Document::RisExport +module Blacklight::Ris::DocumentExport def self.extended(document) document.will_export_as(:ris, 'application/x-research-info-systems') diff --git a/app/models/concerns/blacklight/solr/document/ris_fields.rb b/app/models/concerns/blacklight/ris/document_fields.rb similarity index 75% rename from app/models/concerns/blacklight/solr/document/ris_fields.rb rename to app/models/concerns/blacklight/ris/document_fields.rb index 08b09b9..51ce351 100644 --- a/app/models/concerns/blacklight/solr/document/ris_fields.rb +++ b/app/models/concerns/blacklight/ris/document_fields.rb @@ -1,5 +1,5 @@ -module Blacklight::Solr::Document::RisFields +module Blacklight::Ris::DocumentFields extend ActiveSupport::Concern diff --git a/blacklight-ris.gemspec b/blacklight-ris.gemspec index a66b055..9935d3c 100644 --- a/blacklight-ris.gemspec +++ b/blacklight-ris.gemspec @@ -16,7 +16,8 @@ Gem::Specification.new do |s| s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"] - s.add_dependency "rails", "> 4.2" + s.add_dependency "rails" + s.add_dependency "blacklight" s.metadata['rubygems_mfa_required'] = 'false' end diff --git a/lib/blacklight/ris.rb b/lib/blacklight/ris.rb index d32912a..1bc0c44 100644 --- a/lib/blacklight/ris.rb +++ b/lib/blacklight/ris.rb @@ -1,4 +1,3 @@ - require 'blacklight/ris/engine' module Blacklight diff --git a/lib/blacklight/ris/catalog.rb b/lib/blacklight/ris/catalog.rb index 0de0c3d..1a4b3bd 100644 --- a/lib/blacklight/ris/catalog.rb +++ b/lib/blacklight/ris/catalog.rb @@ -7,7 +7,7 @@ module Catalog included do # this also causes Blacklight's show endpoint to handle .ris - add_show_tools_partial(:ris, label: 'Download in RIS format', if: :render_ris_action?, modal: false, path: :ris_path) + blacklight_config.add_show_tools_partial(:ris, label: 'Download in RIS format', if: :render_ris_action?, modal: false, path: :ris_path) end private diff --git a/lib/blacklight/ris/engine.rb b/lib/blacklight/ris/engine.rb index 1a22a7f..e2dddde 100644 --- a/lib/blacklight/ris/engine.rb +++ b/lib/blacklight/ris/engine.rb @@ -1,5 +1,5 @@ -module Blacklight - module Ris + +module Blacklight::Ris class Engine < ::Rails::Engine isolate_namespace Blacklight::Ris @@ -8,9 +8,9 @@ class Engine < ::Rails::Engine end initializer 'blacklight-ris.helpers' do |app| - ActionView::Base.send :include, BlacklightRisHelper + config.after_initialize do + ActionView::Base.include BlacklightRisHelper + end end - end - end end diff --git a/lib/blacklight/ris/version.rb b/lib/blacklight/ris/version.rb index ebb1663..2a1ad35 100644 --- a/lib/blacklight/ris/version.rb +++ b/lib/blacklight/ris/version.rb @@ -1,5 +1,5 @@ module Blacklight module Ris - VERSION = '0.1.0' + VERSION = '0.2.0' end end From 834231f3d57c412e1f04150ddb2d465948bf31da Mon Sep 17 00:00:00 2001 From: Nikitas Tampakis Date: Thu, 8 Aug 2024 23:22:55 -0400 Subject: [PATCH 2/5] replace deprecated document_list for bl 8, better ris format paths --- app/helpers/blacklight_ris_helper.rb | 4 ++-- app/views/bookmarks/index.ris.erb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/helpers/blacklight_ris_helper.rb b/app/helpers/blacklight_ris_helper.rb index a1979b5..a0993ee 100644 --- a/app/helpers/blacklight_ris_helper.rb +++ b/app/helpers/blacklight_ris_helper.rb @@ -4,9 +4,9 @@ module BlacklightRisHelper # this helper is called from the Show view and Bookmarks view def ris_path(opts = {}) if controller_name == "bookmarks" - bookmarks_path(opts.merge(format: 'ris')) + bookmarks_path(format: 'ris') else - solr_document_path(opts.merge(format: 'ris')) + solr_document_path(format: 'ris') end end diff --git a/app/views/bookmarks/index.ris.erb b/app/views/bookmarks/index.ris.erb index 2cce89e..3646629 100644 --- a/app/views/bookmarks/index.ris.erb +++ b/app/views/bookmarks/index.ris.erb @@ -1 +1 @@ -<%= render_ris(@document_list) %> \ No newline at end of file +<%= render_ris(@response.documents) %> \ No newline at end of file From 92216a14944460e41ce208b9997cedc64b0a56dd Mon Sep 17 00:00:00 2001 From: Nikitas Tampakis Date: Fri, 9 Aug 2024 15:13:09 -0400 Subject: [PATCH 3/5] allow bookmark link to render without extra catalog controller config --- config/locales/blacklight_ris.en.yml | 4 ++++ lib/blacklight/ris/catalog.rb | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 config/locales/blacklight_ris.en.yml diff --git a/config/locales/blacklight_ris.en.yml b/config/locales/blacklight_ris.en.yml new file mode 100644 index 0000000..da43362 --- /dev/null +++ b/config/locales/blacklight_ris.en.yml @@ -0,0 +1,4 @@ +en: + blacklight: + tools: + ris: 'Download in RIS format' \ No newline at end of file diff --git a/lib/blacklight/ris/catalog.rb b/lib/blacklight/ris/catalog.rb index 1a4b3bd..e806f95 100644 --- a/lib/blacklight/ris/catalog.rb +++ b/lib/blacklight/ris/catalog.rb @@ -7,13 +7,13 @@ module Catalog included do # this also causes Blacklight's show endpoint to handle .ris - blacklight_config.add_show_tools_partial(:ris, label: 'Download in RIS format', if: :render_ris_action?, modal: false, path: :ris_path) + blacklight_config.add_show_tools_partial(:ris, label: I18n.t('blacklight.tools.ris'), if: :render_ris_action?, modal: false, path: :ris_path) end private def render_ris_action? config, options = {} - doc = options[:document] || (options[:document_list] || []).first + doc = options[:document] || (@response.documents || []).first doc && doc.respond_to?(:export_formats) && doc.export_formats.keys.include?(:ris ) end From db90097bddcdb39c2486c57925b63fdeb90404c3 Mon Sep 17 00:00:00 2001 From: Carla Galarza Date: Mon, 12 Aug 2024 13:44:02 -0400 Subject: [PATCH 4/5] Pinning to Blacklight >= 7 and Rails >= 7. Though untested with Blacklight 7, we think it might be compatible. --- README.md | 2 ++ blacklight-ris.gemspec | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 00abf21..94b6c15 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,8 @@ Blacklight plugin that adds the ability to download a [RIS representation](https ### Versioning `v0.1.0` -> Known to work with Blacklight v6 and Rails 4 +`v0.2.0` -> Known to work with Blacklight v8 and Rails 7 (untested with Blacklight v7 but might work) + ## Installation Add this line to your application's Gemfile: diff --git a/blacklight-ris.gemspec b/blacklight-ris.gemspec index 9935d3c..5e3fa59 100644 --- a/blacklight-ris.gemspec +++ b/blacklight-ris.gemspec @@ -16,8 +16,8 @@ Gem::Specification.new do |s| s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"] - s.add_dependency "rails" - s.add_dependency "blacklight" + s.add_dependency "rails", '>= 7' + s.add_dependency "blacklight", '>= 7' s.metadata['rubygems_mfa_required'] = 'false' end From cae8a4bbd6faf7880e7b50c47306574cda449d86 Mon Sep 17 00:00:00 2001 From: Carla Galarza Date: Tue, 13 Aug 2024 09:48:32 -0400 Subject: [PATCH 5/5] Not pinning gem in README instructions --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 94b6c15..b390d68 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Blacklight plugin that adds the ability to download a [RIS representation](https Add this line to your application's Gemfile: ```ruby -gem 'blacklight-ris', '0.1.0' +gem 'blacklight-ris' ``` And then execute: