-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ESSI-2062] fix iiif urls unaware of external_storage #648
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
58920ea
[ESSI-2062] fix iiif image lookup cases being unaware of external_sto…
aploshay 19a416c
[ESSI-2062] simplify #versioned_lookup_id, #basic_lookup_id split
aploshay d88e152
[ESSI-2062] unify #versioned_lookup_id, #basic_lookup_id split
aploshay 3271267
[ESSI-2062] drop version lookup from FileSet#original_file_id
aploshay 40113a2
[ESSI-2062] revise CollectionBrandingInfo model, specs
aploshay File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
class IIIFFileSetPathService | ||
attr_reader :file_set | ||
|
||
# @param [ActiveFedora::SolrHit, FileSet, Hash, SolrDocument, Hyrax::FileSetPresenter] file_set | ||
def initialize(file_set) | ||
file_set = SolrDocument.new(file_set) if file_set.class.in? [ActiveFedora::SolrHit, Hash] | ||
if [:id, :content_location, :original_file_id].map { |m| file_set.respond_to?(m) }.all? | ||
@file_set = file_set | ||
else | ||
raise StandardError, 'Provided file_set does not meet interface requirements' | ||
end | ||
end | ||
|
||
def lookup_id | ||
@lookup_id ||= versioned_lookup_id | ||
end | ||
|
||
# @return [String] a URL that resolves to an image provided by a IIIF image server | ||
def iiif_image_url(base_url: nil, size: nil) | ||
return unless lookup_id | ||
Hyrax.config.iiif_image_url_builder.call(lookup_id, base_url, size || Hyrax.config.iiif_image_size_default) | ||
end | ||
|
||
# @return [String] a URL that resolves to an info.json file provided by a IIIF image server | ||
def iiif_info_url(base_url) | ||
return unless lookup_id | ||
Hyrax.config.iiif_info_url_builder.call(lookup_id, base_url) | ||
end | ||
|
||
private | ||
def versioned_lookup_id | ||
result = file_set.content_location || file_set.original_file_id | ||
if result.blank? | ||
Rails.logger.warn "original_file_id for #{file_set.id} not found, falling back to Fedora." | ||
# result = Hyrax::VersioningService.versioned_file_id(original_file) | ||
result = versioned_file_id(original_file) if original_file | ||
end | ||
if result.blank? | ||
Rails.logger.warn "original_file for #{file_set.id} not found, versioned_lookup_id failed." | ||
nil | ||
else | ||
result | ||
end | ||
end | ||
|
||
# @return [Hydra::PCDM::File, nil] | ||
def original_file | ||
@original_file ||= | ||
case file_set | ||
when FileSet | ||
file_set.original_file | ||
else | ||
begin | ||
FileSet.find(file_set.id).original_file | ||
rescue => error | ||
Rails.logger.error "original_file lookup for #{file_set.id} raised error: #{error.inspect}" | ||
nil | ||
end | ||
end | ||
end | ||
|
||
# @todo remove after upgrade to Hyrax 3.x | ||
# cherry-picked from Hyrax 3.x VersioningService | ||
# @param [ActiveFedora::File | Hyrax::FileMetadata] content | ||
def versioned_file_id(file) | ||
@versioned_file_id ||= begin | ||
raise StandardError, 'No original_file available for versioning' if file.nil? | ||
versions = file.versions.all | ||
if versions.present? | ||
ActiveFedora::File.uri_to_id versions.last.uri | ||
else | ||
file.id | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module Extensions | ||
module Hyrax | ||
module FileSetPresenter | ||
module ContentLocation | ||
delegate :content_location, to: :solr_document | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pulling these IIIF behaviors into this service presents an opportunity to make some spec tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dlpierce spec tests added, which did indeed lead to some revisions!