From f7116ad1c4e074b9e78ce6ad3ee996068b3f8cf1 Mon Sep 17 00:00:00 2001 From: evazion Date: Mon, 14 Oct 2019 21:16:04 -0500 Subject: [PATCH] post previews: fix thumbnail width/height outside post index. Normally thumbnails have a fixed size of 154x154, but that's not always desirable outside of the posts index because it creates empty gaps around thumbnails. --- app/javascript/src/styles/specific/post_tooltips.scss | 1 - app/javascript/src/styles/specific/posts.scss | 5 +++++ app/presenters/post_presenter.rb | 3 ++- app/views/iqdb_queries/_matches.html.erb | 2 +- app/views/posts/show.html+tooltip.erb | 2 +- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/javascript/src/styles/specific/post_tooltips.scss b/app/javascript/src/styles/specific/post_tooltips.scss index 9d94d1da2..2cf1f7681 100644 --- a/app/javascript/src/styles/specific/post_tooltips.scss +++ b/app/javascript/src/styles/specific/post_tooltips.scss @@ -74,7 +74,6 @@ $tooltip-width: 164px * 3 - 10; // 3 thumbnails wide. article.post-preview { margin: 0 8px 0 0; - height: auto; } } diff --git a/app/javascript/src/styles/specific/posts.scss b/app/javascript/src/styles/specific/posts.scss index f86268e3d..23cf5077d 100644 --- a/app/javascript/src/styles/specific/posts.scss +++ b/app/javascript/src/styles/specific/posts.scss @@ -42,6 +42,11 @@ article.post-preview { vertical-align: text-top; } + &.post-preview-compact { + width: auto; + height: auto; + } + .desc { font-size: 80%; margin-bottom: 0; diff --git a/app/presenters/post_presenter.rb b/app/presenters/post_presenter.rb index e864c8ab0..59d364791 100644 --- a/app/presenters/post_presenter.rb +++ b/app/presenters/post_presenter.rb @@ -89,7 +89,7 @@ class PostPresenter < Presenter ApplicationController.render(partial: "posts/partials/index/preview", locals: locals) end - def self.preview_class(post, highlight_score: nil, pool: nil, size: nil, similarity: nil, **options) + def self.preview_class(post, highlight_score: nil, pool: nil, size: nil, similarity: nil, compact: nil, **options) klass = ["post-preview"] # klass << " large-cropped" if post.has_cropped? && options[:show_cropped] klass << "captioned" if pool || size || similarity @@ -100,6 +100,7 @@ class PostPresenter < Presenter klass << "post-status-has-children" if post.has_visible_children? klass << "post-pos-score" if highlight_score && post.score >= 3 klass << "post-neg-score" if highlight_score && post.score <= -3 + klass << "post-preview-compact" if compact klass end diff --git a/app/views/iqdb_queries/_matches.html.erb b/app/views/iqdb_queries/_matches.html.erb index 592f2ec1f..b0020fa24 100644 --- a/app/views/iqdb_queries/_matches.html.erb +++ b/app/views/iqdb_queries/_matches.html.erb @@ -3,7 +3,7 @@

Found <%= pluralize(@matches.length, "similar post") %>:

<% @matches.each do |match| %> - <%= PostPresenter.preview(match["post"], :tags => "status:any", :similarity => match["score"], :size => true) %> + <%= PostPresenter.preview(match["post"], tags: "status:any", similarity: match["score"], size: true, compact: true) %> <% end %> <% else %>

Similar Posts

diff --git a/app/views/posts/show.html+tooltip.erb b/app/views/posts/show.html+tooltip.erb index c3c0afc19..402f53d31 100644 --- a/app/views/posts/show.html+tooltip.erb +++ b/app/views/posts/show.html+tooltip.erb @@ -38,7 +38,7 @@
">
<% if params[:preview].truthy? %> - <%= PostPresenter.preview(@post, show_deleted: true) %> + <%= PostPresenter.preview(@post, show_deleted: true, compact: true) %> <% end %>