Paperclip cruft removed

This commit is contained in:
Christoph Haas 2021-02-25 00:14:17 +01:00
parent 0a5c64d17c
commit ae597a6235
2 changed files with 0 additions and 50 deletions

View file

@ -7,21 +7,9 @@ class Screenshot < ApplicationRecord
# - otherwise show newest first
default_scope { order(approved: :asc, created_at: :desc) }
# Paperclip
has_attached_file :image,
styles: { :large => '800x600>', :thumb => '160x120>' },
default_url: '/images/dummy/no-screenshots-available.svg',
path: ':rails_root/public/screenshots/:id_partition/:style.png',
url: '/screenshots/:id_partition/:style.png'
# validates_attachment_content_type :image, :content_type => 'image/png'
# validates_with AttachmentSizeValidator, :attributes => :image, :less_than => 5.megabytes
# validate :validate_image_is_unique
# validates :delete_reason, length: { in: 5..100 }, allow_nil: true
# Shrine
include ImageUploader::Attachment(:simage) # adds an `simage` virtual attribute
# Calculate how many days ago this screenshot has been uploaded
def age
time_ago_in_words(self.created_at)
@ -47,11 +35,6 @@ class Screenshot < ApplicationRecord
# end
# end
# Return Debshots 1.x path to allow migration of images into Paperclip filesystem schema
# def image_url(size)
# "live/screenshots/approved/#{self.package.name[0]}/#{self.package.name}/#{self.id}_#{size}.png"
# end
# Long status text for public users
def status
text = 'This image '
@ -143,25 +126,6 @@ class Screenshot < ApplicationRecord
#Digest::MD5.base64digest(Net::HTTP.get(URI(url)))
end
# Returns a medium sized image (Papeclip-style)
# def medium_image
# if self.image.attached?
# self.image.variant(
# resize_to_limit: [670, 600]
# ).processed
# end
# end
# # Returns the image variant that links to a medium-size screenshot for the details page
# def large_image_watermarked
# if self.image.attached?
# self.image.variant(
# gravity: 'East',
# draw: 'image Over 0,0 0,0 "public/logo/watermark.png"'
# ).processed
# end
# end
private
# Validator that checks if the image has already been uploaded.
@ -179,14 +143,4 @@ class Screenshot < ApplicationRecord
end
end
# Check that the uploaded file can be handled by ImageMagick and is not broken
# def image_intact?
# begin
# #MiniMagick::Image.open(self.image.blob.open)
# MiniMagick::Image.read(self.image.download)
# rescue MiniMagick::Invalid => exc
# error.add(:image, 'appears to be a broken image file')
# end
# end
end

View file

@ -105,7 +105,3 @@ Images are saved in four ways:
- large image (original image with watermark on the right edge)
- medium image (up to 800x600)
- small image (up to 320x240) for gallery/grid views
Screenshot.image was the Paperclip image attachment.
Screenshot.simage is the Shring image attachment.
I used two different attributes to avoid confusion.