blacklight-marc 8.0.0 → 8.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +19 -8
- data/README.md +1 -1
- data/app/helpers/blacklight_marc_helper.rb +2 -2
- data/app/models/concerns/blacklight/marc/document_export.rb +11 -3
- data/app/views/catalog/librarian_view.html.erb +1 -1
- data/lib/blacklight/marc/version.rb +1 -1
- data/lib/railties/solr_marc.rake +2 -2
- data/spec/features/record_view_spec.rb +5 -0
- data/spec/helpers/blacklight_marc_helper_spec.rb +0 -19
- data/spec/models/concerns/blacklight/marc/document_export_spec.rb +63 -0
- data/spec/support/controller_level_helpers.rb +1 -3
- data/spec/test_app_templates/Gemfile.extra +6 -0
- metadata +5 -5
- data/spec/views/catalog/_document_action.html.erb_spec.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23e9d46508c9e92c90ad0f589728440809b003db1ada7744b35961d393a7b17d
|
4
|
+
data.tar.gz: a7760905d39e8540bf22a6adb5ce6883de27c02796569f2469b1c3008d52e89a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c80948cb35c420f12a658f36084856113d5e240843fc78534b45f678985000b19b3d16830d2660edbfebd9a7fdb6ea9cc31089fe5d2885c7d47628b5dea7ffab
|
7
|
+
data.tar.gz: f5909facef040f97f73d2071876e2c93a1cdb2cdbae2da9985b4e074780eb0fda021fdc902e7fcb8617387861c37d59d8340de5fc0fc562bfdf9715ce0b49260
|
data/.github/workflows/ruby.yml
CHANGED
@@ -1,26 +1,37 @@
|
|
1
|
-
---
|
2
1
|
name: CI
|
3
2
|
|
4
3
|
on:
|
5
4
|
push:
|
6
|
-
branches: [main]
|
5
|
+
branches: [ main ]
|
7
6
|
pull_request:
|
8
|
-
branches: [main]
|
7
|
+
branches: [ main ]
|
9
8
|
|
10
9
|
jobs:
|
11
10
|
test:
|
12
11
|
runs-on: ubuntu-latest
|
12
|
+
continue-on-error: ${{ matrix.experimental }}
|
13
13
|
strategy:
|
14
14
|
matrix:
|
15
|
-
rails_version: [6.1.4.7, 7.0.2.3]
|
16
15
|
ruby: [2.7, '3.0']
|
16
|
+
rails_version: ['6.1.7', '7.0.4']
|
17
|
+
blacklight_version: ['~> 7.0']
|
18
|
+
experimental: [false]
|
17
19
|
include:
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
- ruby: '3.1'
|
21
|
+
rails_version: '7.0.4'
|
22
|
+
blacklight_version: '~> 7.0'
|
23
|
+
experimental: false
|
24
|
+
- ruby: '3.1'
|
25
|
+
rails_version: '7.0.4'
|
26
|
+
blacklight_version: '8.0.0.beta4'
|
27
|
+
experimental: false
|
28
|
+
- ruby: '3.1'
|
29
|
+
rails_version: '7.0.4'
|
30
|
+
blacklight_version: 'github'
|
31
|
+
experimental: true
|
22
32
|
env:
|
23
33
|
RAILS_VERSION: ${{ matrix.rails_version }}
|
34
|
+
BLACKLIGHT_VERSION: ${{ matrix.blacklight_version }}
|
24
35
|
steps:
|
25
36
|
- uses: actions/checkout@v2
|
26
37
|
- name: Set up Ruby ${{ matrix.ruby }}
|
data/README.md
CHANGED
@@ -35,7 +35,7 @@ include Blacklight::Marc::Catalog
|
|
35
35
|
and the following code is generated into SolrDocument:
|
36
36
|
|
37
37
|
```ruby
|
38
|
-
use_extension( Blacklight::
|
38
|
+
use_extension( Blacklight::Marc::DocumentExtension) do |document|
|
39
39
|
document.key?( :marc_display )
|
40
40
|
end
|
41
41
|
```
|
@@ -12,8 +12,8 @@ module BlacklightMarcHelper
|
|
12
12
|
end
|
13
13
|
|
14
14
|
# For exporting a single endnote document. (endnote_catalog_path is defined by blacklight-marc and it is used for multiple document export)
|
15
|
-
def single_endnote_catalog_path opts = {},
|
16
|
-
solr_document_path(opts.merge(format: 'endnote'))
|
15
|
+
def single_endnote_catalog_path opts = {}, **kwargs
|
16
|
+
solr_document_path(opts['id'], **kwargs.merge(opts).merge(format: 'endnote').except('id'))
|
17
17
|
end
|
18
18
|
|
19
19
|
|
@@ -299,6 +299,10 @@ module Blacklight::Marc::DocumentExport
|
|
299
299
|
pub_info << clean_end_punctuation(marc["260"]["a"]).strip if marc["260"]["a"]
|
300
300
|
pub_info << ": #{clean_end_punctuation(marc["260"]["b"]).strip}" if marc["260"]["b"]
|
301
301
|
pub_info << ", #{setup_pub_date(marc)}" if marc["260"]["c"]
|
302
|
+
elsif marc["264"] and (marc["264"]["a"] or marc["264"]["b"])
|
303
|
+
pub_info << clean_end_punctuation(marc["264"]["a"]).strip if marc["264"]["a"]
|
304
|
+
pub_info << ": #{clean_end_punctuation(marc["264"]["b"]).strip}" if marc["264"]["b"]
|
305
|
+
pub_info << ", #{setup_pub_date(marc)}" if marc["264"]["c"]
|
302
306
|
elsif marc["502"] and marc["502"]["a"] # MARC 502 is the Dissertation Note. This holds the correct pub info for these types of records.
|
303
307
|
pub_info << marc["502"]["a"]
|
304
308
|
elsif marc["502"] and (marc["502"]["b"] or marc["502"]["c"] or marc["502"]["d"]) #sometimes the dissertation note is encoded in pieces in the $b $c and $d sub fields instead of lumped into the $a
|
@@ -414,8 +418,8 @@ module Blacklight::Marc::DocumentExport
|
|
414
418
|
text
|
415
419
|
end
|
416
420
|
def setup_pub_date(record)
|
417
|
-
if !record.find{|f| f.tag
|
418
|
-
pub_date = record.find{|f| f.tag
|
421
|
+
if !record.find{|f| ['260', '264'].include?(f.tag)}.nil?
|
422
|
+
pub_date = record.find{|f| ['260', '264'].include?(f.tag)}
|
419
423
|
if pub_date.find{|s| s.code == 'c'}
|
420
424
|
date_value = pub_date.find{|s| s.code == 'c'}.value.gsub(/[^0-9|n\.d\.]/, "")[0,4] unless pub_date.find{|s| s.code == 'c'}.value.gsub(/[^0-9|n\.d\.]/, "")[0,4].blank?
|
421
425
|
end
|
@@ -425,7 +429,7 @@ module Blacklight::Marc::DocumentExport
|
|
425
429
|
end
|
426
430
|
def setup_pub_info(record)
|
427
431
|
text = ''
|
428
|
-
pub_info_field = record
|
432
|
+
pub_info_field = get_publication_data(record)
|
429
433
|
if !pub_info_field.nil?
|
430
434
|
a_pub_info = pub_info_field.find{|s| s.code == 'a'}
|
431
435
|
b_pub_info = pub_info_field.find{|s| s.code == 'b'}
|
@@ -551,6 +555,10 @@ module Blacklight::Marc::DocumentExport
|
|
551
555
|
{:primary_authors => primary_authors, :translators => translators, :editors => editors, :compilers => compilers}
|
552
556
|
end
|
553
557
|
|
558
|
+
def get_publication_data(record)
|
559
|
+
publication_data = record.find{|field| field.tag == '260'} || record.find{|field| field.tag == '264'}
|
560
|
+
end
|
561
|
+
|
554
562
|
def abbreviate_name(name)
|
555
563
|
name_parts = name.split(", ")
|
556
564
|
first_name_parts = name_parts.last.split(" ")
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<%= render Blacklight::System::ModalComponent.new do |component| %>
|
2
|
-
<% component.
|
2
|
+
<% component.with_title { t('blacklight.search.librarian_view.title') } %>
|
3
3
|
<%- if @document.respond_to?(:to_marc) -%>
|
4
4
|
<%= render "marc_view", document: @document %>
|
5
5
|
<%- else %>
|
data/lib/railties/solr_marc.rake
CHANGED
@@ -106,7 +106,7 @@ def compute_arguments
|
|
106
106
|
File.join( plugin_site_path, "config-#{::Rails.env}.properties"),
|
107
107
|
File.join( plugin_site_path, "config.properties"),
|
108
108
|
].each do |file_path|
|
109
|
-
if File.
|
109
|
+
if File.exist?(file_path)
|
110
110
|
arguments[:config_properties_path] = file_path
|
111
111
|
break
|
112
112
|
end
|
@@ -147,7 +147,7 @@ def locate_path(*subpath_fragments)
|
|
147
147
|
local_root = File.expand_path File.join(File.dirname(__FILE__), '..', '..')
|
148
148
|
subpath = subpath_fragments.join('/')
|
149
149
|
base_match = [Rails.root, local_root].find do |base|
|
150
|
-
File.
|
150
|
+
File.exist? File.join(base, subpath)
|
151
151
|
end
|
152
152
|
File.join(base_match.to_s, subpath) if base_match
|
153
153
|
end
|
@@ -9,5 +9,10 @@ describe "Record View" do
|
|
9
9
|
link = find_link("Export to Refworks")
|
10
10
|
expect(link['href']).to include CGI.escape(solr_document_path('2008305903', format: :refworks_marc_txt))
|
11
11
|
end
|
12
|
+
|
13
|
+
it 'has an endnote link' do
|
14
|
+
visit solr_document_path('2008305903')
|
15
|
+
expect(page).to have_link "Export to EndNote", href: solr_document_path('2008305903', format: :endnote)
|
16
|
+
end
|
12
17
|
end
|
13
18
|
end
|
@@ -23,25 +23,6 @@ describe BlacklightMarcHelper do
|
|
23
23
|
expect(helper.render_endnote_texts([one, two])).to eq "one\ntwo\n"
|
24
24
|
end
|
25
25
|
end
|
26
|
-
require 'spec_helper'
|
27
|
-
|
28
|
-
describe '#document_action_path' do
|
29
|
-
before do
|
30
|
-
allow(helper).to receive_messages(controller_name: 'catalog')
|
31
|
-
end
|
32
|
-
|
33
|
-
let(:document_action_config) { Blacklight::Configuration::ToolConfig.new(tool_config) }
|
34
|
-
let(:document) { SolrDocument.new(id: '123') }
|
35
|
-
|
36
|
-
subject { helper.document_action_path(document_action_config, id: document) }
|
37
|
-
|
38
|
-
context "for endnote" do
|
39
|
-
let(:tool_config) { { if: :render_refworks_action?, partial: "document_action",
|
40
|
-
name: :endnote, key: :endnote, path: :single_endnote_catalog_path } }
|
41
|
-
|
42
|
-
it { is_expected.to eq '/catalog/123.endnote' }
|
43
|
-
end
|
44
|
-
end
|
45
26
|
|
46
27
|
describe "#bookmarks_export_url" do
|
47
28
|
it "is the bookmark url with an encrypted user token" do
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class MockClass260
|
4
|
+
include Blacklight::Marc::DocumentExport
|
5
|
+
|
6
|
+
def to_marc
|
7
|
+
fields = [
|
8
|
+
{ "100" => { "subfields" => [{ "a" => "Borja, Ronaldo I." }]}},
|
9
|
+
{ "245" => { "ind1" => " ", "ind2" => " ", "subfields" => [{ "a" => "Plasticity : ", "b" => "modeling & computation /", "c" => "Ronaldo I. Borja." }] } },
|
10
|
+
{ "260" => { "ind1" => " ", "ind2" => " ", "subfields" => [{ "a" => "Berlin :", "b" => "Springer,", "c" => "[2013]" }] } }
|
11
|
+
]
|
12
|
+
MARC::Record.new_from_hash('fields' => fields)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class MockClass264
|
17
|
+
include Blacklight::Marc::DocumentExport
|
18
|
+
|
19
|
+
def to_marc
|
20
|
+
fields = [
|
21
|
+
{ "100" => { "subfields" => [{ "a" => "Borja, Ronaldo I." }]}},
|
22
|
+
{ "245" => { "ind1" => " ", "ind2" => " ", "subfields" => [{ "a" => "Plasticity : ", "b" => "modeling & computation /", "c" => "Ronaldo I. Borja." }] } },
|
23
|
+
{ "264" => { "ind1" => " ", "ind2" => " ", "subfields" => [{ "a" => "Berlin :", "b" => "Springer,", "c" => "[2013]" }] } }
|
24
|
+
]
|
25
|
+
MARC::Record.new_from_hash('fields' => fields)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
RSpec.describe Blacklight::Marc::DocumentExport do
|
30
|
+
describe 'export citiations from 260 field' do
|
31
|
+
it 'exports citations in apa format' do
|
32
|
+
expect(MockClass260.new.export_as_apa_citation_txt).to include('(2013)')
|
33
|
+
expect(MockClass260.new.export_as_apa_citation_txt).to include('Berlin: Springer.')
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'exports citations in mla format' do
|
37
|
+
expect(MockClass260.new.export_as_mla_citation_txt).to include('2013.')
|
38
|
+
expect(MockClass260.new.export_as_mla_citation_txt).to include('Berlin: Springer,')
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'exports citations in Chicago format' do
|
42
|
+
expect(MockClass260.new.export_as_chicago_citation_txt).to include('2013.')
|
43
|
+
expect(MockClass260.new.export_as_chicago_citation_txt).to include('Berlin: Springer,')
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'export citations from 264 field' do
|
48
|
+
it 'exports citations in apa format' do
|
49
|
+
expect(MockClass264.new.export_as_apa_citation_txt).to include('(2013)')
|
50
|
+
expect(MockClass264.new.export_as_apa_citation_txt).to include('Berlin: Springer.')
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'exports citations in mla format' do
|
54
|
+
expect(MockClass264.new.export_as_mla_citation_txt).to include('2013.')
|
55
|
+
expect(MockClass264.new.export_as_mla_citation_txt).to include('Berlin: Springer,')
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'exports citations in Chicago format' do
|
59
|
+
expect(MockClass264.new.export_as_chicago_citation_txt).to include('2013.')
|
60
|
+
expect(MockClass264.new.export_as_chicago_citation_txt).to include('Berlin: Springer,')
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -1,7 +1,5 @@
|
|
1
1
|
module ControllerLevelHelpers
|
2
2
|
module ControllerViewHelpers
|
3
|
-
include Blacklight::Facet
|
4
|
-
|
5
3
|
def blacklight_config
|
6
4
|
controller.blacklight_config
|
7
5
|
end
|
@@ -18,4 +16,4 @@ module ControllerLevelHelpers
|
|
18
16
|
def initialize_controller_helpers(helper)
|
19
17
|
helper.extend ControllerViewHelpers
|
20
18
|
end
|
21
|
-
end
|
19
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blacklight-marc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 8.
|
4
|
+
version: 8.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Coyne
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: blacklight
|
@@ -300,6 +300,7 @@ files:
|
|
300
300
|
- spec/lib/marc_export_spec.rb
|
301
301
|
- spec/lib/tasks/solr_marc_task_spec.rb
|
302
302
|
- spec/lib/traject_indexer_spec.rb
|
303
|
+
- spec/models/concerns/blacklight/marc/document_export_spec.rb
|
303
304
|
- spec/routing/routes_spec.rb
|
304
305
|
- spec/spec_helper.rb
|
305
306
|
- spec/support/controller_level_helpers.rb
|
@@ -307,7 +308,6 @@ files:
|
|
307
308
|
- spec/test_app_templates/lib/generators/test_app_generator.rb
|
308
309
|
- spec/views/bookmarks/_endnote.html.erb_spec.rb
|
309
310
|
- spec/views/bookmarks/_refworks.html.erb_spec.rb
|
310
|
-
- spec/views/catalog/_document_action.html.erb_spec.rb
|
311
311
|
- spec/views/catalog/index.atom.builder_spec.rb
|
312
312
|
- test_support/config/translation_maps/test_dewey.properties
|
313
313
|
- test_support/config/translation_maps/test_formats.properties
|
@@ -331,7 +331,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
331
331
|
- !ruby/object:Gem::Version
|
332
332
|
version: '0'
|
333
333
|
requirements: []
|
334
|
-
rubygems_version: 3.
|
334
|
+
rubygems_version: 3.3.3
|
335
335
|
signing_key:
|
336
336
|
specification_version: 4
|
337
337
|
summary: MARC support for Blacklight
|
@@ -349,6 +349,7 @@ test_files:
|
|
349
349
|
- spec/lib/marc_export_spec.rb
|
350
350
|
- spec/lib/tasks/solr_marc_task_spec.rb
|
351
351
|
- spec/lib/traject_indexer_spec.rb
|
352
|
+
- spec/models/concerns/blacklight/marc/document_export_spec.rb
|
352
353
|
- spec/routing/routes_spec.rb
|
353
354
|
- spec/spec_helper.rb
|
354
355
|
- spec/support/controller_level_helpers.rb
|
@@ -356,5 +357,4 @@ test_files:
|
|
356
357
|
- spec/test_app_templates/lib/generators/test_app_generator.rb
|
357
358
|
- spec/views/bookmarks/_endnote.html.erb_spec.rb
|
358
359
|
- spec/views/bookmarks/_refworks.html.erb_spec.rb
|
359
|
-
- spec/views/catalog/_document_action.html.erb_spec.rb
|
360
360
|
- spec/views/catalog/index.atom.builder_spec.rb
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'catalog/_document_action' do
|
4
|
-
let(:document_action_config) { Blacklight::Configuration::ToolConfig.new(tool_config) }
|
5
|
-
let(:document) { SolrDocument.new(id: '123') }
|
6
|
-
|
7
|
-
before do
|
8
|
-
allow(view).to receive_messages(controller_name: 'catalog')
|
9
|
-
render 'catalog/document_action', document_action_config: document_action_config, document: document
|
10
|
-
end
|
11
|
-
|
12
|
-
context "for refworks" do
|
13
|
-
let(:tool_config) { { if: :render_refworks_action?, partial: "document_action",
|
14
|
-
name: :refworks, key: :refworks, modal: false } }
|
15
|
-
|
16
|
-
it "should not be modal" do
|
17
|
-
expect(rendered).to have_link('Export to Refworks')
|
18
|
-
expect(rendered).not_to have_selector('a[data-ajax-modal]')
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|