Skip to content

Commit

Permalink
♻️ Favor Hyku::Application.path_for over Rails.root
Browse files Browse the repository at this point in the history
Given the existence of Knapsack we need to consider how overrides in
Knapsack will take precedence over Hyku files.  This change handles
cases where we want to use the Knapsack's uploaded thumbnails.

Related to:

- #2010
  • Loading branch information
jeremyf committed Oct 5, 2023
1 parent 966936b commit 4c57b28
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/services/uploaded_collection_thumbnail_path_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ def call(object)

# rubocop:disable Metrics/LineLength, Rails/FilePath, Lint/StringConversionInInterpolation
def uploaded_thumbnail?(collection)
File.exist?("#{Rails.root.to_s}/public/uploads/uploaded_collection_thumbnails/#{collection.id}/#{collection.id}_card.jpg")
File.exist?(File.join(upload_dir(collection), "#{collection.id}_card.jpg"))
end

def upload_dir(collection)
"#{Rails.root.to_s}/public/uploads/uploaded_collection_thumbnails/#{collection.id}"
Hyku::Application.path_for("public/uploads/uploaded_collection_thumbnails/#{collection.id}")
end
# rubocop:enable Metrics/LineLength, Rails/FilePath, Lint/StringConversionInInterpolation
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% thumbnail_path = SolrDocument.find(@collection.id).thumbnail_path %>
<% if thumbnail_path.include?("uploaded_collection_thumbnails") and File.exist? Rails.root.join("public#{::SolrDocument.find(@collection.id).thumbnail_path}") %>
<% if thumbnail_path.include?("uploaded_collection_thumbnails") and File.exist? Hyky::Application.path_for("public#{::SolrDocument.find(@collection.id).thumbnail_path}") %>
<%= image_tag(thumbnail_path, class: "current-thumbnail") %>
<p>Current image: <strong><%= @thumbnail_filename %></strong></p>
<% else %>
Expand Down

0 comments on commit 4c57b28

Please sign in to comment.