Skip to content

Commit

Permalink
Merge pull request #418 from nla/blac-682-adjust-collection-level-hea…
Browse files Browse the repository at this point in the history
…ding

BLAC-682: adjust collection level heading
  • Loading branch information
yetti authored May 13, 2024
2 parents d345a5f + 01b9a39 commit 8873af2
Show file tree
Hide file tree
Showing 9 changed files with 248 additions and 37 deletions.
10 changes: 5 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ GIT

GIT
remote: https://github.com/nla/nla-blacklight_common
revision: 1cd0ee9fb716cba9839403e6aba888649fd849a8
revision: 90eea4c1e63bd82d324d80643efa4542dfdd2edc
branch: main
specs:
nla-blacklight_common (0.2.0)
nla-blacklight_common (0.2.1)
activerecord-session_store (~> 2.0)
annotaterb
blacklight (>= 8.0.0, < 9)
Expand Down Expand Up @@ -105,7 +105,7 @@ GEM
addressable (2.8.5)
public_suffix (>= 2.0.2, < 6.0)
aes_key_wrap (1.1.0)
annotaterb (4.7.0)
annotaterb (4.7.1)
anyway_config (2.5.4)
ruby-next-core (>= 0.14.0)
arclight (1.0.1)
Expand Down Expand Up @@ -319,7 +319,7 @@ GEM
mysql2 (0.5.5)
net-http (0.4.1)
uri
net-imap (0.4.10)
net-imap (0.4.11)
date
net-protocol
net-pop (0.1.2)
Expand Down Expand Up @@ -352,7 +352,7 @@ GEM
omniauth-oauth2 (1.8.0)
oauth2 (>= 1.4, < 3)
omniauth (~> 2.0)
omniauth-rails_csrf_protection (1.0.1)
omniauth-rails_csrf_protection (1.0.2)
actionpack (>= 4.2)
omniauth (~> 2.0)
orm_adapter (0.5.0)
Expand Down
6 changes: 5 additions & 1 deletion app/components/arclight/document_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@

<div class="title-container">
<%= content_tag :h1 do %>
<%= t('collection_prefix') + document.normalized_title %>
<% if document.collection? %>
<%= t('collection_prefix') + document.normalized_title %>
<% else %>
<%= document.normalized_title %>
<% end %>
<% end %>
<%= render 'arclight/requests', document: document %>
<%= render Arclight::BookmarkComponent.new document: document, action: bookmark_config %>
Expand Down
34 changes: 34 additions & 0 deletions app/components/breadcrumbs_hierarchy_component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<ol class="breadcrumb">
<li class="breadcrumb-home-link">
<%= link_to t("arclight.routes.home"), root_path %>
</li>
<li class="breadcrumb-item breadcrumb-item-1">
<span aria-hidden="true"><%= blacklight_icon :repository, classes: "al-repository-content-icon" %></span>
<span class="breadcrumb-text"><%= repository %></span>
<ol class="breadcrumb">
<% if collection %>
<li class="breadcrumb-item breadcrumb-item-2">
<span aria-hidden="true"><%= blacklight_icon :collection, classes: "al-collection-content-icon" %></span>
<span class="breadcrumb-text"><%= link_to "#{t("collection_prefix")}#{collection.label}", solr_document_path(collection.global_id) %></span>

<ol class="breadcrumb">
<% parents_under_collection.each do |parent| %>
<li class="breadcrumb-item breadcrumb-item-3">
<span class="breadcrumb-text"><%= link_to parent.label, solr_document_path(parent.global_id) %></span>
</li>
<% end %>

<li class="breadcrumb-item breadcrumb-item-4">
<span class="breadcrumb-text"><%= @presenter.heading %></span>
</li>
</ol>
</li>
<% else # this is a collection %>
<li class="breadcrumb-item breadcrumb-item-4">
<span aria-hidden="true"><%= blacklight_icon :collection, classes: "al-collection-content-icon" %></span>
<span class="breadcrumb-text"><%= @presenter.heading %></span>
</li>
<% end %>
</ol>
</li>
</ol>
4 changes: 4 additions & 0 deletions app/components/breadcrumbs_hierarchy_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# frozen_string_literal: true

class BreadcrumbsHierarchyComponent < Arclight::BreadcrumbsHierarchyComponent
end
2 changes: 1 addition & 1 deletion app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class CatalogController < ApplicationController
# config.show.title_field = 'title_display'
config.show.document_component = Arclight::DocumentComponent
config.show.sidebar_component = Arclight::SidebarComponent
config.show.breadcrumb_component = Arclight::BreadcrumbsHierarchyComponent
config.show.breadcrumb_component = BreadcrumbsHierarchyComponent
config.show.embed_component = Arclight::EmbedComponent
config.show.access_component = Arclight::AccessComponent
config.show.online_status_component = Arclight::OnlineStatusIndicatorComponent
Expand Down
6 changes: 5 additions & 1 deletion app/presenters/show_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

class ShowPresenter < Arclight::ShowPresenter
def heading
I18n.t("collection_prefix") + document.normalized_title
if document.collection?
I18n.t("collection_prefix") + document.normalized_title
else
document.normalized_title
end
end
end
89 changes: 89 additions & 0 deletions spec/components/arclight/breadcrumbs_hierarchy_component_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# frozen_string_literal: true

require "rails_helper"

RSpec.describe BreadcrumbsHierarchyComponent, type: :component do
let(:document) do
SolrDocument.new(
ead_ssi: "abc123",
repository_ssm: "National Library of Australia",
_root_: "abc123",
normalized_title_ssm: "ABC123",
level_ssm: "collection"
)
end
let(:view_context) { ActionView::Base.new(nil, {}, nil) }
let(:config) { Blacklight::Configuration.new }
let(:show_presenter) { ShowPresenter.new(document, view_context, config) }

context "when viewing collection" do
it "renders collection title with prefix" do
render_inline(described_class.new(presenter: show_presenter))

expect(page).to have_css "li", text: "National Library of Australia"
expect(page).to have_css "li", text: "Guide to the ABC123"
expect(page).not_to have_link "Guide to the ABC123"
end
end

context "when viewing series" do
let(:document) do
SolrDocument.new(
parent_ssim: %w[abc123 abc123_def],
parent_unittitles_ssm: %w[ABC123 DEF],
parent_levels_ssm: %w[collection Series],
ead_ssi: "abc123",
repository_ssm: "National Library of Australia",
_root_: "abc123",
normalized_title_ssm: "GHI",
level_ssm: "Subseries"
)
end

it "renders series titles without prefix" do
render_inline(described_class.new(presenter: show_presenter))

expect(page).to have_css "li", text: "National Library of Australia"
expect(page).to have_link "Guide to the ABC123", href: "/finding-aids/catalog/abc123"

expect(page).to have_link "DEF", href: "/finding-aids/catalog/abc123abc123_def"
expect(page).not_to have_link "Guide to the DEF", href: "/finding-aids/catalog/abc123abc123_def"

expect(page).to have_css "li", text: "GHI"
expect(page).not_to have_link "GHI"
expect(page).not_to have_link "Guide to the GHI"
end
end

context "when viewing file" do
let(:document) do
SolrDocument.new(
parent_ssim: %w[abc123 abc123_def abc123_ghi],
parent_unittitles_ssm: %w[ABC123 DEF GHI],
parent_levels_ssm: %w[collection Series Subseries],
ead_ssi: "abc123",
repository_ssm: "National Library of Australia",
_root_: "abc123",
normalized_title_ssm: "JKL",
level_ssm: "file"
)
end

it "renders file titles without prefix" do
render_inline(described_class.new(presenter: show_presenter))

expect(page).to have_css "li", text: "National Library of Australia"
expect(page).to have_link "Guide to the ABC123", href: "/finding-aids/catalog/abc123"

expect(page).to have_link "DEF", href: "/finding-aids/catalog/abc123abc123_def"
expect(page).not_to have_link "Guide to the DEF", href: "/finding-aids/catalog/abc123abc123_def"

expect(page).to have_link "GHI", href: "/finding-aids/catalog/abc123abc123_ghi"
expect(page).not_to have_link "Guide to the GHI", href: "/finding-aids/catalog/abc123abc123_ghi"

expect(page).to have_css "li", text: "JKL"
expect(page).not_to have_link "Guide to the JKL"
expect(page).not_to have_link "JKL"
end
end
end
54 changes: 25 additions & 29 deletions spec/features/document_component_spec.rb
Original file line number Diff line number Diff line change
@@ -1,34 +1,30 @@
require "rails_helper"

RSpec.describe "Document components" do
before do
solr_response = IO.read("spec/files/solr/280011976.json")

WebMock.stub_request(:get, /solr:8983/)
.with(
headers: {
"Accept" => "*/*",
"Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
}
)
.to_return(status: 200, body: solr_response, headers: {})
end

it "has correct tab title, including the collection prefix" do
visit solr_document_path(id: "280011976")

expect(page).to have_title(I18n.t("collection_prefix") + "19th century currency items, c1868-1895 - Finding Aids")
end

it "has correct breadcrumbs, including the collection prefix" do
visit solr_document_path(id: "280011976")

expect(page).to have_css("span.breadcrumb-text", text: I18n.t("collection_prefix") + "19th century currency items, c1868-1895")
end

it "has correct title, including the collection prefix" do
visit solr_document_path(id: "280011976")

expect(page).to have_css("div.title-container h1", text: I18n.t("collection_prefix") + "19th century currency items, c1868-1895")
context "when at the collection level" do
before do
solr_response = IO.read("spec/files/solr/280011976.json")

WebMock.stub_request(:get, /solr:8983/)
.with(
headers: {
"Accept" => "*/*",
"Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
}
)
.to_return(status: 200, body: solr_response, headers: {})
end

it "has correct tab title, including the collection prefix" do
visit solr_document_path(id: "280011976")

expect(page).to have_title(I18n.t("collection_prefix") + "19th century currency items, c1868-1895 - Finding Aids")
end

it "has correct title, including the collection prefix" do
visit solr_document_path(id: "280011976")

expect(page).to have_css("div.title-container h1", text: I18n.t("collection_prefix") + "19th century currency items, c1868-1895")
end
end
end
80 changes: 80 additions & 0 deletions spec/files/solr/367300335367601811.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"responseHeader":{
"zkConnected":true,
"status":0,
"QTime":1,
"params":{
"q":"id:367300335367601811",
"fl":"*",
"_forwardedCount":"1",
"wt":"json"}},
"response":{"numFound":1,"start":0,"numFoundExact":true,"docs":[
{
"id":"367300335367601811",
"fav_obj_id_ssi":"nla.obj-367710222",
"ref_ssi":"367601811",
"ref_ssm":["367601811"],
"component_level_isim":[2],
"sort_isi":2,
"bibid_ssi":"538326",
"folio_instance_id_ssi":"2ff67ac1-fd2b-515c-ba93-248652d934c0",
"parent_ssi":"367601771",
"aspace_id_ssi":"aspace_8cf2270ccfec1a6513579cb137066c2f",
"title_ssm":["Diaries, 1929, 1934; loose diary pages, 1916, 1929, 1930, 1935 and undated"],
"title_tesim":["Diaries, 1929, 1934; loose diary pages, 1916, 1929, 1930, 1935 and undated"],
"normalized_title_ssm":["Diaries, 1929, 1934; loose diary pages, 1916, 1929, 1930, 1935 and undated"],
"text":["Diaries, 1929, 1934; loose diary pages, 1916, 1929, 1930, 1935 and undated",
"1",
"Braga, J.M. (José Maria)",
"History"],
"parent_ssim":["367300335",
"367601771"],
"parent_levels_ssm":["collection",
"Series"],
"parent_unittitles_ssm":["Papers of J.M. Braga, 1862-2000 (bulk 1920-1971)",
"Diaries and notebooks, 1916-c.1972"],
"parent_unittitles_tesim":["Papers of J.M. Braga, 1862-2000 (bulk 1920-1971)",
"Diaries and notebooks, 1916-c.1972"],
"collection_ssim":["Papers of J.M. Braga, 1862-2000 (bulk 1920-1971)"],
"unitid_ssm":["1"],
"ead_unitid_ssm":["367300335"],
"repository_ssim":["National Library of Australia"],
"collection_creator_ssm":["Braga, J.M. (José Maria)"],
"has_online_content_ssim":["false"],
"child_component_count_isi":0,
"level_ssim":["File"],
"level_ssm":["File"],
"parent_access_restrict_tesm":["Available for research."],
"parent_access_terms_tesm":["Copying and publishing of unpublished manuscript material is subject to copyright restrictions. For such material, written permission to publish must be obtained from the copyright holder(s). Copying of unpublished material for research purposes is permissible 50 years after the death of the creator of the material."],
"names_ssim":["Braga, J.M. (José Maria)"],
"access_subjects_ssim":["History"],
"access_subjects_ssm":["History"],
"acqinfo_ssim":["The bulk of the Braga Collection (including manuscripts, pictures, maps, newspapers, serials, periodicals, monographs and ephemera) was purchased from J.M. Braga in 1966. The component held in the Manuscript Collection at MS 4300 appears to have been formally accessioned as the J.M. Braga Papers in 1975. Several small additions have been made since the original instalment of papers was received. Most of these additions were transfers to the Manuscripts Collection from other collection areas, including a file of newspaper cuttings in May 1975, a set of microfilm reels in 1984, a file of manuscript material in 1985, lists of the Braga Collection in 1994, and two files of assorted printed material and other papers in 2009. As well, several small additions have been made by members of the Braga family. In 1992, various Braga family members donated a copy of the eulogy and order of service for Augusta Braga's memorial service, and in 2002 Angela Braga donated photographs of medals and decorations awarded to J.P. Braga, together with photocopies of early writings of J.M. Braga and eulogies for J.M. Braga and his grandson Michael Braga."],
"_nest_path_":"/child#0/child#0",
"_nest_parent_":"367300335367601771",
"_root_":"367300335",
"_version_":1796736391573405696,
"timestamp":"2024-04-19T04:35:49.969Z"}]
},
"facet_counts":{
"facet_queries":{},
"facet_fields":{
"level_ssim":[
"File",1],
"creator_ssim":[],
"date_range_ssim":[],
"names_ssim":[
"Braga, J.M. (José Maria)",1],
"geogname_ssim":[],
"access_subjects_ssim":[
"History",1],
"repository_ssim":[
"National Library of Australia",1],
"collection_ssim":[
"Papers of J.M. Braga, 1862-2000 (bulk 1920-1971)",1]},
"facet_ranges":{},
"facet_intervals":{},
"facet_heatmaps":{}},
"spellcheck":{
"suggestions":[],
"correctlySpelled":true}}

0 comments on commit 8873af2

Please sign in to comment.