Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/helpers/catalog_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ def current_view
document_index_view_type.to_s
end

def format_constraints_page_title(search_state)
text = render_search_to_page_title(search_state)
return text unless text.present? && search_state.filter('library').present?

library_code = search_state.filter('library').values.first
library_name = translate_library_code(library_code)

text.sub(/Library:\s*.*/, "Library: #{library_name}")
end

# override upstream so we don't check the session for the last view type.
def document_index_view_type(query_params = params || {})
view_param = query_params[:view]
Expand Down
2 changes: 1 addition & 1 deletion app/views/catalog/_search_results.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<% @page_title = t 'blacklight.search.masthead_title', title: page_location.access_point.to_s.gsub(/_/, ' ').capitalize.pluralize, application_name: "#{I18n.t('blacklight.application_name')} catalog" %>
<% end %>
<% else %>
<% constraints_text = render_search_to_page_title(search_state) %>
<% constraints_text = format_constraints_page_title(search_state) %>
<% if constraints_text.present? %>
<% @page_title = t('blacklight.search.page_title.title', constraints: constraints_text, application_name: application_name) %>
<% else %>
Expand Down
20 changes: 20 additions & 0 deletions spec/features/results_page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,26 @@
end
end

context 'with a library filter applied' do
before do
visit search_catalog_path f: { library: ['HILA'] }
end

it 'uses the friendly library name rather than the code' do
expect(page).to have_title "SearchWorks catalog, Library: Hoover Institution Library & Archives"
end
end

context 'with a library filter and search term applied' do
before do
visit search_catalog_path f: { library: ['HILA'] }, q: 'book'
end

it 'uses the friendly library name rather than the code' do
expect(page).to have_title "SearchWorks catalog, book, Library: Hoover Institution Library & Archives"
end
end

context 'when clicking clear all' do
it 'takes the user to a blank search' do
visit search_catalog_path f: { access_facet: ['Online'] }, q: 'book'
Expand Down