Skip to content

Commit 4882d47

Browse files
authored
Merge pull request #96 from projectblacklight/bl8
Support Blacklight 8
2 parents 99b9407 + b265af2 commit 4882d47

File tree

7 files changed

+58
-60
lines changed

7 files changed

+58
-60
lines changed
+9-26
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,14 @@
11
/* border between items on marc view */
22
$marc_item_separator: 1px solid $text-muted !default;
33

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;
186

19-
.field
20-
{
7+
.field {
8+
align-items: flex-start;
219
border-bottom: $marc_item_separator;
22-
clear:both;
10+
display: flex;
11+
gap: 2em;
2312
}
2413

2514
.ind1, .ind2
@@ -28,13 +17,7 @@ $marc_item_separator: 1px solid $text-muted !default;
2817
padding: 0 ($spacer / 2);
2918
}
3019

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+
}
4023
}

lib/blacklight/marc/catalog.rb app/controllers/concerns/blacklight/marc/catalog.rb

+10-3
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,20 @@ module Catalog
99
end
1010

1111
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+
1421
respond_to do |format|
1522
format.html do
1623
return render layout: false if request.xhr?
1724
# Otherwise draw the full page
18-
end
25+
end
1926
end
2027
end
2128

app/helpers/blacklight_marc_helper.rb

+8
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,12 @@ def render_endnote_texts(documents)
3939
end
4040
val
4141
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
4250
end

app/views/catalog/_marc_view.html.erb

+15-17
Original file line numberDiff line numberDiff line change
@@ -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">
32
<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| -%>
64
<div class="field">
7-
<div class="tag_ind">
8-
<span class="tag">
9-
<%= h(field.tag) %>
10-
</span>
115
<%- 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>
1512
<%- else -%>
13+
<div class="tag_ind">
14+
<span class="tag"><%= field.tag %></span>
1615
<div class="ind1">
17-
<%= !field.indicator1.blank? ? field.indicator1 : "&nbsp;".html_safe -%>
16+
<%= field.try(:indicator1).present? ? field.indicator1 : "&nbsp;".html_safe -%>
1817
</div>
1918
<div class="ind2">
20-
<%= !field.indicator2.blank? ? field.indicator2 : "&nbsp;".html_safe -%>
19+
<%= field.try(:indicator2).present? ? field.indicator2 : "&nbsp;".html_safe -%>
2120
</div>
2221
</div>
2322
<div class="subfields">
2423
<%- 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 -%>
2826
</div>
27+
<%- end -%>
2928
</div>
30-
<%- end-%>
3129
<%- end -%>
3230
</div>
+8-13
Original file line numberDiff line numberDiff line change
@@ -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 %>

blacklight-marc.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
1818
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
1919
spec.require_paths = ["lib"]
2020

21-
spec.add_dependency 'blacklight', '~> 7.0'
21+
spec.add_dependency 'blacklight', '>= 7.11', '< 9'
2222
spec.add_dependency "library_stdnums"
2323
spec.add_dependency "rails"
2424
spec.add_dependency "marc", ">= 0.4.3", "< 2.0" # Marc record parser.

spec/helpers/blacklight_marc_helper_spec.rb

+7
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,11 @@
4343
end
4444
end
4545

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
4653
end

0 commit comments

Comments
 (0)