Skip to content

Commit

Permalink
Show PDF.js viewer when PDF.js FlipFlop is true
Browse files Browse the repository at this point in the history
This is a workaround to unblock Mobius ingests. If the feature flipper to display PDF.js is true, we will display that viewer regardless of the property values of :show_pdf_viewer and :show_pdf_download_button.

We will revisit valkyrizing this feature fully in the future, when we start the iiif x valkyrie epic.

Issue:
- scientist-softserv/hykuup_knapsack#185

Co-Authored-By: Kirk Wang <[email protected]>
  • Loading branch information
ShanaLMoore and kirkkwang committed Mar 26, 2024
1 parent 9614850 commit 9c632d7
Show file tree
Hide file tree
Showing 197 changed files with 119,501 additions and 12 deletions.
1 change: 1 addition & 0 deletions app/forms/generic_work_resource_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ class GenericWorkResourceForm < Hyrax::Forms::ResourceForm(GenericWorkResource)
include Hyrax::FormFields(:generic_work_resource)
include Hyrax::FormFields(:with_pdf_viewer)
include Hyrax::FormFields(:with_video_embed)
include PdfBehavior
include VideoEmbedBehavior::Validation
end
1 change: 1 addition & 0 deletions app/forms/image_resource_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ class ImageResourceForm < Hyrax::Forms::ResourceForm(ImageResource)
include Hyrax::FormFields(:image_resource)
include Hyrax::FormFields(:with_pdf_viewer)
include Hyrax::FormFields(:with_video_embed)
include PdfBehavior
include VideoEmbedBehavior::Validation
end
14 changes: 9 additions & 5 deletions app/helpers/pdf_js_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ def query_param
end

def render_show_pdf_behavior_checkbox?
return unless Flipflop.default_pdf_viewer?
return if params[:id].nil?
# we are showing PDF.js based on the FlipFlop value
# instead of checking for the property value.
# TODO: Valkyrize PDF.js feature
false
# return unless Flipflop.default_pdf_viewer?
# return if params[:id].nil?

doc = SolrDocument.find params[:id]
# doc = SolrDocument.find params[:id]

presenter = @_controller.show_presenter.new(doc, current_ability)
presenter.file_set_presenters.any?(&:pdf?)
# presenter = @_controller.show_presenter.new(doc, current_ability)
# presenter.file_set_presenters.any?(&:pdf?)
end
end
7 changes: 4 additions & 3 deletions app/models/concerns/pdf_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,20 @@ class CustomShowPdfDownloadButtonTerm < Vocabulary('http://id.loc.gov/vocabulary

module PdfBehavior
extend ActiveSupport::Concern
# TODO: Valkyrize PDF.js feature

included do
property :show_pdf_viewer, predicate: RDF::CustomShowPdfViewerTerm.show_pdf_viewer, multiple: false do |index|
index.as :stored_searchable
# index.as :stored_searchable
end

# rubocop:disable Metrics/LineLength
property :show_pdf_download_button, predicate: RDF::CustomShowPdfDownloadButtonTerm.show_pdf_download_button, multiple: false do |index|
index.as :stored_searchable
# index.as :stored_searchable
end
# rubocop:enable Metrics/LineLength

after_initialize :set_default_show_pdf_viewer, :set_default_show_pdf_download_button
# after_initialize :set_default_show_pdf_viewer, :set_default_show_pdf_download_button
end

private
Expand Down
10 changes: 6 additions & 4 deletions app/presenters/hyku/work_show_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,13 @@ def user_can_feature_collection?
# End Featured Collections Methods

def show_pdf_viewer?
return unless Flipflop.default_pdf_viewer?
return unless show_pdf_viewer
return unless file_set_presenters.any?(&:pdf?)
Flipflop.default_pdf_viewer?
# TODO: Valkyrize PDF.js feature
# return unless Flipflop.default_pdf_viewer?
# return unless show_pdf_viewer
# return unless file_set_presenters.any?(&:pdf?)

show_pdf_viewer.first.to_i.positive?
# show_pdf_viewer.first.to_i.positive?
end

def show_pdf_download_button?
Expand Down
11 changes: 11 additions & 0 deletions public/pdf.js/images/annotation-check.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions public/pdf.js/images/annotation-comment.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions public/pdf.js/images/annotation-help.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions public/pdf.js/images/annotation-insert.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions public/pdf.js/images/annotation-key.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions public/pdf.js/images/annotation-newparagraph.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions public/pdf.js/images/annotation-noicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions public/pdf.js/images/annotation-note.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions public/pdf.js/images/annotation-paperclip.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions public/pdf.js/images/annotation-paragraph.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions public/pdf.js/images/annotation-pushpin.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/pdf.js/images/cursor-editorFreeText.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions public/pdf.js/images/cursor-editorInk.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/pdf.js/images/findbarButton-next.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/pdf.js/images/findbarButton-previous.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/pdf.js/images/gv-toolbarButton-download.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions public/pdf.js/images/gv-toolbarButton-openinapp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions public/pdf.js/images/loading-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/pdf.js/images/loading-icon.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 9c632d7

Please sign in to comment.