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

Don't process images all at once #8

Merged
merged 1 commit into from
Aug 28, 2021
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
13 changes: 13 additions & 0 deletions app/controllers/covers_controller.rb
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= image_tag @artwork, class: "d-block w-100" %>
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
post :archive
post :unarchive
post :toggle_b_side

get :artwork
end
collection do
post :archive_all
Expand Down