eBooru/app/views/posts/show.html.erb

329 lines
14 KiB
Plaintext

<div id="c-posts">
<div id="a-show">
<aside id="sidebar">
<%= render "posts/partials/common/search", title: "Posts", :tags => params[:q] %>
<%= render "posts/partials/index/blacklist", post_id: @post.id %>
<section id="tag-list">
<%= @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">
<h1>Information</h1>
<%= render "posts/partials/show/information", :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><%= link_to "Tags/Desc", post_versions_path(search: { post_id: @post.id }) %></li>
<li><%= link_to "Notes", note_versions_path(search: { post_id: @post.id }) %></li>
<li><%= link_to "Events", post_events_path(search: { post_id: @post.id }) %></li>
<li><%= link_to "Replacements", post_replacements_path(search: { post_id: @post.id }) %></li>
</ul>
</section>
<% end %>
<section id="post-related-images">
<h1>Related</h1>
<ul>
<li><%= link_to "Sets with this post", post_sets_path(post_id: @post.id), rel: "nofollow" %></li>
<% if IqdbProxy.enabled? && @post.has_preview? %>
<li><%= link_to "Visually similar", iqdb_queries_path(search: { post_id: @post.id }), rel: "nofollow" %></li>
<% end %>
</ul>
</section>
</aside>
<section id="content">
<div id="image-and-nav">
<% if @post.presenter.has_nav_links?(self) %>
<%= render "posts/partials/show/nav_links", :post => @post %>
<div id="nav-links-top" class="ui-corner-all nav-notice">
<%= content_for :nav_links_section %>
</div>
<% end %>
<div id="post-notices-top">
<div class="notice notice-no-shortcuts" style="display: none;" id="flash-shortcut-notice">
Adobe Flash has reached end of life, and no longer works in browsers. Please see <a href="/forum_topics/22535" rel="nofollow">this thread</a> on the forum for details on how you can continue to play this file.
<br>Keyboard shortcuts are disabled on this page because it contains flash.
</div>
<% if CurrentUser.is_janitor? %>
<%= render "posts/partials/show/notices", post: @post %>
<% end %>
</div>
<%= render "ads/leaderboard", tag_string: @post.ad_tag_string %>
<%= tag.section(id: "image-container", class: "blacklistable", **PostPresenter.data_attributes(@post, include_post: true)) do -%>
<div id="note-container"></div>
<div id="note-preview"></div>
<%= render "posts/partials/show/embedded", post: @post %>
<% end -%>
<% if @post.visible? && @post.has_large? %>
<div class="ui-corner-all ui-state-highlight notice notice-resized" id="image-resize-notice" style="<%= CurrentUser.default_image_size != "large" ? "display: none;" : "" %>">
<span>Viewing sample resized to <span id="image-resize-size"><%= number_to_percentage @post.resize_percentage.floor, precision: 0 %></span> of original (<%= link_to "view original", @post.file_url, id: "image-resize-link" %>)</span>
<span style="display: none;">Loading...</span>
</div>
<% end %>
<% if @post.presenter.has_nav_links?(self) %>
<div id="nav-links-bottom" class="ui-corner-all nav-notice">
<%= content_for :nav_links_section %>
</div>
<% end %>
</div>
<section id="image-extra-controls">
<% if CurrentUser.is_member? %>
<div class="image-vote-buttons">
<%= post_vote_block(@post, @post.own_vote, buttons: true) %>
</div>
<%= tag.div(class: "fav-buttons fav-buttons-#{@post.is_favorited?}") do %>
<%= button_tag id: "add-fav-button", class: "button btn-success", "data-pid": @post.id do %>
<%= tag.i(class: "fa-regular fa-star") %>
<span>Favorite</span>
<% end %>
<%= button_tag id: "remove-fav-button", class: "button btn-danger", "data-pid": @post.id do %>
<%= tag.i(class: "fa-solid fa-star") %>
<span>Unfavorite</span>
<% end %>
<% end %>
<% end %>
<% if @post.visible? %>
<div id="image-download-link">
<%= link_to @post.file_url, class: "button btn-warn" do %>
<%= tag.i(class: "fa-solid fa-right-to-bracket fa-rotate-90") %>
<span>Download</span>
<% end %>
</div>
<% end %>
<% if !@post.force_original_size? %>
<div>
<select id="image-resize-selector" class="button btn-neutral">
<option value="original">Original</option>
<option value="fit">Fit (Horizontal)</option>
<option value="fitv">Fit (Vertical)</option>
<% if !@post.is_video? %>
<option value="large">Sample (<%= Danbooru.config.large_image_width %>px)</option>
<% end %>
<% Danbooru.config.video_rescales.keys.each do |size| %>
<% next unless @post.has_sample_size?(size) %>
<option value="<%= size %>">Sample (<%= size %>)</option>
<% end %>
</select>
</div>
<% end %>
</section>
<div class="bottom-notices">
<div class="parent-children">
<% if @post.parent_id && @post.parent_exists? %>
<div class="notice notice-child">
<%= has_parent_message(@post, @parent_post_set) %>
<div id="has-parent-relationship-preview" style="display: none;"><%= @parent_post_set.presenter.post_previews_html(self) %></div>
</div>
<% end %>
<% if @post.has_visible_children? %>
<div class="notice notice-parent">
<%= has_children_message(@post, @children_post_set) %>
<div id="has-children-relationship-preview" style="display: none;"><%= @children_post_set.presenter.post_previews_html(self) %></div>
</div>
<% end %>
</div>
<% if !CurrentUser.is_janitor? %>
<%= render "posts/partials/show/notices", post: @post %>
<% end %>
</div>
<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_translation_check">
<%= check_box "post", "translation_check", :checked => @post.has_tag?("translation_check") %>
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.title.present? %>
<div id="post-title-container" class="styled-dtext">
<details id="title" <%= 'open' %>>
<summary>Title</summary>
<div>
<%= format_text(@post.title, max_thumbs: 0) %>
</div>
</details>
</div>
<% end %>
<% if @post.description.present? %>
<div id="post-description-container" class="styled-dtext">
<details id="description" <%= 'open' unless CurrentUser.description_collapsed_initially? %>>
<summary>Description</summary>
<div>
<%= format_text(@post.description, max_thumbs: 0) %>
</div>
</details>
</div>
<% end %>
<% if @post.transcript.present? %>
<div id="post-transcript-container" class="styled-dtext">
<details id="transcript">
<summary>Transcript</summary>
<div>
<%= format_text(@post.transcript, max_thumbs: 0) %>
</div>
</details>
</div>
<% end %>
<ul class="menu mobile-only">
<li><a href="#image-and-nav">Image</a></li>
<li><a href="#tag-list">Tags/Info</a></li>
</ul>
<%= render "posts/partials/common/inline_blacklist" %>
<menu id="post-sections">
<% unless CurrentUser.hide_comments? %>
<li class="active"><a href="#comments">Comments</a></li>
<% end %>
<% if CurrentUser.is_member? %>
<li><a href="#edit" id="post-edit-link" data-shortcut="e">Edit</a></li>
<% end %>
</menu>
<% unless CurrentUser.hide_comments? %>
<section id="comments">
<%= render "comments/partials/index/list", :comments => @post.comments.visible(CurrentUser.user), :post => @post, :show_header => false %>
</section>
<% end %>
<ul class="menu mobile-only">
<li><a href="#image-and-nav">Image</a></li>
<% unless CurrentUser.hide_comments? %>
<li><a href="#comments">Comments</a></li>
<% end %>
</ul>
<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? %>
<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-to-set-dialog" title="Add to set" style="display: none;">
<%= render "post_sets/add_dialog" %>
</div>
<%= javascript_tag nonce: true do -%>
var uploaderSettings = {
postTags: <%= (@post.presenter.split_tag_list_text + " ").to_json.html_safe %>,
uploadTags: <%= CurrentUser.presenter.favorite_tags_with_types.to_json.html_safe %>,
recentTags: <%= CurrentUser.presenter.recent_tags_with_types.to_json.html_safe %>
};
<% end -%>
<% end %>
<% if @fixup_post_url %>
<%= javascript_tag nonce: true do -%>
// This just fixes up the history path for this page so you don't end up getting the wrong url when navigating.
history.replaceState({}, "", <%= post_path(@post, q: params[:q]).to_json.html_safe %>);
<% end -%>
<% end %>
</div>
<% content_for(:page_title) do %>
#<%= @post.id %>
<% end %>
<% content_for(:html_header) do %>
<% if @post.hide_from_search_engines? %><meta name="robots" content="noindex" /><% end %>
<% if @post.force_original_size? %><meta name="image-override-size" content="original"/><% end %>
<meta name="default-image-size" content="<%= @post.presenter.default_image_size(CurrentUser.user) %>"/>
<%= 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 %>">
<%= tag.meta property: "og:site", content: Danbooru.config.app_name %>
<%= tag.meta property: "og:title", content: "#{@post.presenter.humanized_essential_tag_string} - #{Danbooru.config.app_name}" %>
<%= tag.meta property: "og:url", content: post_url(@post, host: Danbooru.config.hostname, protocol: "https") %>
<% if @post.visible? %>
<% if @post.is_video? && @post.has_sample_size?('original') %>
<meta property="og:type" content="video.other">
<%= tag.meta property: "og:video", content: @post.open_graph_video_url %>
<%= tag.meta property: "og:image", content: @post.open_graph_image_url %>
<meta property="og:video:height" content="<%= @post.image_height %>"/>
<meta property="og:video:width" content="<%= @post.image_width %>"/>
<% else %>
<meta property="og:type" content="website">
<%= tag.meta property: "og:image", content: @post.open_graph_image_url %>
<% end %>
<meta property="og:image:height" content="<%= @post.image_height %>"/>
<meta property="og:image:width" content="<%= @post.image_width %>"/>
<% end %>
<%= tag.meta name: "canonical", content: post_url(@post, host: Danbooru.config.hostname, protocol: "https") %>
<%# Twitter properties %>
<% if @post.twitter_card_supported? && @post.is_image? %>
<meta name="twitter:card" content="summary_large_image">
<%= 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">
<% unless Danbooru.config.adult_content? %>
<meta name="RATING" content="RTA-5042-1996-1400-1577-RTA" />
<% end %>
<% end %>
<% end %>
<%= render "posts/partials/common/secondary_links" %>