Skip to content

Commit

Permalink
Merge pull request #286 from pulibrary/257-download-pdf
Browse files Browse the repository at this point in the history
Add a pdf download link
  • Loading branch information
Seanwarren77 authored Jan 6, 2025
2 parents 4890507 + d09e7d6 commit b88dde5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
2 changes: 2 additions & 0 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ config :dpul_collections, DpulCollectionsWeb.Gettext,
default_locale: "en",
locales: ~w(en es)

config :dpul_collections, :web_connections, figgy_url: "https://figgy.princeton.edu"

# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "#{config_env()}.exs"
2 changes: 2 additions & 0 deletions config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,5 @@ config :dpul_collections, :solr, %{

# Set this poll interval really small so it triggers in test.
config :dpul_collections, :figgy_hydrator, poll_interval: 50

config :dpul_collections, :web_connections, figgy_url: "https://figgy.example.com"
9 changes: 7 additions & 2 deletions lib/dpul_collections_web/live/item_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ defmodule DpulCollectionsWeb.ItemLive do
<.description :for={description <- @item.description} description={description} />
</div>
</div>
<div class="md:col-span-2 md:order-first">
<div class="primary-thumbnail md:col-span-2 md:order-first">
<img
class="w-full"
src={"#{Enum.at(@item.image_service_urls, 0)}/full/525,800/0/default.jpg"}
Expand All @@ -51,7 +51,12 @@ defmodule DpulCollectionsWeb.ItemLive do
height="800"
/>
<button class="w-full btn-primary">
<%= gettext("Download") %>
<a
href={"#{Application.fetch_env!(:dpul_collections, :web_connections)[:figgy_url]}/catalog/#{@item.id}/pdf"}
target="_blank"
>
<%= gettext("Download PDF") %>
</a>
</button>
</div>
<div class="md:hidden block">
Expand Down
8 changes: 7 additions & 1 deletion test/dpul_collections_web/live/item_live_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,13 @@ defmodule DpulCollectionsWeb.ItemLiveTest do
# Large thumbnail renders
assert view
|> has_element?(
"img[src='https://example.com/iiif/2/image2/full/350,465/0/default.jpg']"
".primary-thumbnail img[src='https://example.com/iiif/2/image1/full/525,800/0/default.jpg']"
)

assert view
|> has_element?(
".primary-thumbnail a[href='https://figgy.example.com/catalog/1/pdf']",
"Download PDF"
)

# Renders when there's no description
Expand Down

0 comments on commit b88dde5

Please sign in to comment.