refactor cropped images into explore/posts/intro
This commit is contained in:
@@ -26,6 +26,13 @@ article.post-preview {
|
|||||||
margin: auto;
|
margin: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.large-cropped {
|
||||||
|
height: auto;
|
||||||
|
weidth: auto;
|
||||||
|
float: none;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
&[data-tags~=animated]:before, &[data-file-ext=swf]:before, &[data-file-ext=webm]:before, &[data-file-ext=mp4]:before, &[data-file-ext=zip]:before {
|
&[data-tags~=animated]:before, &[data-file-ext=swf]:before, &[data-file-ext=webm]:before, &[data-file-ext=mp4]:before, &[data-file-ext=zip]:before {
|
||||||
@include animated-icon;
|
@include animated-icon;
|
||||||
}
|
}
|
||||||
|
|||||||
12
app/logical/image_cropper.rb
Normal file
12
app/logical/image_cropper.rb
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
class ImageCropper
|
||||||
|
def self.enabled?
|
||||||
|
Danbooru.config.aws_sqs_cropper_url.present?
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.notify(post)
|
||||||
|
if post.is_image?
|
||||||
|
sqs = SqsService.new(Danbooru.config.aws_sqs_cropper_url)
|
||||||
|
sqs.send_message("#{post.id},https://#{Danbooru.config.hostname}/data/#{post.md5}.#{post.file_ext}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -142,6 +142,15 @@ class Post < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# this is for the 640x320 version
|
||||||
|
def cropped_file_url
|
||||||
|
if Danbooru.config.use_s3_proxy?(self)
|
||||||
|
"/cached/data/cropped/large/#{md5}.jpg"
|
||||||
|
else
|
||||||
|
"/data/cropped/large/#{md5}.jpg"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def large_file_url
|
def large_file_url
|
||||||
if has_large?
|
if has_large?
|
||||||
if Danbooru.config.use_s3_proxy?(self)
|
if Danbooru.config.use_s3_proxy?(self)
|
||||||
|
|||||||
@@ -200,9 +200,8 @@ class Upload < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def notify_cropper(post)
|
def notify_cropper(post)
|
||||||
if Danbooru.config.aws_sqs_cropper_url && is_image?
|
if ImageCropper.enabled?
|
||||||
sqs = SqsService.new(Danbooru.config.aws_sqs_cropper_url)
|
ImageCropper.notify(post)
|
||||||
sqs.send_message("#{post.id},https://#{Danbooru.config.hostname}/data/#{post.md5}.#{post.file_ext}")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -32,7 +32,14 @@ class PostPresenter < Presenter
|
|||||||
tag_param = nil
|
tag_param = nil
|
||||||
end
|
end
|
||||||
html << %{<a href="#{path}/#{post.id}#{tag_param}">}
|
html << %{<a href="#{path}/#{post.id}#{tag_param}">}
|
||||||
html << %{<img itemprop="thumbnailUrl" src="#{post.preview_file_url}" alt="#{h(post.tag_string)}">}
|
|
||||||
|
if options[:show_cropped] && post.has_cropped?
|
||||||
|
src = post.cropped_file_url
|
||||||
|
else
|
||||||
|
src = post.preview_file_url
|
||||||
|
end
|
||||||
|
|
||||||
|
html << %{<img itemprop="thumbnailUrl" src="#{src}" alt="#{h(post.tag_string)}">}
|
||||||
html << %{</a>}
|
html << %{</a>}
|
||||||
|
|
||||||
if options[:pool]
|
if options[:pool]
|
||||||
@@ -56,6 +63,7 @@ class PostPresenter < Presenter
|
|||||||
|
|
||||||
def self.preview_class(post, description = nil)
|
def self.preview_class(post, description = nil)
|
||||||
klass = "post-preview"
|
klass = "post-preview"
|
||||||
|
klass << " large-cropped" if post.has_cropped? && options[:show_cropped]
|
||||||
klass << " pooled" if description
|
klass << " pooled" if description
|
||||||
klass << " post-status-pending" if post.is_pending?
|
klass << " post-status-pending" if post.is_pending?
|
||||||
klass << " post-status-flagged" if post.is_flagged?
|
klass << " post-status-flagged" if post.is_flagged?
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
<% @presenter.each do |tag, post_set| %>
|
<% @presenter.each do |tag, post_set| %>
|
||||||
<div class="posts">
|
<div class="posts">
|
||||||
<h2><%= link_to tag, posts_path(:tags => tag) %></h2>
|
<h2><%= link_to tag, posts_path(:tags => tag) %></h2>
|
||||||
<%= post_set.presenter.post_previews_html(self) %>
|
<%= post_set.presenter.post_previews_html(self, show_cropped: true) %>
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
Reference in New Issue
Block a user