[Posts] Mark artist tags linked to the uploader

This commit is contained in:
Earlopain 2022-09-17 14:04:11 +02:00
parent 5ce26fe33a
commit 3dd018a36e
No known key found for this signature in database
GPG Key ID: 6CFB948E15246897
4 changed files with 16 additions and 5 deletions

View File

@ -1801,4 +1801,9 @@ class Post < ApplicationRecord
save
end
def uploader_linked_artists
linked_artists ||= tags.select { |t| t.category == Tag.categories.artist }.filter_map(&:artist)
linked_artists.select { |artist| artist.linked_user_id == uploader_id }
end
end

View File

@ -28,7 +28,7 @@ class TagSetPresenter < Presenter
html.html_safe
end
def post_show_sidebar_tag_list_html(current_query: "")
def post_show_sidebar_tag_list_html(current_query: "", highlighted_tags:)
html = ""
TagCategory.split_header_list.each do |category|
@ -38,7 +38,7 @@ class TagSetPresenter < Presenter
html << %{<h2 class="#{category}-tag-list-header tag-list-header" data-category="#{category}">#{TagCategory.header_mapping[category]}</h2>}
html << %{<ul class="#{category}-tag-list">}
typetags.each do |tag|
html << build_list_item(tag, current_query: current_query)
html << build_list_item(tag, current_query: current_query, highlight: highlighted_tags.include?(tag.name))
end
html << "</ul>"
end
@ -125,7 +125,7 @@ class TagSetPresenter < Presenter
ordered
end
def build_list_item(tag, current_query: "")
def build_list_item(tag, current_query: "", highlight: false)
name = tag.name
count = tag.post_count
category = tag.category
@ -144,6 +144,7 @@ class TagSetPresenter < Presenter
end
html << tag_link(tag, name.tr("_", " "))
html << %(<i class="highlight fas fa-check"></i>) if highlight
if count >= 10_000
post_count = "#{count / 1_000}k"

View File

@ -14,7 +14,12 @@
<meta itemprop="uploadDate" content="<%= post.created_at.iso8601 %>">
</li>
<% if CurrentUser.is_janitor? %>
<li>Uploader: <%= link_to_user(post.uploader) %> <%= user_record_meta(post.uploader) %></li>
<li>
Uploader: <%= link_to_user(post.uploader) %> <%= user_record_meta(post.uploader) %>
<% if post.uploader_linked_artists.any? %>
<i class="uploader-is-artist fas fa-check" title="The uploader is linked to one of the artist tags"></i>
<% end %>
</li>
<% end %>
<% if post.approver %>
<li>Approver: <%= link_to_user(post.approver) %></li>

View File

@ -7,7 +7,7 @@
<section id="tag-list">
<!-- TODO: Lock off these extra items? -->
<%= @post.presenter.post_show_sidebar_tag_list_html(current_query: params[:q]) %>
<%= @post.presenter.post_show_sidebar_tag_list_html(current_query: params[:q], highlighted_tags: @post.uploader_linked_artists.map(&:name)) %>
</section>
<section id="post-information">