diff --git a/app/assets/images/favicon.ico b/app/assets/images/favicon.ico new file mode 100644 index 0000000..71a13af Binary files /dev/null and b/app/assets/images/favicon.ico differ diff --git a/app/helpers/um_arclight_helper.rb b/app/helpers/um_arclight_helper.rb index cbb0a5d..b8e98c0 100644 --- a/app/helpers/um_arclight_helper.rb +++ b/app/helpers/um_arclight_helper.rb @@ -11,6 +11,70 @@ def formatted_last_indexed(timestamp) date.strftime("%F") end + + # Render an html 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? + 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 = [ diff --git a/app/views/catalog/_search_results.html.erb b/app/views/catalog/_search_results.html.erb index ef7647e..adf6387 100644 --- a/app/views/catalog/_search_results.html.erb +++ b/app/views/catalog/_search_results.html.erb @@ -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 %> diff --git a/config/locales/arclight.en.yml b/config/locales/arclight.en.yml index d52fd59..1a23f0b 100644 --- a/config/locales/arclight.en.yml +++ b/config/locales/arclight.en.yml @@ -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 diff --git a/config/locales/blacklight.en.yml b/config/locales/blacklight.en.yml index ab5cc0b..dcf1dcd 100644 --- a/config/locales/blacklight.en.yml +++ b/config/locales/blacklight.en.yml @@ -1,3 +1,8 @@ en: blacklight: - application_name: 'Arclight' \ No newline at end of file + application_name: 'University of Michigan Finding Aids' + search: + page_title: + title: '%{constraints} - %{application_name}' + prefix: 'Results for' + joiner: " / "