diff --git a/Gemfile.lock b/Gemfile.lock index 2799fd4f..f4c8e69c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -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) @@ -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) @@ -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) diff --git a/app/components/arclight/document_component.html.erb b/app/components/arclight/document_component.html.erb index 0e2616d6..22eac7fc 100644 --- a/app/components/arclight/document_component.html.erb +++ b/app/components/arclight/document_component.html.erb @@ -8,7 +8,11 @@
<%= 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 %> diff --git a/app/components/breadcrumbs_hierarchy_component.html.erb b/app/components/breadcrumbs_hierarchy_component.html.erb new file mode 100644 index 00000000..845a29fb --- /dev/null +++ b/app/components/breadcrumbs_hierarchy_component.html.erb @@ -0,0 +1,34 @@ + diff --git a/app/components/breadcrumbs_hierarchy_component.rb b/app/components/breadcrumbs_hierarchy_component.rb new file mode 100644 index 00000000..5f1a6f45 --- /dev/null +++ b/app/components/breadcrumbs_hierarchy_component.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class BreadcrumbsHierarchyComponent < Arclight::BreadcrumbsHierarchyComponent +end diff --git a/app/controllers/catalog_controller.rb b/app/controllers/catalog_controller.rb index 2d3590d3..1c555c75 100644 --- a/app/controllers/catalog_controller.rb +++ b/app/controllers/catalog_controller.rb @@ -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 diff --git a/app/presenters/show_presenter.rb b/app/presenters/show_presenter.rb index 3f879f6e..401692a0 100644 --- a/app/presenters/show_presenter.rb +++ b/app/presenters/show_presenter.rb @@ -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 diff --git a/spec/components/arclight/breadcrumbs_hierarchy_component_spec.rb b/spec/components/arclight/breadcrumbs_hierarchy_component_spec.rb new file mode 100644 index 00000000..25abbec4 --- /dev/null +++ b/spec/components/arclight/breadcrumbs_hierarchy_component_spec.rb @@ -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 diff --git a/spec/features/document_component_spec.rb b/spec/features/document_component_spec.rb index 627fce78..595f73a4 100644 --- a/spec/features/document_component_spec.rb +++ b/spec/features/document_component_spec.rb @@ -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 diff --git a/spec/files/solr/367300335367601811.json b/spec/files/solr/367300335367601811.json new file mode 100644 index 00000000..f1c1e646 --- /dev/null +++ b/spec/files/solr/367300335367601811.json @@ -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}} \ No newline at end of file