Skip to content

Commit

Permalink
Merge pull request #8 from 155pod/bw/artwork-action
Browse files Browse the repository at this point in the history
Don't process images all at once
  • Loading branch information
benjaminwil committed Aug 28, 2021
2 parents 28f61b6 + 610e5cf commit 3950253
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
13 changes: 13 additions & 0 deletions app/controllers/covers_controller.rb
Expand Up @@ -3,6 +3,19 @@ class CoversController < ApplicationController

before_action :password_required, only: [:index, :archive, :archive_all, :update_order]

def artwork
cover = Cover.find(params[:id])

redirect_to_admin unless cover.artwork.attached?

@artwork =
if cover.artwork.variable?
cover.artwork.variant(resize_to_limit: [1440,1440]).processed.url
else
rails_blob_path(cover.artwork, disposition: "inline")
end
end

def new
@cover = Cover.new
end
Expand Down
8 changes: 3 additions & 5 deletions app/views/covers/_list.html.erb
Expand Up @@ -44,11 +44,9 @@
<b>Artwork:</b>
<%= link_to(
cover.artwork.blob.filename.sanitized,
cover.artwork.variable? ?
cover.artwork.variant(resize_to_limit: [1440,1440]).processed.url :
rails_blob_path(cover.artwork, disposition: "inline"),
target: "_blank"
) %><br />
artwork_cover_path(cover), target: "_blank"
) %>
<br />
<% end %>
<% if cover.blurb.present? %>
Expand Down
1 change: 1 addition & 0 deletions app/views/covers/artwork.html.erb
@@ -0,0 +1 @@
<%= image_tag @artwork, class: "d-block w-100" %>
2 changes: 2 additions & 0 deletions config/routes.rb
Expand Up @@ -13,6 +13,8 @@
post :archive
post :unarchive
post :toggle_b_side

get :artwork
end
collection do
post :archive_all
Expand Down

0 comments on commit 3950253

Please sign in to comment.