- <.thumbs :for={thumb_num <- 1..@item.page_count} :if={@item.page_count} thumb_num={thumb_num} />
+ <.thumbs
+ :for={{thumb, thumb_num} <- Enum.with_index(@item.image_service_urls)}
+ :if={@item.page_count}
+ thumb={thumb}
+ thumb_num={thumb_num}
+ />
1} class="absolute right-0 top-0 bg-white px-4 py-2">
<%= @item.page_count %> Pages
@@ -151,7 +156,7 @@ defmodule DpulCollectionsWeb.SearchLive do
~H"""

Helpers.clean_params([:page, :per_page])
- socket = push_patch(socket, to: ~p"/search?#{params}")
+ socket = push_patch(socket, to: ~p"/search?#{params}", replace: true)
{:noreply, socket}
end
@@ -263,7 +268,7 @@ defmodule DpulCollectionsWeb.SearchLive do
def handle_event("paginate", %{"page" => page}, socket) when page != "..." do
params = %{socket.assigns.search_state | page: page} |> Helpers.clean_params()
- socket = push_patch(socket, to: ~p"/search?#{params}")
+ socket = push_redirect(socket, to: ~p"/search?#{params}", replace: true)
{:noreply, socket}
end
diff --git a/test/dpul_collections/indexing_pipeline/figgy/hydration_cache_entry_test.exs b/test/dpul_collections/indexing_pipeline/figgy/hydration_cache_entry_test.exs
index 382d1d85..6b34fc08 100644
--- a/test/dpul_collections/indexing_pipeline/figgy/hydration_cache_entry_test.exs
+++ b/test/dpul_collections/indexing_pipeline/figgy/hydration_cache_entry_test.exs
@@ -28,6 +28,56 @@ defmodule DpulCollections.IndexingPipeline.Figgy.HydrationCacheEntryTest do
assert doc2[:page_count_i] == 0
end
+ test "transforms related member image service urls" do
+ # Add FileMetadata with both a JP2/Pyramidal derivative, to ensure it
+ # picks the pyramidal
+ {:ok, entry} =
+ IndexingPipeline.write_hydration_cache_entry(%{
+ cache_version: 0,
+ record_id: "0cff895a-01ea-4895-9c3d-a8c6eaab4013",
+ source_cache_order: ~U[2018-03-09 20:19:35.465203Z],
+ related_data: %{
+ "member_ids" => %{
+ "1" => %{
+ "internal_resource" => "FileSet",
+ "metadata" => %{
+ "file_metadata" => [
+ # Not this one - it's an old JP2
+ %{
+ "id" => %{"id" => "0cff895a-01ea-4895-9c3d-a8c6eaab4014"},
+ "internal_resource" => "FileMetadata",
+ "mime_type" => ["image/jp2"],
+ "use" => [%{"@id" => "http://pcdm.org/use#ServiceFile"}]
+ },
+ %{
+ "id" => %{"id" => "0cff895a-01ea-4895-9c3d-a8c6eaab4017"},
+ "internal_resource" => "FileMetadata",
+ "mime_type" => ["image/tiff"],
+ "use" => [%{"@id" => "http://pcdm.org/use#ServiceFile"}]
+ }
+ ]
+ }
+ }
+ }
+ },
+ data: %{
+ "id" => "0cff895a-01ea-4895-9c3d-a8c6eaab4013",
+ "internal_resource" => "EphemeraFolder",
+ "metadata" => %{
+ "member_ids" => [%{"id" => "1"}],
+ "title" => ["test title 4"]
+ }
+ }
+ })
+
+ doc = HydrationCacheEntry.to_solr_document(entry)
+
+ # This is the pyramidal derivative.
+ assert doc[:image_service_urls_ss] == [
+ "https://iiif-cloud.princeton.edu/iiif/2/0c%2Fff%2F89%2F0cff895a01ea48959c3da8c6eaab4017%2Fintermediate_file"
+ ]
+ end
+
test "includes date range if found, date if not" do
entries =
FiggyTestFixtures.hydration_cache_entries()
diff --git a/test/dpul_collections/item_test.exs b/test/dpul_collections/item_test.exs
new file mode 100644
index 00000000..60508115
--- /dev/null
+++ b/test/dpul_collections/item_test.exs
@@ -0,0 +1,13 @@
+defmodule DpulCollections.ItemTest do
+ use DpulCollections.DataCase
+
+ alias DpulCollections.Item
+
+ describe ".from_solr/1" do
+ test "populates an empty array for image_service_urls if empty" do
+ item = DpulCollections.Item.from_solr(%{"title_ss" => ["Title"]})
+
+ assert item.image_service_urls == []
+ end
+ end
+end
diff --git a/test/dpul_collections_web/live/item_live_test.exs b/test/dpul_collections_web/live/item_live_test.exs
index 339077d3..c84a5027 100644
--- a/test/dpul_collections_web/live/item_live_test.exs
+++ b/test/dpul_collections_web/live/item_live_test.exs
@@ -14,19 +14,31 @@ defmodule DpulCollectionsWeb.ItemLiveTest do
id: 1,
title_txtm: "Învăţămîntul trebuie să urmărească dezvoltarea deplină a personalităţii",
display_date_s: "2022",
- page_count_i: 17
+ page_count_i: 17,
+ image_service_urls_ss: [
+ "https://example.com/iiif/2/image1",
+ "https://example.com/iiif/2/image2"
+ ]
},
%{
id: 2,
title_txtm: "زلزلہ",
display_date_s: "2024",
- page_count_i: 14
+ page_count_i: 14,
+ image_service_urls_ss: [
+ "https://example.com/iiif/2/image1",
+ "https://example.com/iiif/2/image2"
+ ]
},
%{
id: 3,
title_txtm: "اب كوئى جنگ نه هوگى نه كبهى رات گئے، خون كى آگ كو اشكوں سے بجهانا هوگا",
display_date_s: "2022",
- page_count_i: 1
+ page_count_i: 1,
+ image_service_urls_ss: [
+ "https://example.com/iiif/2/image1",
+ "https://example.com/iiif/2/image2"
+ ]
}
],
active_collection()
@@ -75,6 +87,35 @@ defmodule DpulCollectionsWeb.ItemLiveTest do
assert response =~ "Învăţămîntul trebuie să urmărească dezvoltarea deplină a personalităţii"
assert response =~ "2022"
assert response =~ "17"
+ # Thumbnails render.
+ assert view
+ |> has_element?(
+ "img[src='https://example.com/iiif/2/image1/full/350,465/0/default.jpg']"
+ )
+
+ assert view
+ |> has_element?(
+ "img[src='https://example.com/iiif/2/image2/full/350,465/0/default.jpg']"
+ )
+
+ # Download links for each thumbnail
+ assert view
+ |> has_element?(
+ "a[href='https://example.com/iiif/2/image1/full/full/0/default.jpg']",
+ "Download"
+ )
+
+ assert view
+ |> has_element?(
+ "a[href='https://example.com/iiif/2/image2/full/full/0/default.jpg']",
+ "Download"
+ )
+
+ # Large thumbnail renders
+ assert view
+ |> has_element?(
+ "img[src='https://example.com/iiif/2/image2/full/350,465/0/default.jpg']"
+ )
end
test "/i/{:slug}/item/{:id} does not redirect with a bad id", %{conn: conn} do
diff --git a/test/dpul_collections_web/live/search_live_test.exs b/test/dpul_collections_web/live/search_live_test.exs
index 733ce99d..b830b2dd 100644
--- a/test/dpul_collections_web/live/search_live_test.exs
+++ b/test/dpul_collections_web/live/search_live_test.exs
@@ -43,6 +43,30 @@ defmodule DpulCollectionsWeb.SearchLiveTest do
|> Enum.any?()
end
+ test "GET /search renders thumbnails for each resource", %{conn: conn} do
+ {:ok, view, _html} = live(conn, "/search?")
+
+ assert view
+ |> has_element?(
+ "#item-1 img[src='https://example.com/iiif/2/image1/square/350,350/0/default.jpg']"
+ )
+
+ assert view
+ |> has_element?(
+ "#item-1 img[src='https://example.com/iiif/2/image2/square/350,350/0/default.jpg']"
+ )
+
+ assert view
+ |> has_element?(
+ "#item-2 img[src='https://example.com/iiif/2/image1/square/350,350/0/default.jpg']"
+ )
+
+ assert view
+ |> has_element?(
+ "#item-2 img[src='https://example.com/iiif/2/image2/square/350,350/0/default.jpg']"
+ )
+ end
+
test "searching filters results", %{conn: conn} do
{:ok, view, _html} = live(conn, "/search?")
@@ -130,14 +154,20 @@ defmodule DpulCollectionsWeb.SearchLiveTest do
assert view
|> element("#paginator-previous")
|> render_click()
+ |> follow_redirect(conn)
+ |> elem(2)
|> Floki.parse_document()
|> elem(1)
|> Floki.find(~s{a[href="/i/document40/item/40"]})
|> Enum.any?()
+ {:ok, view, _html} = live(conn, ~p"/search?page=4")
+
assert view
|> element("#paginator-next")
|> render_click()
+ |> follow_redirect(conn)
+ |> elem(2)
|> Floki.parse_document()
|> elem(1)
|> Floki.find(~s{a[href="/i/document50/item/50"]})
diff --git a/test/support/solr_test_support.ex b/test/support/solr_test_support.ex
index 189519b2..6f9a88a8 100644
--- a/test/support/solr_test_support.ex
+++ b/test/support/solr_test_support.ex
@@ -9,7 +9,11 @@ defmodule SolrTestSupport do
title_txtm: "Document-#{n}",
display_date_s: date |> Integer.to_string(),
years_is: [date],
- page_count_i: page_count
+ page_count_i: page_count,
+ image_service_urls_ss: [
+ "https://example.com/iiif/2/image1",
+ "https://example.com/iiif/2/image2"
+ ]
}
end
end