blacklight-marc 7.1.0 → 8.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 67e4c2b3e51422a3801fda3a61fe549e73889f43cdee3571c35368f44f10490e
4
- data.tar.gz: dec3a61d6f54c91811d37afa6d9a4462255c224c33d1f7a0448d1de3028161ff
3
+ metadata.gz: 510b8f1ae8d1d7752d0dbeadf0db9e4cc5003d88dd25c7b4a9e76ba1757c2d4e
4
+ data.tar.gz: 61ffc549983a3e3ca3fe0497cfcac437bac64318fba45d7836ad0307d2f1a83a
5
5
  SHA512:
6
- metadata.gz: 57f8a9949505a58970bae0a8aaf9f25a0d46c1d7d80272cf19c8a5ff43aa2833c3676e9f5246dd88c8954d33d6699601ddf463429ae30cb916a762616b7014eb
7
- data.tar.gz: 959d4dae4de2e8f5378cd7379b3863a1ca70408f9d6e0ba95bed151651ec6bc5b4f052167782caf53f3d1c351e6747f68be5841825888a4be724ee3c02ad1330
6
+ metadata.gz: cc9bacb9622c2e4f68f2ff7058d9ce8495e2667ab7b8fae7c5495e571a11e82ccd9699bb73237aad5935f6d47a229e651671158eb22fe686816b14c520adaf09
7
+ data.tar.gz: b8127b909fd370507c3a7a59860ae395abe2f7b23828e18dfae1c54042507ee7c7c8f7b03f7986e58d308f855ca38fad0851b1f93b6d5aab7e3ef31c632555e7
@@ -1,36 +1,24 @@
1
+ ---
1
2
  name: CI
2
3
 
3
4
  on:
4
5
  push:
5
- branches: [ master ]
6
+ branches: [main]
6
7
  pull_request:
7
- branches: [ master ]
8
+ branches: [main]
8
9
 
9
10
  jobs:
10
11
  test:
11
12
  runs-on: ubuntu-latest
12
13
  strategy:
13
14
  matrix:
14
- rails_version: [6.1.1]
15
- ruby: [2.7, 3.0]
16
- env:
17
- RAILS_VERSION: ${{ matrix.rails_version }}
18
- steps:
19
- - uses: actions/checkout@v2
20
- - name: Set up Ruby ${{ matrix.ruby }}
21
- uses: ruby/setup-ruby@v1
22
- with:
23
- ruby-version: ${{ matrix.ruby }}
24
- - name: Install dependencies with Rails ${{ matrix.rails_version }}
25
- run: bundle install
26
- - name: Run tests
27
- run: bundle exec rake
28
- test_rails52:
29
- runs-on: ubuntu-latest
30
- strategy:
31
- matrix:
32
- rails_version: [5.2.4.4, 6.0.3.4]
33
- ruby: [2.7]
15
+ rails_version: [6.1.4.7, 7.0.2.3]
16
+ ruby: [2.7, '3.0']
17
+ include:
18
+ - rails_version: 5.2.4.4
19
+ ruby: 2.7
20
+ - rails_version: 6.0.3.4
21
+ ruby: 2.7
34
22
  env:
35
23
  RAILS_VERSION: ${{ matrix.rails_version }}
36
24
  steps:
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Build Status](https://travis-ci.org/projectblacklight/blacklight-marc.png?branch=master)](https://travis-ci.org/projectblacklight/blacklight-marc)
1
+ ![Build Status](https://github.com/projectblacklight/blacklight-marc/actions/workflows/ruby.yml/badge.svg?branch=main)
2
2
 
3
3
  # Blacklight::Marc
4
4
 
@@ -1,25 +1,14 @@
1
1
  /* border between items on marc view */
2
2
  $marc_item_separator: 1px solid $text-muted !default;
3
3
 
4
- #librarian_view
5
- {
6
- left:-17%;
7
- text-align:left;
8
- top:10%;
9
- width:700px;
10
- }
11
-
12
- #marc_view
13
- {
14
- text-align:left;
15
- /* https://meyerweb.com/eric/thoughts/2010/02/12/fixed-monospace-sizing/ */
16
- font-family: "Courier New", monospace, serif;
17
- font-size: 1em;
4
+ .marc_view {
5
+ font-family: $font-family-monospace;
18
6
 
19
- .field
20
- {
7
+ .field {
8
+ align-items: flex-start;
21
9
  border-bottom: $marc_item_separator;
22
- clear:both;
10
+ display: flex;
11
+ gap: 2em;
23
12
  }
24
13
 
25
14
  .ind1, .ind2
@@ -28,13 +17,7 @@ $marc_item_separator: 1px solid $text-muted !default;
28
17
  padding: 0 ($spacer / 2);
29
18
  }
30
19
 
31
- .subfields
32
- {
33
- padding-left:5em;
34
- }
35
-
36
- .tag_ind
37
- {
38
- float:left;
39
- }
20
+ .tag_ind {
21
+ flex-shrink: 0;
22
+ }
40
23
  }
@@ -9,13 +9,20 @@ module Blacklight::Marc
9
9
  end
10
10
 
11
11
  def librarian_view
12
- @response, deprecated_document = search_service.fetch params[:id]
13
- @document = ActiveSupport::Deprecation::DeprecatedObjectProxy.new(deprecated_document, "The @document instance variable is deprecated and will be removed in Blacklight-marc 8.0")
12
+ if Blacklight::VERSION >= '8'
13
+ @document = search_service.fetch(params[:id])
14
+ @response = ActiveSupport::Deprecation::DeprecatedObjectProxy.new(@document.response, "The @response instance variable is deprecated and will be removed in Blacklight-marc 8.0")
15
+
16
+ else
17
+ deprecated_response, @document = search_service.fetch(params[:id])
18
+ @response = ActiveSupport::Deprecation::DeprecatedObjectProxy.new(deprecated_response, "The @response instance variable is deprecated and will be removed in Blacklight-marc 8.0")
19
+ end
20
+
14
21
  respond_to do |format|
15
22
  format.html do
16
23
  return render layout: false if request.xhr?
17
24
  # Otherwise draw the full page
18
- end
25
+ end
19
26
  end
20
27
  end
21
28
 
@@ -39,4 +39,12 @@ module BlacklightMarcHelper
39
39
  end
40
40
  val
41
41
  end
42
+
43
+ # A URL to refworks export, with an embedded callback URL to this app.
44
+ # the callback URL is to bookmarks#export, which delivers a list of
45
+ # user's bookmarks in 'refworks marc txt' format -- we tell refworks
46
+ # to expect that format.
47
+ def bookmarks_export_url(format, params = {})
48
+ bookmarks_url(params.merge(format: format, encrypted_user_id: encrypt_user_id(current_or_guest_user.id)))
49
+ end
42
50
  end
@@ -1,11 +1,12 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  # -*- coding: utf-8 -*-
3
- # Written for use with Blacklight::Solr::Document::Marc, but you can use
3
+
4
+ # Written for use with Blacklight::Marc::DocumentExtension, but you can use
4
5
  # it for your own custom Blacklight document Marc extension too -- just
5
6
  # include this module in any document extension (or any other class)
6
7
  # that provides a #to_marc returning a ruby-marc object. This module will add
7
8
  # in export_as translation methods for a variety of formats.
8
- module Blacklight::Solr::Document::MarcExport
9
+ module Blacklight::Marc::DocumentExport
9
10
 
10
11
  def self.register_export_formats(document)
11
12
  document.will_export_as(:xml)
@@ -9,7 +9,7 @@
9
9
  # This extension would normally be registered using
10
10
  # Blacklight::Solr::Document#use_extension. eg:
11
11
  #
12
- # SolrDocument.use_extension( Blacklight::Solr::Document::Marc ) { |document| my_logic_for_document_has_marc?( document ) }
12
+ # SolrDocument.use_extension( Blacklight::Marc::DocumentExtension ) { |document| my_logic_for_document_has_marc?( document ) }
13
13
  #
14
14
  # This extension also expects a :marc_source_field and :marc_format_type to
15
15
  # be registered with the hosting classes extension_parameters. In an initializer
@@ -18,15 +18,16 @@
18
18
  # SolrDocument.extension_parameters[:marc_format_type] = :marc21 # or :marcxml
19
19
  require 'marc'
20
20
 
21
- module Blacklight::Solr::Document::Marc
21
+ module Blacklight::Marc
22
+ module DocumentExtension
22
23
 
23
- include Blacklight::Solr::Document::MarcExport # All our export_as stuff based on to_marc.
24
+ include Blacklight::Marc::DocumentExport # All our export_as stuff based on to_marc.
24
25
 
25
26
  class UnsupportedMarcFormatType < RuntimeError; end
26
27
 
27
28
  def self.extended(document)
28
29
  # Register our exportable formats, we inherit these from MarcExport
29
- Blacklight::Solr::Document::MarcExport.register_export_formats( document )
30
+ Blacklight::Marc::DocumentExport.register_export_formats( document )
30
31
  end
31
32
 
32
33
  # ruby-marc object
@@ -59,7 +60,9 @@ module Blacklight::Solr::Document::Marc
59
60
  end
60
61
 
61
62
  def marc_record_from_marcxml
62
- MARC::XMLReader.new(StringIO.new( fetch(_marc_source_field) )).to_a.first
63
+ marcxml = fetch(_marc_source_field)
64
+ marcxml = marcxml.first if marcxml.kind_of? Array
65
+ MARC::XMLReader.new(StringIO.new(marcxml)).to_a.first
63
66
  end
64
67
 
65
68
  def _marc_helper
@@ -76,4 +79,5 @@ module Blacklight::Solr::Document::Marc
76
79
  self.class.extension_parameters[:marc_format_type]
77
80
  end
78
81
 
82
+ end
79
83
  end
@@ -1,32 +1,30 @@
1
- <div id="marc_view" class="modal-body">
2
- <% fields = document.to_marc.find_all{|f| ('000'..'999') === f.tag } %>
1
+ <div id="marc_view" class="marc_view">
3
2
  <div class="field"><%= t('blacklight.search.librarian_view.leader', :leader => document.to_marc.leader) %></div>
4
- <%- fields.each do |field| -%>
5
- <%- unless field.tag.to_s == "940" -%>
3
+ <%- document.to_marc.each do |field| -%>
6
4
  <div class="field">
7
- <div class="tag_ind">
8
- <span class="tag">
9
- <%= h(field.tag) %>
10
- </span>
11
5
  <%- if field.is_a?(MARC::ControlField) -%>
12
- <span class="control_field_values">
13
- <%= h(field.value) %>
14
- </span>
6
+ <div class="tag_ind">
7
+ <span class="tag"><%= field.tag %></span>
8
+ </div>
9
+ <span class="control_field_values">
10
+ <%= h(field.value) %>
11
+ </span>
15
12
  <%- else -%>
13
+ <div class="tag_ind">
14
+ <span class="tag"><%= field.tag %></span>
16
15
  <div class="ind1">
17
- <%= !field.indicator1.blank? ? field.indicator1 : "&nbsp;".html_safe -%>
16
+ <%= field.try(:indicator1).present? ? field.indicator1 : "&nbsp;".html_safe -%>
18
17
  </div>
19
18
  <div class="ind2">
20
- <%= !field.indicator2.blank? ? field.indicator2 : "&nbsp;".html_safe -%>
19
+ <%= field.try(:indicator2).present? ? field.indicator2 : "&nbsp;".html_safe -%>
21
20
  </div>
22
21
  </div>
23
22
  <div class="subfields">
24
23
  <%- field.each do |sub| -%>
25
- <span class="sub_code"><%= h(sub.code) %>|</span> <%= h(sub.value) %>
26
- <%- end -%>
27
- <%- end -%>
24
+ <span class="sub_code"><%= sub.code %>|</span> <%= sub.value %>
25
+ <%- end -%>
28
26
  </div>
27
+ <%- end -%>
29
28
  </div>
30
- <%- end-%>
31
29
  <%- end -%>
32
30
  </div>
@@ -1,13 +1,8 @@
1
-
2
- <div class="modal-header">
3
- <h1 class="modal-title"><%= t('blacklight.search.librarian_view.title') %></h1>
4
- <button type="button" class="blacklight-modal-close close" data-dismiss="modal" aria-label="Close">
5
- <span aria-hidden="true">×</span>
6
- </button>
7
- </div>
8
- <%- if @response.documents.first.respond_to?(:to_marc) -%>
9
- <%= render "marc_view", document: @response.documents.first %>
10
- <%- else %>
11
- <%= t('blacklight.search.librarian_view.empty') %>
12
- <%- end -%>
13
-
1
+ <%= render Blacklight::System::ModalComponent.new do |component| %>
2
+ <% component.title { t('blacklight.search.librarian_view.title') } %>
3
+ <%- if @document.respond_to?(:to_marc) -%>
4
+ <%= render "marc_view", document: @document %>
5
+ <%- else %>
6
+ <%= t('blacklight.search.librarian_view.empty') %>
7
+ <%- end -%>
8
+ <% end %>
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency 'blacklight', '~> 7.0'
21
+ spec.add_dependency 'blacklight', '>= 7.11', '< 9'
22
22
  spec.add_dependency "library_stdnums"
23
23
  spec.add_dependency "rails"
24
24
  spec.add_dependency "marc", ">= 0.4.3", "< 2.0" # Marc record parser.
@@ -1,21 +1,10 @@
1
- require "blacklight/marc"
2
- require "rails"
3
-
4
1
  module Blacklight::Marc
5
2
  class Engine < Rails::Engine
6
- config.autoload_paths += %W(
7
- #{config.root}/app/presenters
8
- #{config.root}/app/controllers/concerns
9
- #{config.root}/app/models/concerns
10
- )
11
-
12
3
  rake_tasks do
13
4
  load "railties/solr_marc.rake"
14
5
  end
15
6
 
16
7
  initializer 'blacklight_marc.initialize' do |app|
17
- require 'blacklight/solr/document'
18
-
19
8
  Mime::Type.register_alias "text/plain", :refworks_marc_txt
20
9
  Mime::Type.register_alias "text/plain", :openurl_kev
21
10
  Mime::Type.register "application/x-endnote-refer", :endnote
@@ -23,6 +12,13 @@ module Blacklight::Marc
23
12
  Mime::Type.register "application/marcxml+xml", :marcxml,
24
13
  ["application/x-marc+xml", "application/x-marcxml+xml",
25
14
  "application/marc+xml"]
15
+
16
+ # these are here for backwards compatibility with the old class names,
17
+ # which zeitwerk didn't care for
18
+ config.after_initialize do
19
+ Blacklight::Solr::Document::Marc = Blacklight::Marc::DocumentExtension
20
+ Blacklight::Solr::Document::MarcExport = Blacklight::Marc::DocumentExport
21
+ end
26
22
  end
27
23
  end
28
24
  end
@@ -1,5 +1,5 @@
1
1
  module Blacklight
2
2
  module Marc
3
- VERSION = '7.1.0'
3
+ VERSION = '8.0.0'
4
4
  end
5
5
  end
@@ -40,11 +40,11 @@ EOF
40
40
  # The following shows how to setup this blacklight document to display marc documents
41
41
  extension_parameters[:marc_source_field] = :marc_ss
42
42
  extension_parameters[:marc_format_type] = :marcxml
43
- use_extension( Blacklight::Solr::Document::Marc) do |document|
44
- document.key?( SolrDocument.extension_parameters[:marc_source_field] )
43
+ use_extension(Blacklight::Marc::DocumentExtension) do |document|
44
+ document.key?(SolrDocument.extension_parameters[:marc_source_field])
45
45
  end
46
-
47
- field_semantics.merge!(
46
+
47
+ field_semantics.merge!(
48
48
  :title => "title_ssm",
49
49
  :author => "author_ssm",
50
50
  :language => "language_ssim",
@@ -17,6 +17,7 @@
17
17
  </updateHandler>
18
18
 
19
19
  <!-- solr lib dirs -->
20
+ <lib dir="${solr.install.dir:../../../..}/modules/analysis-extras/lib" />
20
21
  <lib dir="${solr.install.dir:../../../..}/contrib/analysis-extras/lib" />
21
22
  <lib dir="${solr.install.dir:../../../..}/contrib/analysis-extras/lucene-libs" />
22
23
 
@@ -43,4 +43,11 @@ describe BlacklightMarcHelper do
43
43
  end
44
44
  end
45
45
 
46
+ describe "#bookmarks_export_url" do
47
+ it "is the bookmark url with an encrypted user token" do
48
+ allow(helper).to receive_messages(encrypt_user_id: 'xyz', current_or_guest_user: double(id: 123))
49
+ url = helper.bookmarks_export_url(:html)
50
+ expect(url).to eq helper.bookmarks_url(format: :html, encrypted_user_id: 'xyz')
51
+ end
52
+ end
46
53
  end
@@ -1,2 +1 @@
1
- gem 'blacklight', github: 'projectblacklight/blacklight'
2
1
  gem "traject", '~>3.0'
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- RSpec.describe 'bookmarks/_endnote.html.erb' do
3
+ RSpec.describe 'bookmarks/_endnote' do
4
4
  before do
5
5
  allow(controller).to receive(:blacklight_config)
6
6
  .and_return(CatalogController.blacklight_config)
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- RSpec.describe 'bookmarks/_refworks.html.erb' do
3
+ RSpec.describe 'bookmarks/_refworks' do
4
4
  before do
5
5
  allow(controller).to receive(:blacklight_config)
6
6
  .and_return(CatalogController.blacklight_config)
@@ -29,7 +29,7 @@ describe "catalog/index" do
29
29
  params.merge!( @params )
30
30
  allow(view).to receive(:blacklight_config).and_return(@config)
31
31
  allow(view).to receive(:search_field_options_for_select).and_return([])
32
-
32
+ allow(controller).to receive(:search_state_class).and_return(Blacklight::SearchState)
33
33
  render :template => 'catalog/index', :formats => [:atom]
34
34
 
35
35
  # We need to use rexml to test certain things that have_tag wont' test
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blacklight-marc
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.1.0
4
+ version: 8.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-17 00:00:00.000000000 Z
11
+ date: 2022-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: blacklight
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '7.11'
20
+ - - "<"
18
21
  - !ruby/object:Gem::Version
19
- version: '7.0'
22
+ version: '9'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '7.11'
30
+ - - "<"
25
31
  - !ruby/object:Gem::Version
26
- version: '7.0'
32
+ version: '9'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: library_stdnums
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -227,9 +233,10 @@ files:
227
233
  - README.md
228
234
  - Rakefile
229
235
  - app/assets/stylesheets/blacklight_marc.scss
236
+ - app/controllers/concerns/blacklight/marc/catalog.rb
230
237
  - app/helpers/blacklight_marc_helper.rb
231
- - app/models/concerns/blacklight/solr/document/marc.rb
232
- - app/models/concerns/blacklight/solr/document/marc_export.rb
238
+ - app/models/concerns/blacklight/marc/document_export.rb
239
+ - app/models/concerns/blacklight/marc/document_extension.rb
233
240
  - app/views/bookmarks/_endnote.html.erb
234
241
  - app/views/bookmarks/_marc_tools.html.erb
235
242
  - app/views/bookmarks/_refworks.html.erb
@@ -247,7 +254,6 @@ files:
247
254
  - config/locales/blacklight_marc.pt-BR.yml
248
255
  - config/routes.rb
249
256
  - lib/blacklight/marc.rb
250
- - lib/blacklight/marc/catalog.rb
251
257
  - lib/blacklight/marc/engine.rb
252
258
  - lib/blacklight/marc/indexer.rb
253
259
  - lib/blacklight/marc/indexer/dewey.rb
@@ -310,7 +316,7 @@ homepage: https://github.com/projectblacklight/blacklight-marc
310
316
  licenses:
311
317
  - Apache-2.0
312
318
  metadata: {}
313
- post_install_message:
319
+ post_install_message:
314
320
  rdoc_options: []
315
321
  require_paths:
316
322
  - lib
@@ -325,8 +331,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
325
331
  - !ruby/object:Gem::Version
326
332
  version: '0'
327
333
  requirements: []
328
- rubygems_version: 3.1.2
329
- signing_key:
334
+ rubygems_version: 3.2.32
335
+ signing_key:
330
336
  specification_version: 4
331
337
  summary: MARC support for Blacklight
332
338
  test_files: