Skip to content
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

🐛 Fix for human_readable_label_name not defined #11

Merged
merged 2 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions app/indexers/hyrax/file_set_indexer_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# OVERRIDE Hyrax 3.5.0 to override default_thumbnail and displaying human-readable titles on UV
module Hyrax
module FileSetIndexerDecorator
def generate_solr_document
Expand Down Expand Up @@ -34,6 +35,47 @@ def generate_solr_document

end
end

private

def digest_from_content
return unless object.original_file
object.original_file.digest.first.to_s
end

def original_file_id
return unless object.original_file
if object.original_file.versions.present?
ActiveFedora::File.uri_to_id(object.current_content_version_uri)
else
object.original_file.id
end
end

def file_format
if object.mime_type.present? && object.format_label.present?
"#{object.mime_type.split('/').last} (#{object.format_label.join(', ')})"
elsif object.mime_type.present?
object.mime_type.split('/').last
elsif object.format_label.present?
object.format_label
end
end

def human_readable_label_name(parent)
return unless parent

parent_title = parent.title.first
# The regex should reflect what is set in the `config/initializers/iiif_print.rb`,
# `config.unique_child_title_generator_function`.
page_number = parent_title[/Page \d+/]
return object.label unless page_number

work_title = parent.member_of.first&.title&.first
return parent_title unless work_title

"#{work_title} - #{page_number}"
end
end
end

Expand Down
2 changes: 2 additions & 0 deletions app/models/file_set_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ module FileSetDecorator
end

FileSet.include FileSetDecorator
FileSet.instance_variable_set(:@generated_resource_class, nil)
FileSet.resource_class.send(:include, FileSetDecorator)
Loading