scientist-softserv / atla-hyku

Other
0 stars 0 forks source link

I162 install pdf js #180

Closed kirkkwang closed 7 months ago

kirkkwang commented 7 months ago

Story

This PR is for installing PDF.js as the viewer for PDF resources. This is modeled after the work from PALs however it is different in that it does not have the functionality to stop IIIF Print processes. I feel that was out of scope for this particular issue. To help review this PR, I think it is best to go commit by commit to understand the workflow.

Ref:

Expected Behavior Before Changes

The Universal Viewer with logic and processes from IIIF Print was the viewer for PDF resources. PDFs were turned into images and then linked via the IIIF Manifest.

Expected Behavior After Changes

There is now the ability to use PDF.js as the viewer of choice for PDF resources instead of the Universal Viewer.

Screenshots / Video

image

Notes

A reindex is needed for the existing records to work properly. All newly created records should have the viewer and download button showing by default.

Commits

🎁 Copy over files from a PDF.js generic build

9122ad16124d5597533abd36cc4cb0d9c43d9579

This commit will copy over the files from a generic build of PDF.js. The build was created by running the following commands:

git clone https://github.com/mozilla/pdf.js.git
cd pdf.js
npm install -g gulp-cli
npm install
gulp generic

In the project's build folder we find all the files needed. We copy over mostly everying, skipping debug and sandbox files.

🧹 Rename .mjs to .js

34b7fd8a227e25d69523ec3dec8996618976d2b3

Using the .mjs extension did not seem to work properly, however renaming it to .js seems to work fine. This commit renames instances (where needed) of .mjs to .js.

🎁 Add feature flipper for PDF.js viewer

56770b9f3e92171a843791a762935deb75053a05

This commit will add a feature flipper to switch between using PDF.js or Universal Viewer for displaying PDFs. At the moment we have no mechanism to turn off IIIF Print PDF processing, however, that was not indicated as a requirement at this time so that is not included until we have a need for it.

🎁 Make views display PDFs with PDF.js

02fd84e2fa2c2d479480c5cd4dbbaa5ad5a9cac2

This commit will add the PDF.js viewer to the work show page. It will also add a helper method to the work show presenter to determine if the work has a PDF file. All relevant views will be updated.

🎁 Add ability to pass search term to PDF.js

8d21dde29bb6c28c198c630588c739b6e971347f

This commit will add a PDF's text to the file set's solr document so it can be searched in the catalog. Now we can pass the search term to the viewer so when it loads it will highlight the search term.

🎁 Add toggle for pdf viewer and download button

5a9c14a448aef75f6c0d7c9b887b45e855b28eec

This commit will add two properties for all work types to allow for the pdf viewer and download button to be toggled on and off on the work show page. These two options will exist on the forms for each work type on the files tab. This will also hide the default download button on PDF.js so the users can only download from the newly introduced download button.