Skip to content

Commit

Permalink
Ensure that viewers show rather than thumbnails (#890)
Browse files Browse the repository at this point in the history
# Story

Refs:
- #880 
- #881 

In the case of a split work, :pdf? needs to be included in the methods
checked on a presenter.
In the case of a work that isn't split, Valkyrie has changed the term we
use to check for a `.pdf` suffix. It appears that we do not fill in the
label term. If characterization fails and we fall back to looking for a
pdf, we needed to look in the right location.

# Expected Behavior Before Changes

When PDF.js is selected via flipper and a work has been split, it
sometimes just shows a thumbnail.
When PDF.js is selected via flipper and work is not split, it sometimes
just shows a thumbnail.

# Expected Behavior After Changes

In new (valkyrie) resources, resources converted from Fedora, and works
still in Fedora:

- When PDF.js is selected via flipper and a work has been split, it
shows the UV
- When PDF.js is selected via flipper and a work is not split, it shows
the PDF in PDF.js

# Screenshots / Video

<details>
<summary>Both of these originally showed thumbnails only</summary>

![Screenshot 2024-11-13 at 2 51
37 PM](https://github.com/user-attachments/assets/0dbc51c1-a365-4b1a-a79d-3ce33d9d718d)


![Screenshot 2024-11-13 at 2 47
01 PM](https://github.com/user-attachments/assets/43050ab0-1783-4136-bd53-321cff20efc9)

</details>

# Notes
  • Loading branch information
laritakr authored Nov 13, 2024
2 parents 8c8f852 + 74c03f1 commit 6162b6c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/helpers/pdf_js_helper_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ def external_pdf(presenter)
end

def pdf_file_set_presenters(presenters)
presenters.select(&:pdf?).presence || presenters.select do |file_set_presenter|
file_set_presenter.solr_document["label_ssi"].downcase.end_with? ".pdf"
presenters.select(&:pdf?).presence || presenters.select do |fsp|
(fsp.solr_document['original_filename_tesi'] || fsp.solr_document['label_ssi'])&.downcase&.end_with?('.pdf')
end
end

Expand Down
14 changes: 10 additions & 4 deletions app/presenters/hyku/work_show_presenter_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ def part_of_label
# OVERRIDE incorporates fallback to PDF.js viewer via fileset's import_url
# see also pdf_js_helper_decorator
def show_pdf_viewer?
return unless Flipflop.default_pdf_viewer? || !iiif_viewer?
return unless file_set_presenters.any?(&:pdf?) || pdf_extension?
return false unless Flipflop.default_pdf_viewer? || !iiif_viewer?
return false unless file_set_presenters.any?(&:pdf?) || pdf_extension?

no_child_works?
end
Expand All @@ -38,11 +38,17 @@ def no_child_works?
end

def pdf_extension?
file_set_presenters.any? { |fsp| fsp&.label&.downcase&.end_with?('.pdf') }
# Valkyrie works are apparently not getting label assigned, but earlier works
# used label for file name. Using a combination of both.
file_set_presenters.any? do |fsp|
(fsp.solr_document['original_filename_tesi'] || fsp.solr_document['label_ssi'])&.downcase&.end_with?('.pdf')
end
end

def iiif_media?(presenter: representative_presenter)
iiif_media_predicates.any? { |predicate| presenter.try(predicate) || presenter.try(:solr_document).try(predicate) }
# override TenantConfig to include pdfs so we can use the UV regardless of the config
predicates = (iiif_media_predicates + %i[pdf?]).uniq
predicates.any? { |predicate| presenter.try(predicate) || presenter.try(:solr_document).try(predicate) }
end

# Override Tenant Config
Expand Down

0 comments on commit 6162b6c

Please sign in to comment.