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)
|
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
|
# Run this a bit in the future to give the upload process time to move the file
|
||||||
if delay
|
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
|
else
|
||||||
PixivUgoiraConverter.convert(source_path, output_path, preview_path, @frame_data)
|
PixivUgoiraConverter.convert(source_path, output_path, preview_path, @frame_data)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -152,6 +152,10 @@ class Post < ActiveRecord::Base
|
|||||||
def has_dimensions?
|
def has_dimensions?
|
||||||
image_width.present? && image_height.present?
|
image_width.present? && image_height.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def has_ugoira_webm?
|
||||||
|
created_at < 1.minute.ago || File.exists?(preview_file_path)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module ImageMethods
|
module ImageMethods
|
||||||
|
|||||||
@@ -10,6 +10,11 @@ class PostPresenter < Presenter
|
|||||||
return ""
|
return ""
|
||||||
end
|
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"
|
path = options[:path_prefix] || "/posts"
|
||||||
|
|
||||||
html = %{<article id="post_#{post.id}" class="#{preview_class(post, options[:pool])}" #{data_attributes(post)}>}
|
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>
|
<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 id="seek-slider" style="display: none; width: <%= @post.image_width - 81 %>px;"></div>
|
||||||
</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>
|
</div>
|
||||||
|
|
||||||
<% content_for(:html_header) do %>
|
<% content_for(:html_header) do %>
|
||||||
|
|||||||
Reference in New Issue
Block a user