+ + #{label} +
+ HTML + end.join.html_safe + end end + diff --git a/blacklight-cornell/app/helpers/browse_helper.rb b/blacklight-cornell/app/helpers/browse_helper.rb index 1a33e7769..6cbdddc75 100644 --- a/blacklight-cornell/app/helpers/browse_helper.rb +++ b/blacklight-cornell/app/helpers/browse_helper.rb @@ -1,34 +1,5 @@ module BrowseHelper - def search_field(heading_type) - case heading_type - when 'Personal Name' - 'pers' - when 'Corporate Name' - 'corp' - when 'Event' - 'event' - when 'Geographic Name' - 'geo' - when 'Chronological Term' - 'era' - when 'Genre/Form Term' - 'genr' - when 'Topical Term' - 'topic' - when 'Work' - 'work' - else - 'all_fields' - end - end - - def browse_search_field(browse_type, heading_type) - heading_type = search_field(heading_type) if heading_type - - browse_type - end - def browse_uri_encode (link_url) link_url = link_url.gsub('&','%26') link_url = link_url.gsub('"','%22') @@ -137,75 +108,26 @@ def build_alt_forms(alt_forms) return html.html_safe end - # TODO: Review generated search fields in search links. author_work_browse, for example, is not a valid search field. - def build_search_link(format_type, encoded_heading, search_type) - if search_type == "pers" || search_type == "corp" || search_type == "event" - the_search_field = 'search_field_row[]=author_' + search_type + '_browse&search_field_row[]=subject_' + search_type + '_browse' - return format_the_formats(format_type, encoded_heading, the_search_field, "OR") - else - the_search_field = 'search_field_row[]=subject_' + search_type + '_browse&search_field_row[]=author_' + search_type + '_browse' - return format_the_formats(format_type, encoded_heading, the_search_field, "NOT") - end - return ""#%2F + def build_search_link(format, f_count) + browse_field_count = @heading_document.browse_fields.count + boolean_row = {} + (browse_field_count - 1).times { |i| boolean_row[i + 1] = 'OR' } + search_params = { + advanced_query: 'yes', + search_field: 'advanced', + search_field_row: @heading_document.browse_fields, + boolean_row: boolean_row, + op_row: ['AND'] * browse_field_count, + q_row: [@heading_document['heading']] * browse_field_count, + "f[format]": [format] + } + + format_with_count = "#{pluralize_format(format)} (#{number_with_delimiter(f_count)})" + link_id = "facet_link_#{format.downcase.gsub(/[\/\-\s]/, '_')}" + link_to format_with_count, search_catalog_path(search_params).html_safe, id: link_id end - - def format_the_formats(f_type, encoded_heading, the_search_field, bool) - html = "" - f = f_type.split(" (")[0] - case f - when "Books" - html = '' - html += '' + f_type + '' - when "Journals/Periodicals" - html = '' - html += '' + f_type + '' - when "Manuscripts/Archives" - html = '' - html += '' + f_type + '' - when "Maps" - html = '' - html += '' + f_type + '' - when "Musical Scores" - html = '' - html += '' + f_type + '' - when "Non-musical Recordings" - html = '' - html += '' + f_type + '' - when "Videos" - html = '' - html += '' + f_type + '' - when "Computer Files" - html = '' - html += '' + f_type + '' - when "Databases" - html = '' - html += '' + f_type + '' - when "Musical Recordings" - html = '' - html += '' + f_type + '' - when "Theses" - html = '' - html += '' + f_type + '' - when "Microforms" - html = '' - html += '' + f_type + '' - when "Miscellaneous" - html = '' - html += '' + f_type + '' - end - return html.html_safe + + def pluralize_format(format) + format.split('/').map(&:pluralize).join('/') end end diff --git a/blacklight-cornell/app/helpers/cornell_catalog_helper.rb b/blacklight-cornell/app/helpers/cornell_catalog_helper.rb index 86c25230b..d44f20c75 100644 --- a/blacklight-cornell/app/helpers/cornell_catalog_helper.rb +++ b/blacklight-cornell/app/helpers/cornell_catalog_helper.rb @@ -1431,20 +1431,26 @@ def request_path(group, id, aeon_codes, document, scan) end if ENV['AEON_REQUEST'].blank? && group != 'AEON_SCAN_REQUEST' - aeon_req = "/aeon/#{id.to_s}" + aeon_req = "/aeon/#{id}" else url = group == 'AEON_SCAN_REQUEST' ? ENV['AEON_SCAN_REQUEST'] : ENV['AEON_REQUEST'] aeon_req = url.gsub('~id~', id.to_s).gsub('~libid~',aeon_codes.join('|')) end - if document['url_findingaid_display'] && document['url_findingaid_display'].size > 0 - finding_a = (document['url_findingaid_display'][0]).split('|')[0] - # only replace the placeholder if a finding aid value exists - aeon_req = aeon_req.gsub('~fa~', finding_a) - else - # otherwise remove the finding aid placeholder - aeon_req = aeon_req.gsub('&finding=~fa~', '') - end + # NOTE: In order to support display of multiple finding aids (see, e.g., bib 3272126), + # I'm using a different way of handling the finding aid URLs (the @finding_aids variable + # in the aeon_controller). So I'm not sure if we even need to do the following anymore. + # We should probably test this and remove it if it's not needed. (2/27/2025) + + # If there is a finding aid URL, replace the placeholder in the AEON request URL with it + if document['url_findingaid_display'] && document['url_findingaid_display'].size > 0 + finding_a = (document['url_findingaid_display'][0]).split('|')[0] + # only replace the placeholder if a finding aid value exists + aeon_req = aeon_req.gsub('~fa~', finding_a) + else + # otherwise remove the finding aid placeholder + aeon_req = aeon_req.gsub('&finding=~fa~', '') + end (group == "Circulating" ) ? magic_path : aeon_req end diff --git a/blacklight-cornell/app/helpers/display_helper.rb b/blacklight-cornell/app/helpers/display_helper.rb index 1acaf6db9..0ba33df11 100644 --- a/blacklight-cornell/app/helpers/display_helper.rb +++ b/blacklight-cornell/app/helpers/display_helper.rb @@ -107,13 +107,24 @@ def render_pair_delimited_index_field_value args # * link_to's with trailing