votes: fixup various minor issues.
* Add a gap between thumbnails on mobile. * Adjust CSS for scores and vote buttons. * Include "Private favorites" as an incentive on the user upgrade page. * Fix vote buttons not being visible beneath thumbnails on mobile. * Fix the "Show scores" link not preserving the current page number. * Fix vote buttons being unintentionally enabled for all thumbnails by default. * Fix banned and restricted users being able to favorite posts by tagging them with `fav:self`. * Fix search engines being able to crawl /posts?view=score pages. * Fix broken tests.
This commit is contained in:
@@ -6,8 +6,3 @@
|
||||
max-width: 160px;
|
||||
}
|
||||
}
|
||||
|
||||
span.post-favcount a {
|
||||
color: var(--text-color);
|
||||
&:hover { text-decoration: underline; }
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ class PostPreviewComponent < ApplicationComponent
|
||||
delegate :image_width, :image_height, :file_ext, :file_size, :duration, :is_animated?, to: :media_asset
|
||||
delegate :media_asset, to: :post
|
||||
|
||||
def initialize(post:, tags: "", show_deleted: false, show_cropped: true, show_votes: true, link_target: post, pool: nil, similarity: nil, recommended: nil, compact: nil, size: nil, current_user: CurrentUser.user, **options)
|
||||
def initialize(post:, tags: "", show_deleted: false, show_cropped: true, show_votes: false, link_target: post, pool: nil, similarity: nil, recommended: nil, compact: nil, size: nil, current_user: CurrentUser.user, **options)
|
||||
super
|
||||
@post = post
|
||||
@tags = tags.presence
|
||||
|
||||
@@ -55,8 +55,8 @@
|
||||
<% end %>
|
||||
</p>
|
||||
<% elsif show_votes -%>
|
||||
<p class="desc">
|
||||
<div class="post-preview-score text-sm mt-1">
|
||||
<%= render_post_votes post, current_user: current_user %>
|
||||
</p>
|
||||
</div>
|
||||
<% end -%>
|
||||
<% end -%>
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
@import "../../javascript/src/styles/base/000_vars.scss";
|
||||
|
||||
article.post-preview {
|
||||
width: 154px;
|
||||
margin: 0 10px 10px 0;
|
||||
text-align: center;
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
vertical-align: top;
|
||||
overflow: hidden;
|
||||
|
||||
a {
|
||||
display: inline-block;
|
||||
@@ -119,38 +117,16 @@ body[data-current-user-can-approve-posts="true"] .post-preview {
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 660px) {
|
||||
@media screen and (min-width: 660px) {
|
||||
article.post-preview {
|
||||
margin: 0;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
display: inline-block;
|
||||
|
||||
a {
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
img {
|
||||
max-width: 33.3vw;
|
||||
max-height: 33.3vw;
|
||||
border: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
.user-disable-cropped-false {
|
||||
article.post-preview {
|
||||
width: 33.3%;
|
||||
height: 33.3vw;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
img {
|
||||
width: 33.3vw;
|
||||
height: 33.3vw;
|
||||
|
||||
&.has-cropped-false {
|
||||
object-fit: cover;
|
||||
}
|
||||
}
|
||||
width: 154px;
|
||||
margin: 0 10px 10px 0;
|
||||
vertical-align: top;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 660px) {
|
||||
article.post-preview img {
|
||||
border: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@import "../../javascript/src/styles/base/000_vars.scss";
|
||||
|
||||
.post-votes {
|
||||
// Fix it so that the vote buttons don't move when the score changes width.
|
||||
// XXX duplicated from app/components/comment_component/comment_component.scss
|
||||
@@ -7,10 +9,11 @@
|
||||
min-width: 1.25em;
|
||||
white-space: nowrap;
|
||||
vertical-align: middle;
|
||||
|
||||
a {
|
||||
color: var(--text-color);
|
||||
&:hover { text-decoration: underline; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.posts-container {
|
||||
.post-score a {
|
||||
@include inactive-link;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<div class="post-votes-tooltip thin-scrollbar">
|
||||
<div class="text-center text-muted">
|
||||
+<%= post.up_score %> / <%= post.down_score %> <%= upvote_ratio %>
|
||||
<div class="text-center text-muted whitespace-nowrap">
|
||||
+<%= post.up_score %> / -<%= post.down_score.abs %> <%= upvote_ratio %>
|
||||
</div>
|
||||
|
||||
<div class="post-voters">
|
||||
|
||||
@@ -28,6 +28,8 @@ $spacer: 0.25rem; /* 4px */
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.whitespace-nowrap { white-space: nowrap; }
|
||||
|
||||
.leading-none { line-height: 1; }
|
||||
|
||||
.absolute { position: absolute; }
|
||||
@@ -45,6 +47,7 @@ $spacer: 0.25rem; /* 4px */
|
||||
.mx-0\.5 { margin-left: 0.5 * $spacer; margin-right: 0.5 * $spacer; }
|
||||
.mx-2 { margin-left: 2 * $spacer; margin-right: 2 * $spacer; }
|
||||
|
||||
.mt-1 { margin-top: 1 * $spacer; }
|
||||
.mt-2 { margin-top: 2 * $spacer; }
|
||||
.mt-4 { margin-top: 4 * $spacer; }
|
||||
.mt-8 { margin-top: 8 * $spacer; }
|
||||
|
||||
@@ -41,11 +41,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
#posts #posts-container {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
.posts-container {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 0.25rem;
|
||||
|
||||
&.user-disable-cropped-false article.post-preview img.has-cropped-true {
|
||||
object-fit: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,6 +115,7 @@ module PostSets
|
||||
|
||||
def hide_from_crawler?
|
||||
return true if current_page > 50
|
||||
return true if show_votes?
|
||||
return true if artist.present? && artist.is_banned?
|
||||
return false if query.is_empty_search? || query.is_simple_tag? || query.is_metatag?(:order, :rank)
|
||||
true
|
||||
|
||||
@@ -548,9 +548,11 @@ class Post < ApplicationRecord
|
||||
pool&.add!(self)
|
||||
|
||||
when /^fav:(.+)$/i
|
||||
raise User::PrivilegeError unless Pundit.policy!(CurrentUser.user, Favorite).create?
|
||||
Favorite.create(post: self, user: CurrentUser.user)
|
||||
|
||||
when /^-fav:(.+)$/i
|
||||
raise User::PrivilegeError unless Pundit.policy!(CurrentUser.user, Favorite).create?
|
||||
Favorite.destroy_by(post: self, user: CurrentUser.user)
|
||||
|
||||
when /^(up|down)vote:(.+)$/i
|
||||
|
||||
@@ -35,9 +35,9 @@
|
||||
<%= render PopupMenuComponent.new do |menu| %>
|
||||
<% menu.item do %>
|
||||
<% if params[:view] == "score" %>
|
||||
<%= link_to "Hide scores", posts_path(tags: params[:tags], view: nil) %>
|
||||
<%= link_to "Hide scores", posts_path(tags: params[:tags], page: params[:page], limit: params[:limit], view: nil), rel: "nofollow" %>
|
||||
<% else %>
|
||||
<%= link_to "Show scores", posts_path(tags: params[:tags], view: "score") %>
|
||||
<%= link_to "Show scores", posts_path(tags: params[:tags], page: params[:page], limit: params[:limit], view: "score"), rel: "nofollow" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<div id="posts" class="user-disable-cropped-<%= CurrentUser.user.disable_cropped_thumbnails? %>">
|
||||
<div id="posts-container">
|
||||
<div id="posts">
|
||||
<div class="posts-container user-disable-cropped-<%= CurrentUser.user.disable_cropped_thumbnails? %>">
|
||||
<% if post_set.shown_posts.empty? %>
|
||||
<%= render "post_sets/blank" %>
|
||||
<% else %>
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
<% if params[:tags].blank? && @post_set.current_page == 1 %>
|
||||
<% canonical_url root_url(host: Danbooru.config.hostname) %>
|
||||
<% else %>
|
||||
<% canonical_url posts_url(host: Danbooru.config.hostname, tags: params[:tags], page: params[:page], limit: params[:limit]) %>
|
||||
<% end %>
|
||||
|
||||
<% noindex if @post_set.hide_from_crawler? %>
|
||||
|
||||
@@ -70,6 +70,12 @@
|
||||
<td>2,000</td>
|
||||
<td>5,000</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Private Favorites</td>
|
||||
<td>no</td>
|
||||
<td>yes</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Favorite Groups</td>
|
||||
<td>3</td>
|
||||
|
||||
Reference in New Issue
Block a user