Skip to content

Commit

Permalink
rubocop suggestion changes in images_controller (#11436)
Browse files Browse the repository at this point in the history
* First time contributor - rubocop suggestion changes in images_controller.rb

#11432 first timer issue
Fixes rubocop suggestions, according to issue a issue linked above

* Update images_controller.rb

Co-authored-by: Tilda Udufo <mathildaudufo@gmail.com>
  • Loading branch information
megative and TildaDares committed Oct 10, 2022
1 parent 5d94500 commit f96b4af
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions app/controllers/images_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ class ImagesController < ApplicationController

def shortlink
size = params[:size] || params[:s]
size = size || :large
size = :thumb if (size.to_s == "t")
size = :thumb if (size.to_s == "thumbnail")
size = :medium if (size.to_s == "m")
size = :large if (size.to_s == "l")
size = :original if (size.to_s == "o")
size ||= :large
size = :thumb if size.to_s == 't'
size = :thumb if size.to_s == 'thumbnail'
size = :medium if size.to_s == 'm'
size = :large if size.to_s == 'l'
size = :original if size.to_s == 'o'
image = Image.find(params[:id])
if image.is_image?
path = URI.parse(image.path(size)).path
else
path = URI.parse(image.path(:original)).path # PDFs etc don't get resized
end
path = if image.is_image?
URI.parse(image.path(size)).path
else
URI.parse(image.path(:original)).path # PDFs etc don't get resized
end
redirect_to path
end

Expand All @@ -30,25 +30,25 @@ def create
filetype = params[:data].split(';').first.split('/').last
@image = Image.new(uid: current_user.uid,
photo: params[:data],
photo_file_name: 'dataurl.' + filetype)
photo_file_name: "dataurl.#{filetype}")
@image.save!
else
@image = Image.new(uid: current_user.uid,
photo: params[:image][:photo],
title: params[:image][:title],
notes: params[:image][:notes])
end
@image.nid = Node.find(params[:nid].to_i).nid unless params[:nid].nil? || params[:nid] == 'undefined' || params[:nid].to_i == 0
@image.nid = Node.find(params[:nid].to_i).nid unless params[:nid].nil? || params[:nid] == 'undefined' || params[:nid].to_i.zero?
if @image.save!
render json: {
id: @image.id,
url: @image.shortlink,
full: 'https://' + request.host.to_s + '/' + @image.path(:large),
full: "https://#{request.host}/#{@image.path(:large)}",
filename: @image.photo_file_name,
href: @image.shortlink, # Woofmark/PublicLab.Editor
title: @image.photo_file_name,
results: [{ # Woofmark/PublicLab.Editor
href: @image.shortlink + "." + @image.filetype,
href: "#{@image.shortlink}.#{@image.filetype}",
title: @image.photo_file_name
}]
}
Expand Down

0 comments on commit f96b4af

Please sign in to comment.