From 0614793b38db4711053cbcb4fa80d9c8cc492eec Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Fri, 8 Jan 2016 17:38:53 +0100 Subject: DRY up upload and download services --- app/services/projects/download_service.rb | 13 +------------ app/services/projects/upload_service.rb | 13 +------------ 2 files changed, 2 insertions(+), 24 deletions(-) (limited to 'app/services') diff --git a/app/services/projects/download_service.rb b/app/services/projects/download_service.rb index b846a59ed94..6386f57fb0d 100644 --- a/app/services/projects/download_service.rb +++ b/app/services/projects/download_service.rb @@ -16,18 +16,7 @@ module Projects uploader.download!(@url) uploader.store! - filename = uploader.image? ? uploader.file.basename : uploader.file.filename - - escaped_filename = filename.gsub("]", "\\]") - markdown = "[#{escaped_filename}](#{uploader.secure_url})" - markdown.prepend("!") if uploader.image? - - { - 'alt' => filename, - 'url' => uploader.secure_url, - 'is_image' => uploader.image?, - 'markdown' => markdown - } + uploader.to_h end private diff --git a/app/services/projects/upload_service.rb b/app/services/projects/upload_service.rb index 36ccf1cda12..012e82a7704 100644 --- a/app/services/projects/upload_service.rb +++ b/app/services/projects/upload_service.rb @@ -10,18 +10,7 @@ module Projects uploader = FileUploader.new(@project) uploader.store!(@file) - filename = uploader.image? ? uploader.file.basename : uploader.file.filename - - escaped_filename = filename.gsub("]", "\\]") - markdown = "[#{escaped_filename}](#{uploader.secure_url})" - markdown.prepend("!") if uploader.image? - - { - alt: filename, - url: uploader.secure_url, - is_image: uploader.image?, - markdown: markdown - } + uploader.to_h end private -- cgit v1.2.1