Changes: * Drop Users.id_to_name. * Don't cache Users.name_to_id. * Replace calls to name_to_id with find_by_name when possible. * Don't autodefine creator_name in belongs_to_creator. * Don't autodefine updater_name in belongs_to_updater. * Instead manually define creator_name / updater_name only on models that need to return these fields in the api. id_to_name was cached to reduce the impact of N+1 query patterns in certain places, especially in api responses that return creator_name / updater_name fields. But it still meant we were doing N calls to memcache. Using `includes` to prefetch users avoids this N+1 pattern. name_to_id had no need be cached, it was never used in any performance- sensitive contexts. Avoiding caching also avoids the need to keep these caches consistent.
211 lines
8.7 KiB
Plaintext
211 lines
8.7 KiB
Plaintext
<div id="c-posts">
|
|
<div id="a-show">
|
|
<aside id="sidebar">
|
|
<%= render "posts/partials/common/search", :path => posts_path, :tags => params[:q], :tags_dom_id => "tags" %>
|
|
|
|
<%= render "posts/partials/index/blacklist" %>
|
|
|
|
<section id="tag-list">
|
|
<%= @post.presenter.split_tag_list_html(current_query: params[:q], show_extra_links: CurrentUser.user.is_gold?) %>
|
|
</section>
|
|
|
|
<section id="post-information">
|
|
<h1>Information</h1>
|
|
<%= render "posts/partials/show/information", :post => @post %>
|
|
</section>
|
|
|
|
<section id="post-share">
|
|
<h1>Share</h1>
|
|
<%= render "posts/partials/show/share", :post => @post %>
|
|
</section>
|
|
|
|
<section id="post-options">
|
|
<h1>Options</h1>
|
|
<%= render "posts/partials/show/options", :post => @post %>
|
|
</section>
|
|
|
|
<% if CurrentUser.is_member? %>
|
|
<section id="post-history">
|
|
<h1>History</h1>
|
|
<ul>
|
|
<li><%= fast_link_to "Tags", post_versions_path(:search => {:post_id => @post.id}) %></li>
|
|
<li><%= fast_link_to "Notes", note_versions_path(:search => {:post_id => @post.id}) %></li>
|
|
<li><%= fast_link_to "Moderation", post_events_path(@post.id) %></li>
|
|
<li><%= fast_link_to "Commentary", artist_commentary_versions_path(:search => {:post_id => @post.id}) %></li>
|
|
<li><%= fast_link_to "Replacements", post_replacements_path(:search => {:post_id => @post.id}) %></li>
|
|
</ul>
|
|
</section>
|
|
|
|
<% end %>
|
|
|
|
</aside>
|
|
|
|
<section id="content">
|
|
<% if @post.presenter.has_nav_links?(self) %>
|
|
<%= render "posts/partials/show/nav_links", :post => @post, :position => "top" %>
|
|
<% end %>
|
|
|
|
<%= render "posts/partials/show/notices", :post => @post %>
|
|
|
|
<%= content_tag(:section, { id: "image-container" }.merge(PostPresenter.data_attributes(@post))) do -%>
|
|
<div id="note-container"></div>
|
|
<div id="note-preview"></div>
|
|
<%= render "posts/partials/show/embedded", post: @post %>
|
|
<% end -%>
|
|
|
|
<% if CurrentUser.is_member? %>
|
|
<%= content_tag(:div, class: "fav-buttons fav-buttons-#{@post.is_favorited?}") do %>
|
|
<%= form_tag(favorites_path(post_id: @post.id), method: "post", id: "add-fav-button", "data-remote": true) do %>
|
|
<%= button_tag tag.i(class: "far fa-heart"), class: "ui-button ui-widget ui-corner-all", "data-disable-with": tag.i(class: "fas fa-spinner fa-spin") %>
|
|
<% end %>
|
|
|
|
<%= form_tag(favorite_path(@post.id), method: "delete", id: "remove-fav-button", "data-remote": true) do %>
|
|
<%= button_tag tag.i(class: "fas fa-heart"), class: "ui-button ui-widget ui-corner-all", "data-disable-with": tag.i(class: "fas fa-spinner fa-spin") %>
|
|
<% end %>
|
|
<% end %>
|
|
<% end %>
|
|
|
|
<section id="mark-as-translated-section" style="display: none;">
|
|
<%= form_tag(mark_as_translated_post_path(@post), :class => "simple_form", :method => :put) do |f| %>
|
|
<%= hidden_field_tag :tags_query, params[:q] %>
|
|
<%= hidden_field_tag :pool_id, params[:pool_id] %>
|
|
|
|
<fieldset>
|
|
<label for="post_check_translation">
|
|
<%= check_box "post", "check_translation", :checked => @post.has_tag?("check_translation") %>
|
|
Check translation
|
|
</label>
|
|
|
|
<label for="post_partially_translated">
|
|
<%= check_box "post", "partially_translated", :checked => @post.has_tag?("partially_translated") %>
|
|
Partially translated
|
|
</label>
|
|
</fieldset>
|
|
|
|
<div class="input">
|
|
<%= submit_tag "Mark as translated" %>
|
|
</div>
|
|
<% end %>
|
|
</section>
|
|
|
|
<% if @post.artist_commentary && @post.artist_commentary.any_field_present? %>
|
|
<div id="artist-commentary">
|
|
<%= render "artist_commentaries/show", :artist_commentary => @post.artist_commentary %>
|
|
</div>
|
|
<% end %>
|
|
|
|
<% if @post.presenter.has_nav_links?(self) %>
|
|
<%= render "posts/partials/show/nav_links", :post => @post, :position => "bottom" %>
|
|
<% end %>
|
|
|
|
<menu id="post-sections">
|
|
<li class="active"><a href="#comments">Comments</a></li>
|
|
|
|
<% if RecommenderService.available_for_post?(@post) %>
|
|
<li><a href="#recommended">Recommended</a></li>
|
|
<% end %>
|
|
|
|
<% if CurrentUser.is_member? && @post.visible? %>
|
|
<li><a href="#edit" id="post-edit-link" data-shortcut="e">Edit</a></li>
|
|
<% end %>
|
|
</menu>
|
|
|
|
<% if RecommenderService.available_for_post?(@post) %>
|
|
<section id="recommended" style="display: none;">
|
|
<p><em>Loading...</em></p>
|
|
</section>
|
|
<% end %>
|
|
|
|
<section id="comments">
|
|
<% if !CurrentUser.user.is_builder? %>
|
|
<h2>Before commenting, read the <%= link_to "how to comment guide", wiki_pages_path(:search => {:title => "howto:comment"}) %>.</h2>
|
|
<% end %>
|
|
<%= render "comments/partials/index/list", :comments => @post.comments.visible(CurrentUser.user).includes(:creator), :post => @post, :show_header => false %>
|
|
</section>
|
|
|
|
<section id="notes" style="display: none;">
|
|
<% if @post.has_notes? %>
|
|
<% cache("p/#{@post.id}/n/#{@post.last_noted_at.to_i}") do %>
|
|
<%= render :partial => "notes/note", :collection => @post.notes.active %>
|
|
<% end %>
|
|
<% end %>
|
|
</section>
|
|
|
|
<% if CurrentUser.is_member? && @post.visible? %>
|
|
<section id="edit" style="display: none;">
|
|
<%= render "posts/partials/show/edit", :post => @post %>
|
|
</section>
|
|
<% end %>
|
|
</section>
|
|
</div>
|
|
|
|
<% if CurrentUser.is_member? %>
|
|
<div id="add-to-pool-dialog" title="Add to pool" style="display: none;">
|
|
<%= render "pool_elements/new" %>
|
|
</div>
|
|
|
|
<div id="add-commentary-dialog" title="Add artist commentary" style="display: none;">
|
|
<%= render "artist_commentaries/form", :post => @post %>
|
|
</div>
|
|
|
|
<div id="add-to-favgroup-dialog" title="Add to favorite group" style="display: none;">
|
|
<%= render "favorite_groups/add_to_favgroup_dialog", :post => @post %>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
|
|
<%= post_view_count_js %>
|
|
|
|
<% content_for(:page_title) do %>
|
|
<%= @post.presenter.humanized_essential_tag_string %> - <%= Danbooru.config.app_name %>
|
|
<% end %>
|
|
|
|
<% content_for(:html_header) do %>
|
|
<%= tag.meta name: "description", content: "View this #{@post.image_width}x#{@post.image_height} #{number_to_human_size(@post.file_size)} image" %>
|
|
<meta name="post-id" content="<%= @post.id %>">
|
|
<meta name="post-has-embedded-notes" content="<%= @post.has_embedded_notes? %>">
|
|
<meta name="always-resize-images" content="<%= CurrentUser.user.always_resize_images? %>">
|
|
<%= tag.meta name: "og:title", content: "#{@post.presenter.humanized_essential_tag_string} - #{Danbooru.config.app_name}" %>
|
|
|
|
<% if @post.visible? %>
|
|
<%= tag.meta name: "og:image", content: @post.open_graph_image_url %>
|
|
<% end %>
|
|
|
|
<% if Danbooru.config.enable_post_search_counts %>
|
|
<meta name="report-server" content="<%= Danbooru.config.reportbooru_server %>">
|
|
<% end %>
|
|
|
|
<%= tag.meta name: "canonical", content: post_url(@post, host: Danbooru.config.hostname, protocol: "https") %>
|
|
|
|
<%# Twitter properties %>
|
|
<% if @post.twitter_card_supported? %>
|
|
<meta name="twitter:card" content="summary_large_image">
|
|
<%= tag.meta name: "twitter:site", content: Danbooru.config.twitter_site %>
|
|
<%= tag.meta name: "twitter:title", content: "#{@post.presenter.humanized_essential_tag_string} - #{Danbooru.config.app_name}" %>
|
|
<%= tag.meta name: "twitter:description", content: "View this #{@post.image_width}x#{@post.image_height} #{number_to_human_size(@post.file_size)} image" %>
|
|
|
|
<% if @post.visible? %>
|
|
<%= tag.meta name: "twitter:image", content: @post.open_graph_image_url %>
|
|
<% end %>
|
|
<% end %>
|
|
|
|
<% if @post.rating == "e" %>
|
|
<meta name="rating" content="adult">
|
|
<% end %>
|
|
|
|
<%= tag.meta name: "og:type", content: "website" %>
|
|
<%= tag.meta name: "og:site", content: Danbooru.config.app_name %>
|
|
|
|
<%= auto_discovery_link_tag(:atom, comments_url(:atom, search: { post_id: @post.id }), title: "Comments for post ##{@post.id}") %>
|
|
|
|
<script>
|
|
window._paq = window._paq || [];
|
|
window._paq.push(["setCustomVariable", 1, "rating", '<%= j @post.rating %>', "page"]);
|
|
window._paq.push(["setCustomVariable", 2, "fileSize", <%= @post.file_size.to_i / 100.kilobytes %>, "page"]);
|
|
window._paq.push(["setCustomVariable", 3, "sourceDomain", '<%= j @post.source_domain %>', "page"]);
|
|
window._paq.push(["setCustomVariable", 3, "blocked", <%= @post.levelblocked? %>, "page"]);
|
|
</script>
|
|
<% end %>
|
|
|
|
<%= render "posts/partials/common/secondary_links" %>
|