From ae597a62352d5482a5d886490f345ee54f44f5d5 Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Thu, 25 Feb 2021 00:14:17 +0100 Subject: [PATCH] Paperclip cruft removed --- app/models/screenshot.rb | 46 ------------------------------------ doc/README.DeveloperNotes.md | 4 ---- 2 files changed, 50 deletions(-) diff --git a/app/models/screenshot.rb b/app/models/screenshot.rb index 88799a9..4a3b10f 100644 --- a/app/models/screenshot.rb +++ b/app/models/screenshot.rb @@ -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 diff --git a/doc/README.DeveloperNotes.md b/doc/README.DeveloperNotes.md index 3a36b74..7e0e3c7 100644 --- a/doc/README.DeveloperNotes.md +++ b/doc/README.DeveloperNotes.md @@ -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.