Skip to content

Commit

Permalink
Merge pull request #4260 from tulibraries/BL-1829-update-digital-coll…
Browse files Browse the repository at this point in the history
…ections-results-on-bento-page

Bl 1829 update digital collections results on bento page
  • Loading branch information
ebtoner committed Feb 29, 2024
2 parents 519d0d8 + cda546c commit e285c3c
Show file tree
Hide file tree
Showing 5 changed files with 307 additions and 136 deletions.
20 changes: 20 additions & 0 deletions app/assets/stylesheets/partials/_bento.scss
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,23 @@
width: 100%;
}
}

.cdm-results-container {
h3 {
font-size: 1rem;
line-height: 1.5rem;
}
a {
font-size: 1rem;
}
.cdm-data {
max-width: 75%;
color: $midnight-blue;
font-size:1rem;
}
.cdm-image {
min-height: 200px;
max-height: 200px;
height: 200px;
}
}
13 changes: 11 additions & 2 deletions app/search_engines/bento_search/cdm_engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,15 @@ def image_scale(collection, id)
rescue StandardError => e
Honeybadger.notify("Ran into error while try to process CDM image info api call: #{e.message}")
end
"https://digital.library.temple.edu/utils/ajaxhelper/?CISOROOT=#{collection}&CISOPTR=#{id}&action=2&DMSCALE=#{image_scale}&DMHEIGHT=340"

full_image = "https://digital.library.temple.edu/utils/ajaxhelper/?CISOROOT=#{collection}&CISOPTR=#{id}&action=2&DMSCALE=#{image_scale}&DMHEIGHT=340"
thumb = "https://digital.library.temple.edu/utils/getthumbnail/collection/#{collection}/id/#{id}"

if image_available?(full_image)
full_image
else image_available?(thumb)
thumb
end
end

def search_implementation(args)
Expand All @@ -36,14 +44,15 @@ def search_implementation(args)
query = ERB::Util.url_encode(query)
fields = args.fetch(:cdm_fields)
format = args.fetch(:cdm_format)
cdm_url = "https://digital.library.temple.edu/digital/bl/dmwebservices/index.php?q=dmQuery/all/CISOSEARCHALL^#{query}^all^and/#{fields}/sortby/9/#{format}"
cdm_url = "https://digital.library.temple.edu/digital/bl/dmwebservices/index.php?q=dmQuery/all/CISOSEARCHALL^#{query}^all^and/#{fields}/nosort/9/0/1/#{format}"
response = []

begin
response = JSON.load(URI.open(cdm_url))
bento_results.total_items = response.dig("pager", "total") || 0

response["records"].each do |i|

item = BentoSearch::ResultItem.new
item = conform_to_bento_result(i)
if (bento_results.size < 3) && (image_available?(item.other_links[0])) # only take records with images and with alphanumeric titles
Expand Down
22 changes: 11 additions & 11 deletions app/views/search/_digital_collections.html.erb
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<div class="bento-resource-container">
<div class="bento-resource-container cdm-results-container">
<h2 class="bento-resource-types bg-lighter-grey"><%= t("bento.digital_collections_header") %></h2>
<ul class="bento-resource-types-list pt-2 pb-0 list-inline d-flex flex-wrap justify-content-start">
<% @results["cdm"].each do |cdm_record| %>
<ul class="bento-resource-types-list pt-2 list-inline d-flex flex-wrap justify-content-start">
<% @results["cdm"].each do |cdm_record| %>
<li class="bento-resource-list-item list-inline-item pb-1">
<%= link_to cdm_record.link do %>
<%= image_tag cdm_record.other_links[0] %>
<%= image_tag cdm_record.other_links[0], class: "cdm_image" %>
<div class="pt-2 w-75">
<%= cdm_record.title %>
<h3 class="cdm-item-title"><%= cdm_record.title %></h3>
</div>
<% end %>
<p class="w-75" style="color:black;font-size:1rem;">
<p class="cdm-data">
<%= "Date: #{cdm_record.publication_date}" if cdm_record.publication_date.present? %>
<br /><%= cdm_collection_name(cdm_record.source_title) %>
</p>
</li>
<% end %>
<% end %>
<li class="w-100">
<%= link_to "View all digitized collections results >", "https://digital.library.temple.edu/digital/search/searchterm/#{params[:q]}/order/nosort", target: "_blank" %>
</li>
</ul>
<div class="bento-resource-types-list">
<%= link_to "View all digitized collections results >", "https://digital.library.temple.edu/digital/search/searchterm/#{params[:q]}/order/nosort" %>
</div>
</div>
</div>
386 changes: 264 additions & 122 deletions spec/fixtures/vcr_cassettes/bento_search_cdm.yml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion spec/search_engines/cdm_search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
end

it "returns three valid results" do
expect(search_results.size).to eq(3)
expect(search_results.size).to be <= 3
end
end

Expand Down

0 comments on commit e285c3c

Please sign in to comment.