diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index e6d4e39c63ba534911b61490d6664563d9100753..f99a4001b4c44ee005c480974d06a29da9a7aefc 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -56,6 +56,7 @@ class StatusMessagesController < ApplicationController end end photos.update_all(:pending => false, :public => public_flag) + photos.each{|x| x.queue_post_process} end if request.env['HTTP_REFERER'].include?("people") diff --git a/app/models/jobs/process_photo.rb b/app/models/jobs/process_photo.rb new file mode 100644 index 0000000000000000000000000000000000000000..c761b210246c9d9f4c91279597738beeef5cb20b --- /dev/null +++ b/app/models/jobs/process_photo.rb @@ -0,0 +1,13 @@ +# Copyright (c) 2010, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3 or later. See +# the COPYRIGHT file. + + +module Job + class ProcessPhoto < Base + @queue = :photos + def self.perform_delegate(photo_id) + Photo.find(photo_id).image.post_process + end + end +end diff --git a/app/models/photo.rb b/app/models/photo.rb index 0718887a7b608de97effc1350d614a89d16c2cd3..2d7b1911157ab332835ed325b5959c911f7f216e 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -85,6 +85,10 @@ class Photo < Post {:thumb_url => url(:thumb_medium), :id => id, :album_id => nil} end + def queue_processing_job + Resque.enqueue(Job::ProcessPhoto, self.id) + end + def mutable? true end diff --git a/app/views/shared/_add_contact.html.haml b/app/views/shared/_add_contact.html.haml index 2515fd4eda2e793cb66af6fc673b79f16adea152..063f40d63d5920beabae81af63c1b63663226fea 100644 --- a/app/views/shared/_add_contact.html.haml +++ b/app/views/shared/_add_contact.html.haml @@ -2,7 +2,6 @@ -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. - %h5 = t('aspects.manage.add_a_new_contact') = info_text(t('.enter_a_diaspora_username')) @@ -22,4 +21,3 @@ %li.error.hidden #message = link_to t('.know_email'), new_user_invitation_path - diff --git a/app/views/shared/_stream_element.html.haml b/app/views/shared/_stream_element.html.haml index 4347b229d8e0b5884c0aa378b250d265e33e8420..9dc23052052f25b55fb12fb6a6503cf3a8e11f1f 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') - .thumb_small= person_image_link(post.author, :size => :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 32940a47029b264f4b285a67c905aa0c78c9ad54..02307026fcbe0a65838e0676b9dff0d80c040de2 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] - .thumb_small= link_to (image_tag photo.url(:thumb_small)), photo_path(photo) + = link_to (image_tag photo.url(:thumb_small), :class => 'thumb_small'), photo_path(photo) - else - for photo in photos[1..photos.size] - .thumb_small= link_to (image_tag photo.url(:thumb_small)), photo_path(photo) + = link_to (image_tag photo.url(:thumb_small), :class => 'thumb_small'), photo_path(photo) = markdownify(post.text, :youtube_maps => post[:youtube_titles]) - else diff --git a/app/views/status_messages/show.mobile.haml b/app/views/status_messages/show.mobile.haml index 619d2002674fcc6c4d31ec2ddafa46d9169cc649..9e3d790b26d5b76f9babb01ee1f22c8ed360adb8 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 - .thumb_small= link_to (image_tag photo.url(:thumb_small)), photo.url(:thumb_medium) + = link_to (image_tag photo.url(:thumb_small), :class => 'thumb_small'), photo.url(:thumb_medium) .info %span.time diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 07899c7b443c8dbbc0d6146374f6aa1be93c62a9..35b70a3ac9ac01c12628f268510caedd61080096 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -1071,7 +1071,7 @@ label img.thumb_small :max-height 50px :max-width 50px -img.thumb_mediumimg +img.thumb_medium :max-height 100px :max-width 100px img.thumb_large @@ -1079,7 +1079,7 @@ img.thumb_large :max-width 300px img.scaled_full :max-height 700px - :width 700px + :max-width 700px #thumbnails a diff --git a/spec/models/jobs/process_photo_spec.rb b/spec/models/jobs/process_photo_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..6dd4f9a99873d95fc3a33a72c2bb3c59cfe5c8f3 --- /dev/null +++ b/spec/models/jobs/process_photo_spec.rb @@ -0,0 +1,11 @@ +require 'spec_helper' + +describe Job::ProcessPhoto do + it 'calls post_process on an image uploader' do + photo = mock() + photo.should_receive(:image).and_return(photo) + photo.should_receive(:post_process) + Photo.should_receive(:find).with(1).and_return(photo) + Job::ProcessPhoto.perform(1) + end +end diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index 0fc483b899d95f80948d44379758493a030fbfff..e3cdaf5099777062c6016cd8e6d4323a9a2ec31c 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -155,6 +155,13 @@ describe Photo do end end + describe '#queue_processing_job' do + it 'should queue a resque job to process the images' do + Resque.should_receive(:enqueue).with(Job::ProcessPhoto, @photo.id) + @photo.queue_processing_job + end + end + context "deletion" do before do @status_message = @user.build_post(:status_message, :text => "", :to => @aspect.id)