Skip to content

Commit

Permalink
reincluding some stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcam-src committed Nov 26, 2024
1 parent 08e9f8a commit d4ede4b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 30 deletions.
60 changes: 30 additions & 30 deletions app/overrides/presenters/hyrax/work_show_presenter_override.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,37 @@ def scholarly?
false
end

# def fetch_primary_fileset_id
# Rails.logger.info 'Hyrax::WorkShowPresenter#fetch_primary_fileset_id'
# res = representative_id.blank? ? member_ids.first : representative_id
# Rails.logger.info "res: #{res}"
# res
# end
def fetch_primary_fileset_id
Rails.logger.info 'Hyrax::WorkShowPresenter#fetch_primary_fileset_id'
res = representative_id.blank? ? member_ids.first : representative_id
Rails.logger.info "res: #{res}"
res
end


# @return FileSetPresenter presenter for the representative FileSets
# def representative_presenter
# # Rails.logger.info "fetch primary check: #{fetch_primary_fileset_id.present?}"
# # Rails.logger.info "Hyrax::WorkShowPresenter#representative_presenter"
# # Rails.logger.info "representative_id: #{representative_id}"
# # Rails.logger.info "member of collection ids: #{member_of_collection_ids.inspect}"
# # Rails.logger.info "member ids: #{member_ids.inspect}"
# condition = representative_id.blank? && member_ids.blank?
# Rails.logger.info "condition: #{condition}"
# return nil if fetch_primary_fileset_id.blank?
# @representative_presenter ||=
# begin
# result = member_presenters([fetch_primary_fileset_id]).first
# # Rails.logger.info "representative_presenter-result: #{result.inspect}"
# return nil if result.try(:id) == id
# # Rails.logger.info "representative_presenter-result-id: #{result.try(:id)}"
# Rails.logger.info "representative_presenter-OR: #{result.try(:representative_presenter) || result}"
# result.try(:representative_presenter) || result
# rescue Hyrax::ObjectNotFoundError
# # Hyrax.logger.warn "Unable to find representative_id #{temp} for work #{id}"
# # Rails.logger.warn "Unable to find representative_id #{temp} for work #{id}"
# # Rails.logger.info "Unable to find representative_id #{temp} for work #{id}"
# return nil
# end
# end
def representative_presenter
# Rails.logger.info "fetch primary check: #{fetch_primary_fileset_id.present?}"
# Rails.logger.info "Hyrax::WorkShowPresenter#representative_presenter"
# Rails.logger.info "representative_id: #{representative_id}"
# Rails.logger.info "member of collection ids: #{member_of_collection_ids.inspect}"
# Rails.logger.info "member ids: #{member_ids.inspect}"
condition = representative_id.blank? && member_ids.blank?
Rails.logger.info "condition: #{condition}"
return nil if fetch_primary_fileset_id.blank?
@representative_presenter ||=
begin
result = member_presenters([fetch_primary_fileset_id]).first
# Rails.logger.info "representative_presenter-result: #{result.inspect}"
return nil if result.try(:id) == id
# Rails.logger.info "representative_presenter-result-id: #{result.try(:id)}"
Rails.logger.info "representative_presenter-OR: #{result.try(:representative_presenter) || result}"
result.try(:representative_presenter) || result
rescue Hyrax::ObjectNotFoundError
# Hyrax.logger.warn "Unable to find representative_id #{temp} for work #{id}"
# Rails.logger.warn "Unable to find representative_id #{temp} for work #{id}"
# Rails.logger.info "Unable to find representative_id #{temp} for work #{id}"
return nil
end
end
end
9 changes: 9 additions & 0 deletions app/views/hyrax/base/_representative_media.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<% if presenter.fetch_primary_fileset_id.present? && presenter.representative_presenter.present? %>
<% if defined?(viewer) && viewer %>
<%= iiif_viewer_display presenter %>
<% else %>
<%= render media_display_partial(presenter.representative_presenter), file_set: presenter.representative_presenter %>
<% end %>
<% else %>
<%= image_tag 'default.png', class: "canonical-image", alt: 'default representative image' %>
<% end %>

0 comments on commit d4ede4b

Please sign in to comment.