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 +4 -4
- data/.github/workflows/ruby.yml +10 -22
- data/README.md +1 -1
- data/app/assets/stylesheets/blacklight_marc.scss +9 -26
- data/{lib → app/controllers/concerns}/blacklight/marc/catalog.rb +10 -3
- data/app/helpers/blacklight_marc_helper.rb +8 -0
- data/app/models/concerns/blacklight/{solr/document/marc_export.rb → marc/document_export.rb} +3 -2
- data/app/models/concerns/blacklight/{solr/document/marc.rb → marc/document_extension.rb} +9 -5
- data/app/views/catalog/_marc_view.html.erb +15 -17
- data/app/views/catalog/librarian_view.html.erb +8 -13
- data/blacklight-marc.gemspec +1 -1
- data/lib/blacklight/marc/engine.rb +7 -11
- data/lib/blacklight/marc/version.rb +1 -1
- data/lib/generators/blacklight/marc/install_generator.rb +4 -4
- data/solr/conf/solrconfig.xml +1 -0
- data/spec/helpers/blacklight_marc_helper_spec.rb +7 -0
- data/spec/test_app_templates/Gemfile.extra +0 -1
- data/spec/views/bookmarks/_endnote.html.erb_spec.rb +1 -1
- data/spec/views/bookmarks/_refworks.html.erb_spec.rb +1 -1
- data/spec/views/catalog/index.atom.builder_spec.rb +1 -1
- metadata +19 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 510b8f1ae8d1d7752d0dbeadf0db9e4cc5003d88dd25c7b4a9e76ba1757c2d4e
|
4
|
+
data.tar.gz: 61ffc549983a3e3ca3fe0497cfcac437bac64318fba45d7836ad0307d2f1a83a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc9bacb9622c2e4f68f2ff7058d9ce8495e2667ab7b8fae7c5495e571a11e82ccd9699bb73237aad5935f6d47a229e651671158eb22fe686816b14c520adaf09
|
7
|
+
data.tar.gz: b8127b909fd370507c3a7a59860ae395abe2f7b23828e18dfae1c54042507ee7c7c8f7b03f7986e58d308f855ca38fad0851b1f93b6d5aab7e3ef31c632555e7
|
data/.github/workflows/ruby.yml
CHANGED
@@ -1,36 +1,24 @@
|
|
1
|
+
---
|
1
2
|
name: CI
|
2
3
|
|
3
4
|
on:
|
4
5
|
push:
|
5
|
-
branches: [
|
6
|
+
branches: [main]
|
6
7
|
pull_request:
|
7
|
-
branches: [
|
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.
|
15
|
-
ruby: [2.7, 3.0]
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
32
|
-
|
33
|
-
|
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
|
-
|
13
|
-
|
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
|
data/app/models/concerns/blacklight/{solr/document/marc_export.rb → marc/document_export.rb}
RENAMED
@@ -1,11 +1,12 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
# -*- coding: utf-8 -*-
|
3
|
-
|
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::
|
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::
|
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::
|
21
|
+
module Blacklight::Marc
|
22
|
+
module DocumentExtension
|
22
23
|
|
23
|
-
include Blacklight::
|
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::
|
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
|
-
|
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="
|
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
|
-
<%-
|
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
|
-
|
13
|
-
|
14
|
-
|
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
|
-
<%=
|
16
|
+
<%= field.try(:indicator1).present? ? field.indicator1 : " ".html_safe -%>
|
18
17
|
</div>
|
19
18
|
<div class="ind2">
|
20
|
-
<%=
|
19
|
+
<%= field.try(:indicator2).present? ? field.indicator2 : " ".html_safe -%>
|
21
20
|
</div>
|
22
21
|
</div>
|
23
22
|
<div class="subfields">
|
24
23
|
<%- field.each do |sub| -%>
|
25
|
-
<span class="sub_code"><%=
|
26
|
-
|
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
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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 %>
|
data/blacklight-marc.gemspec
CHANGED
@@ -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', '
|
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
|
@@ -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(
|
44
|
-
document.key?(
|
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",
|
data/solr/conf/solrconfig.xml
CHANGED
@@ -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
|
@@ -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:
|
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:
|
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: '
|
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: '
|
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/
|
232
|
-
- app/models/concerns/blacklight/
|
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.
|
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:
|