gif and delayed processing wip
This commit is contained in:
parent
0aa5193434
commit
516b620148
14 changed files with 69 additions and 33 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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'),
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue