Skip to content
Draft
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
Binary file added app/assets/images/favicon.ico
Binary file not shown.
64 changes: 64 additions & 0 deletions app/helpers/um_arclight_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,70 @@
date.strftime("%F")
end


# Render an html <title> appropriate string for a set of search parameters, based on local requirements
#
# @param search_state_or_params [Blacklight::SearchState, ActionController::Parameters]
# @return [String]
# Adapted from https://github.com/projectblacklight/blacklight/blob/main/app/helpers/blacklight/catalog_helper_behavior.rb#L151
def render_search_as_breadcrumbs_to_page_title(search_state_or_params)
search_state = if search_state_or_params.is_a? Blacklight::SearchState
search_state_or_params
else
controller.search_state_class.new(params, blacklight_config, self)
end

constraints = []
suffixes = []
prefix = t("blacklight.search.page_title.prefix")
add_prefix = true

if search_state.query_param.present?
unless search_state.search_field&.key.blank? || default_search_field?(search_state.search_field.key)
q_label = label_for_search_field(search_state.search_field.key)
end

constraints += if q_label.present?
[ t("blacklight.search.page_title.constraint", label: q_label, value: search_state.query_param) ]
else
[ search_state.query_param ]
end
end

if search_state.filters.any?
repository = collection = nil
has_level_collection = false

search_state.filters.each do |filter|
if filter.key == "repository"
repository = filter.values.first
elsif filter.key == "collection"
collection = filter.values.first
elsif filter.key == "level"
has_level_collection = filter.values.first == "Collection"
else
constraints << render_search_to_page_title_filter(filter.key, filter.values)
end
end
suffixes << repository unless repository.nil?
if collection.nil?
suffixes.unshift "Collections" if has_level_collection && suffixes.present?
else
suffixes.unshift collection
add_prefix = constraints.present?
end
end

title = []
title += [ constraints.join(t('blacklight.search.page_title.joiner')) ] unless constraints.empty?

Check failure on line 69 in app/helpers/um_arclight_helper.rb

View workflow job for this annotation

GitHub Actions / lint

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
unless suffixes.empty?
title << "-" unless title.empty?
title << suffixes.join(" - ")
end
title.unshift prefix if add_prefix
title.join(" ")
end

# Keys are the display keys registered in the Blacklight config.
# Fields are the Solr document keys associated with the display keys.
SKIPPABLE_KEYS = [
Expand Down
4 changes: 3 additions & 1 deletion app/views/catalog/_search_results.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
<%# Last checked for updates: ArcLight v1.6.2. %>
<%# https://github.com/projectblacklight/arclight/blob/master/app/views/catalog/_search_results.html.erb %>

<% @page_title = t('blacklight.search.page_title.title', constraints: render_search_to_page_title(search_state), application_name: application_name) %>
<% @page_title = t('blacklight.search.page_title.title',
constraints: render_search_as_breadcrumbs_to_page_title(search_state),
application_name: application_name) %>

<% content_for(:head) do -%>
<%= render 'catalog/opensearch_response_metadata', response: @response %>
Expand Down
2 changes: 2 additions & 0 deletions config/locales/arclight.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ en:
download:
pdf: Download PDF Finding Aid
html: Download HTML Finding Aid
repositories:
title: Repositories - University of Michigan Finding Aids
truncation:
view_less: show less
view_more: show more
Expand Down
7 changes: 6 additions & 1 deletion config/locales/blacklight.en.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
en:
blacklight:
application_name: 'Arclight'
application_name: 'University of Michigan Finding Aids'
search:
page_title:
title: '%{constraints} - %{application_name}'
prefix: 'Results for'
joiner: " / "
Loading