diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index baf48d0a7..529274c54 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -42,6 +42,7 @@ class PhotosController < ApplicationController end def create + @time = Benchmark.realtime do begin raise unless params[:photo][:aspect_ids] @@ -91,6 +92,8 @@ class PhotosController < ApplicationController respond_with @photo, :location => photos_path, :error => message raise e end + end + puts @time.inspect end def make_profile_photo diff --git a/app/models/photo.rb b/app/models/photo.rb index 1a60bcca1..0718887a7 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -34,20 +34,22 @@ class Photo < Post photo.random_string = gen_random_string(10) photo.image.store! image_file + photo.update_photo_remote_path + photo + end - unless photo.image.url.match(/^https?:\/\//) + def update_photo_remote_path + unless self.image.url.match(/^https?:\/\//) pod_url = AppConfig[:pod_url].dup pod_url.chop! if AppConfig[:pod_url][-1,1] == '/' - remote_path = "#{pod_url}#{photo.image.url}" + remote_path = "#{pod_url}#{self.image.url}" else - remote_path = photo.image.url + remote_path = self.image.url end name_start = remote_path.rindex '/' - photo.remote_photo_path = "#{remote_path.slice(0, name_start)}/" - photo.remote_photo_name = remote_path.slice(name_start + 1, remote_path.length) - - photo + self.remote_photo_path = "#{remote_path.slice(0, name_start)}/" + self.remote_photo_name = remote_path.slice(name_start + 1, remote_path.length) end def status_message_guid @@ -99,7 +101,7 @@ class Photo < Post { :photo => { :id => self.id, - :url => self.url(:thumb_medium), + :url => self.url, :thumb_small => self.url(:thumb_small), :text => self.text } diff --git a/app/uploaders/image_uploader.rb b/app/uploaders/image_uploader.rb index 8ee8c9abd..61cc524c0 100644 --- a/app/uploaders/image_uploader.rb +++ b/app/uploaders/image_uploader.rb @@ -10,26 +10,43 @@ class ImageUploader < CarrierWave::Uploader::Base end def extension_white_list - %w(jpg jpeg png) + %w(jpg jpeg png gif) end def filename model.random_string + model.id.to_s + File.extname(@filename) if @filename end - version :thumb_small do - process :resize_to_fill => [50,50] + def post_process + unless self.file.file.include? '.gif' + ImageUploader.instance_eval do + version :thumb_small do + process :resize_to_fill => [50,50] + end + + version :thumb_medium do + process :resize_to_fill => [100,100] + end + + version :thumb_large do + process :resize_to_fill => [300,300] + end + + version :scaled_full do + process :resize_to_limit => [700,700] + end + end + + self.recreate_versions! + self.model.update_photo_remote_path + self.model.save + else + puts "you uploaded a gif! congrats!" + end end - version :thumb_medium do - process :resize_to_fill => [100,100] - end - - version :thumb_large do - process :resize_to_fill => [300,300] - end - - version :scaled_full do - process :resize_to_limit => [700,700] - end + version :scaled_full + version :thumb_large + version :thumb_medium + version :thumb_small end diff --git a/app/views/photos/_new_photo.haml b/app/views/photos/_new_photo.haml index 30887ff46..c13cdf0df 100644 --- a/app/views/photos/_new_photo.haml +++ b/app/views/photos/_new_photo.haml @@ -10,7 +10,7 @@ var uploader = new qq.FileUploaderBasic({ element: document.getElementById('file-upload'), params: {'photo' : {'pending' : 'true', 'aspect_ids' : aspectIds}, 'set_profile_image' : "#{set_profile_image if defined?(set_profile_image)}"}, - allowedExtensions: ['jpg', 'jpeg', 'png'], + allowedExtensions: ['jpg', 'jpeg', 'png', 'gif'], action: "#{photos_path}", debug: true, button: document.getElementById('file-upload'), diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index f3fa29859..fc967e74f 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -49,7 +49,7 @@ .span-7.prepend-1 .show_photo_attachments - for photo in @additional_photos - = link_to (image_tag photo.url(:thumb_small)), object_path(photo) + = link_to (image_tag photo.url(:thumb_small), :class => 'thumb_small'), object_path(photo) #photo_edit_options diff --git a/app/views/posts/photo.html.haml b/app/views/posts/photo.html.haml index edcbdf2e6..0ddc2dd16 100644 --- a/app/views/posts/photo.html.haml +++ b/app/views/posts/photo.html.haml @@ -31,6 +31,6 @@ %p - for photo in @post.status_message.photos - = link_to (image_tag photo.url(:thumb_small)), post_path(photo) + .thumb_small= link_to (image_tag photo.url(:thumb_small)), post_path(photo) %p = link_to t('photos.show.permalink'), post_path(@post) diff --git a/app/views/posts/status_message.haml b/app/views/posts/status_message.haml index d2cb3899f..10df97c47 100644 --- a/app/views/posts/status_message.haml +++ b/app/views/posts/status_message.haml @@ -14,7 +14,7 @@ = markdownify(@post.text, :youtube_maps => @post[:youtube_titles]) - for photo in @post.photos - = link_to (image_tag photo.url(:thumb_small)), post_path(photo) + .thumb_small= link_to (image_tag photo.url(:thumb_small)), post_path(photo) .time = how_long_ago(@post) diff --git a/app/views/shared/_author_info.mobile.haml b/app/views/shared/_author_info.mobile.haml index 7ccc8b35f..e36dc40cc 100644 --- a/app/views/shared/_author_info.mobile.haml +++ b/app/views/shared/_author_info.mobile.haml @@ -1,5 +1,5 @@ #author_info.show - = person_image_tag(person, :thumb_small) + .thumb_small= person_image_tag(person, :thumb_small) = link_to person.name, person %br .diaspora_handle diff --git a/app/views/shared/_stream_element.html.haml b/app/views/shared/_stream_element.html.haml index 9dc230520..4347b229d 100644 --- a/app/views/shared/_stream_element.html.haml +++ b/app/views/shared/_stream_element.html.haml @@ -10,7 +10,7 @@ = render 'shared/reshare', :aspects => reshare_aspects, :post => post = link_to image_tag('deletelabel.png'), status_message_path(post), :confirm => t('are_you_sure'), :method => :delete, :remote => true, :class => "delete", :title => t('delete') - = person_image_link(post.author, :size => :thumb_small) + .thumb_small= person_image_link(post.author, :size => :thumb_small) .content .from diff --git a/app/views/shared/_stream_element.mobile.haml b/app/views/shared/_stream_element.mobile.haml index a92fb4aaf..f8a48abbd 100644 --- a/app/views/shared/_stream_element.mobile.haml +++ b/app/views/shared/_stream_element.mobile.haml @@ -7,7 +7,7 @@ %span.time = time_ago_in_words(post.created_at) - = person_image_link(post.author, :size => :thumb_small) + .thumb_small= person_image_link(post.author, :size => :thumb_small) .content .from diff --git a/app/views/status_messages/_status_message.haml b/app/views/status_messages/_status_message.haml index 632a8ecef..32940a470 100644 --- a/app/views/status_messages/_status_message.haml +++ b/app/views/status_messages/_status_message.haml @@ -9,10 +9,10 @@ - if photos.size > 1 - if photos.size >= 8 - for photo in photos[1..8] - = link_to (image_tag photo.url(:thumb_small)), photo_path(photo) + .thumb_small= link_to (image_tag photo.url(:thumb_small)), photo_path(photo) - else - for photo in photos[1..photos.size] - = link_to (image_tag photo.url(:thumb_small)), photo_path(photo) + .thumb_small= link_to (image_tag photo.url(:thumb_small)), photo_path(photo) = markdownify(post.text, :youtube_maps => post[:youtube_titles]) - else diff --git a/app/views/status_messages/show.html.haml b/app/views/status_messages/show.html.haml index f07962c68..04e9bfdf0 100644 --- a/app/views/status_messages/show.html.haml +++ b/app/views/status_messages/show.html.haml @@ -12,7 +12,7 @@ = markdownify(@status_message.text, :youtube_maps => @status_message[:youtube_titles]) - for photo in @status_message.photos - = link_to (image_tag photo.url(:thumb_small)), photo_path(photo) + .thumb_small= link_to (image_tag photo.url(:thumb_small)), photo_path(photo) %p.time = how_long_ago(@status_message) diff --git a/app/views/status_messages/show.mobile.haml b/app/views/status_messages/show.mobile.haml index 8b208e86d..619d20026 100644 --- a/app/views/status_messages/show.mobile.haml +++ b/app/views/status_messages/show.mobile.haml @@ -9,7 +9,7 @@ = markdownify(@status_message.text, :youtube_maps => @status_message[:youtube_titles]) - for photo in @status_message.photos - = link_to (image_tag photo.url(:thumb_small)), photo.url(:thumb_medium) + .thumb_small= link_to (image_tag photo.url(:thumb_small)), photo.url(:thumb_medium) .info %span.time diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 758eac5c6..07899c7b4 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -305,6 +305,8 @@ header :margin :bottom 2em img + :position relative + :display inline :margin :right 1px :bottom -1px @@ -1066,6 +1068,18 @@ label .dim :opacity 0.3 +img.thumb_small + :max-height 50px + :max-width 50px +img.thumb_mediumimg + :max-height 100px + :max-width 100px +img.thumb_large + :max-height 300px + :max-width 300px +img.scaled_full + :max-height 700px + :width 700px #thumbnails a