hide ugoira preview/video link if it hasn't finished processing
This commit is contained in:
@@ -23,7 +23,7 @@ class PixivUgoiraService
|
||||
def generate_resizes(source_path, output_path, preview_path, delay = true)
|
||||
# Run this a bit in the future to give the upload process time to move the file
|
||||
if delay
|
||||
PixivUgoiraConverter.delay(:queue => Socket.gethostname, :run_at => 2.seconds.from_now).convert(source_path, output_path, preview_path, @frame_data)
|
||||
PixivUgoiraConverter.delay(:queue => Socket.gethostname, :run_at => 2.seconds.from_now, :priority => -1).convert(source_path, output_path, preview_path, @frame_data)
|
||||
else
|
||||
PixivUgoiraConverter.convert(source_path, output_path, preview_path, @frame_data)
|
||||
end
|
||||
|
||||
@@ -152,6 +152,10 @@ class Post < ActiveRecord::Base
|
||||
def has_dimensions?
|
||||
image_width.present? && image_height.present?
|
||||
end
|
||||
|
||||
def has_ugoira_webm?
|
||||
created_at < 1.minute.ago || File.exists?(preview_file_path)
|
||||
end
|
||||
end
|
||||
|
||||
module ImageMethods
|
||||
|
||||
@@ -10,6 +10,11 @@ class PostPresenter < Presenter
|
||||
return ""
|
||||
end
|
||||
|
||||
if post.is_ugoira? && !post.has_ugoira_webm?
|
||||
# ugoira preview gen is async so dont render it immediately
|
||||
return ""
|
||||
end
|
||||
|
||||
path = options[:path_prefix] || "/posts"
|
||||
|
||||
html = %{<article id="post_#{post.id}" class="#{preview_class(post, options[:pool])}" #{data_attributes(post)}>}
|
||||
|
||||
@@ -28,7 +28,13 @@
|
||||
<p id="ugoira-load-progress">Loaded <span id="ugoira-load-percentage">0</span>%</p>
|
||||
<div id="seek-slider" style="display: none; width: <%= @post.image_width - 81 %>px;"></div>
|
||||
</div>
|
||||
<p id="save-video-link"><%= link_to "Save as video (right click and save)", post.large_file_url %></p>
|
||||
<p id="save-video-link">
|
||||
<% if post.has_ugoira_webm? %>
|
||||
<%= link_to "Save as video (right click and save)", post.large_file_url %>
|
||||
<% else %>
|
||||
WebM conversion pending
|
||||
<% end %>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<% content_for(:html_header) do %>
|
||||
|
||||
Reference in New Issue
Block a user