From ba0014d5dfb8b6d9de040fee0a44d4597fd65afd Mon Sep 17 00:00:00 2001 From: Samuel Sciolla Date: Tue, 18 Aug 2026 17:16:16 -0400 Subject: [PATCH] (Mostly) migrate over umich-arclight approach to search results page title --- app/assets/images/favicon.ico | Bin 0 -> 15086 bytes app/helpers/um_arclight_helper.rb | 64 +++++++++++++++++++++ app/views/catalog/_search_results.html.erb | 4 +- config/locales/arclight.en.yml | 2 + config/locales/blacklight.en.yml | 7 ++- 5 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 app/assets/images/favicon.ico diff --git a/app/assets/images/favicon.ico b/app/assets/images/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..71a13affaf465907381e96a94c249250debd16b2 GIT binary patch literal 15086 zcmeHOU1%It6u#Tp-AST0!52Y`S%2y;Y7i8Kpus0a6a^KEK4=TIZ}z4BgNusvL0_z( zQ55qaXh2^Jf@F~rHoMc-qM>4K$wNU=Y2$C#R&xB#+`W@Kvoo_Zvp3ldoq>~c=iGDd z_uVshX7Aj&5uzY0F)<;aE8^3wLfkHds8rhLV?vyOZ48?0cNK+r0}j{02O;7~2;1G` zYN_(Sc?R+ffJP!1F&s7l8Lsi27|gCJxX= zst+dl7ae-elO}zxVJhq>J?+Jz4aJQ$+L#GxXU6lHr;GJi_)drThvF8&QIGZ7l(;)n zv@@m0s&ctOk43eCx+j#MuEA+4Dkj9fQ;*fl@a>7e?a)88}xwcLtpb>r%TFB z`Y8o>HI9B6IYgIoANt0hXcKsUnSs0N!y3OO>F0c)4_x!v9*Zmsb zy$1OD#sQv%dxG56IqIG@jc2&M8s678DZU-L_up$@t_*YkRn2EQc?i)_YKH3_)g5za2Ur}+cC1SuJTQv`*5aw zkZz9U8B8OWK3|dSyl0IZHSS zL{&|v&7bn;eOeXB6vW%7g}q$)k!L{90Om*hZ78wmu^nZHM$)v^_U-l#v|f2>`7g6lim4}9S6(8ktw=8&cTiaXkh{8o*1wW{)C zZP#fl{QuDK|HAv~^|}woX!XH+Vp{j*a$C ze9NKxfgQU(gmw9cn1gBj;W}*r_HQwLS2;K}bcn`{;y373+-qMYz?K{u^fkUwycXl1 zYW$&{EbEGKF=_EtZiD&+xUmH7-Of$mpDQlVof+5fd&b9_`%CIx<8sOzc=##fWL`18 z`1`cN=e6}z<1_vB(y!;KVTUgFu-k>rKB6GDIxjEK!jnP5?$QM>UntqUTL?&Pa?+~ZvBj!QTqvbd#G;2-l|t3Rs*2@W z?4{LsUi!eYhaW|r@j3-BOH?4 zIiB|o1^T|bBvAO-48sQ zL+`sb)Oj|`T>5YgYm9S)~P&3;j4Pq2il_BRN0LO zFW!$4wjb~`&$n4z?7;Qo7>-4qYR{)pw@qfpeP`&%M^s$f{-KIh8upJOVuIs$hWD?i xI8VzxExa$s=kL|`sUX*o^@k1qAN46AUcW+0wIBowR%6}A4?mRbC0=)y@;^v0nV 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: " / "