Skip to content

Commit

Permalink
Merge pull request #644 from sul-dlss/online-links
Browse files Browse the repository at this point in the history
change the way the 856 titles appear in stanford only links
  • Loading branch information
Jessie Keck committed Aug 4, 2014
2 parents 930ede5 + 79735e5 commit 10dbe67
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
13 changes: 10 additions & 3 deletions app/models/concerns/marc_links.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def all
link = process_link(link_field)
if link.present?
SearchWorks::Links::Link.new(
text: ["<a title='#{link[:title]}' href='#{link[:href]}'>#{link[:text]}</a>", "#{'(source: Casalini)' if link[:casalini_toc]}"].compact.join(' '),
text: ["<a title='#{link[:title]}' href='#{link[:href]}'>#{link[:text]}</a>", "#{'(source: Casalini)' if link[:casalini_toc]}", " #{link[:additional_text] if link[:additional_text]}"].compact.join(' '),
fulltext: link_is_fulltext?(link_field),
stanford_only: stanford_only?(link),
finding_aid: link_is_finding_aid?(link_field)
Expand Down Expand Up @@ -63,10 +63,17 @@ def process_link(field)
}
else
link_text = (!suby.present? && !sub3.present?) ? url_host : [sub3, suby].compact.join(' ')
title = subz.join(" ")
additional_text = nil
if title =~ stanford_affiliated_regex
additional_text = "<span class='additional-link-text'>#{title.gsub(stanford_affiliated_regex, '')}</span>"
title = "Available to Stanford-affiliated users only"
end
{:text=>link_text,
:title=>subz.join(" "),
:title=> title,
:href=>field["u"],
:casalini_toc => false
:casalini_toc => false,
:additional_text => additional_text
}
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/marc_records/marc_856_fixtures.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def stanford_only_856
<datafield tag='856' ind1='0' ind2='0'>
<subfield code='u'>http://library.stanford.edu</subfield>
<subfield code='y'>Link text</subfield>
<subfield code='z'>Available to stanford affiliated users at:</subfield>
<subfield code='z'>Available to stanford affiliated users at:4 at one time</subfield>
</datafield>
<datafield tag='856' ind1='0' ind2='0'>
<subfield code='u'>http://library.stanford.edu</subfield>
Expand Down
2 changes: 2 additions & 0 deletions spec/views/catalog/access_panels/_online.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
render
expect(rendered).to have_css(".panel-online")
expect(rendered).to have_css("ul.links li span.stanford-only")
expect(rendered).to have_css("span.additional-link-text", text: "4 at one time")
expect(rendered).to have_css("a[title='Available to Stanford-affiliated users only']", text: "Link text", count: 3)
end
it "should only render SFX links when present" do
assign(:document, SolrDocument.new(url_sfx: ['http://example.com/sfx-link'], marcxml: simple_856))
Expand Down

0 comments on commit 10dbe67

Please sign in to comment.