Skip to content

Commit

Permalink
Merge pull request #3 from upenn-libraries/rails7
Browse files Browse the repository at this point in the history
Add support for Rails 7 and Blacklight 8.
  • Loading branch information
cgalarza authored Aug 13, 2024
2 parents 3de07a8 + cae8a4b commit d910f08
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ test/dummy/db/*.sqlite3
test/dummy/db/*.sqlite3-journal
test/dummy/log/*.log
test/dummy/tmp/
Gemfile.lock
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ 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:

```ruby
gem 'blacklight-ris', '0.1.0'
gem 'blacklight-ris'
```

And then execute:
Expand All @@ -31,8 +33,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
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/blacklight_ris_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

module Blacklight::Solr::Document::RisFields
module Blacklight::Ris::DocumentFields

extend ActiveSupport::Concern

Expand Down
2 changes: 1 addition & 1 deletion app/views/bookmarks/index.ris.erb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<%= render_ris(@document_list) %>
<%= render_ris(@response.documents) %>
3 changes: 2 additions & 1 deletion blacklight-ris.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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", '>= 7'
s.add_dependency "blacklight", '>= 7'

s.metadata['rubygems_mfa_required'] = 'false'
end
4 changes: 4 additions & 0 deletions config/locales/blacklight_ris.en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
en:
blacklight:
tools:
ris: 'Download in RIS format'
1 change: 0 additions & 1 deletion lib/blacklight/ris.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

require 'blacklight/ris/engine'

module Blacklight
Expand Down
4 changes: 2 additions & 2 deletions lib/blacklight/ris/catalog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ 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: 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

Expand Down
10 changes: 5 additions & 5 deletions lib/blacklight/ris/engine.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Blacklight
module Ris

module Blacklight::Ris
class Engine < ::Rails::Engine
isolate_namespace Blacklight::Ris

Expand All @@ -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
2 changes: 1 addition & 1 deletion lib/blacklight/ris/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Blacklight
module Ris
VERSION = '0.1.0'
VERSION = '0.2.0'
end
end

0 comments on commit d910f08

Please sign in to comment.