<% provide :title, t(".title", :tags => params[:tags].to_s.tr("_", " ")) %>
<% provide :title, " | #{t("basic.page", :page => page_number)}" if page_number > 1 %>
<% @canonical_url = url_for(:controller => "/post", :action => :index, :tags => params[:tags], :page => params[:page], :only_path => false) %>
<%= render "shared/twitter_card/gallery", :posts => @posts, :url => @canonical_url %>
<div id="post-list">
  <% if @tag_suggestions && @tag_suggestions.any? %>
    <div class="status-notice">
      <%= t('.maybe_you_meant') %>: <%= @tag_suggestions.map {|x| tag_link(x)}.to_sentence({ :two_words_connector => ' or ', :last_word_connector => ', or ' }).html_safe %>
    </div>
  <% end %>

  <div class="sidebar">
    <%= render :partial => "search" %>
    <% if @current_user.is_privileged_or_higher? %>
    <div style="margin-bottom: 1em;" id="mode-box" class="advanced-editing">
      <h5><%= t('.mode') %></h5>
      <form onsubmit="return false;" action="">
        <div>
          <select name="mode" id="mode" onchange="PostModeMenu.change()" onkeyup="PostModeMenu.change()" style="width: 13em;">
            <option value="view"><%= t('.mode_form.view') %></option>
            <option value="edit"><%= t('.mode_form.edit') %></option>
<!--            <option value="rating-s">Rate safe</option>
            <option value="rating-q">Rate questionable</option>
            <option value="rating-e">Rate explicit</option>
            <% if @current_user.is_privileged_or_higher? %>
              <option value="lock-rating">Lock rating</option>
              <option value="lock-note">Lock notes</option>
            <% end %> -->
            <% if @current_user.is_mod_or_higher? %>
              <option value="approve"><%= t('.mode_form.approve') %></option>
            <% end %>
            <option value="flag"><%= t('.mode_form.flag') %></option>
            <option value="apply-tag-script"><%= t('.mode_form.script') %></option>
            <option value="reparent-quick"><%= t('.mode_form.reparent') %></option>
            <% if @searching_pool then %>
              <option value="remove-from-pool"><%= t('.mode_form.pool_remove') %></option>
            <% end %>
          </select>
        </div>
      </form>
    </div>

    <%= render :partial => "tag_script" %>
    <% end %>

    <% if @searching_pool then %>
      <%= t('.pool_view_html', :pool => link_to(@searching_pool.pretty_name, :controller => "pool", :action => "show", :id => @searching_pool.id)) %>
    <% end %>

    <% if @showing_holds_only %>
      <% if !@posts.empty? %>
        <div style="margin-bottom: .5em;">
          <%= link_to_function t('.activate'), "Post.activate_all_posts()" %>
        </div>
      <% end %>
    <% else %>
      <% if @current_user.held_post_count > 0 %>
        <div style="margin-bottom: .5em;">
          <%= t('.held_html', posts: link_to(
            t('common.count.post', count: @current_user.held_post_count),
            { controller: :post, action: :index, tags: "holds:only user:#{@current_user.name} limit:100" },
          )) %>
        </div>
      <% end %>
    <% end %>

    <%= render :partial => 'blacklists' %>
    <%= render :partial => 'tags', :locals => {:include_tag_hover_highlight=>true} %>

    <br />

    <% if CONFIG["can_see_ads"].call(@current_user) %>
    <%= render :partial => "vertical" %>
    <% end %>

    <%= render :partial => 'layouts/twitter_link' %>

  </div>
  <div class="content">
    <% if @ambiguous_tags.any? %>
      <div class="status-notice">
        <%= t('.ambiguous') %>: <%= @ambiguous_tags.map {|x| link_to(x, :controller => :wiki, :action => :show, :title => x)}.join(', ').html_safe %>
      </div>
    <% end %>
     <% if CONFIG["can_see_ads"].call(@current_user) %>
      <%= CONFIG["ad_code_index_bottom"] %>
    <% end %>

    <div id="quick-edit" style="display: none;" class="top-corner-float">
      <%= form_tag(:action => "update") do %>
        <%= text_area_tag "post[tags]", "", :size => "60x2", :id => "post_tags" %>
        <%= submit_tag t('buttons.update') %>
        <%= tag(:input, :type => 'button', :value => t('buttons.cancel'), :class => "cancel") %>
      <h4 style="float: right;"><%= t('.edit_tags') %></h4>
      <% end %>
    </div>

    <%= render :partial => "hover" %>
    <%= render :partial => "posts", :locals => {:posts => @posts} %>

    <div id="paginator">
      <%= will_paginate(@posts) %>
    </div>
  </div>
</div>

<% content_for :post_cookie_javascripts do %>
<script type="text/javascript">
  post_quick_edit = new PostQuickEdit('#quick-edit');

  PostModeMenu.init(<%= j(@searching_pool && @searching_pool.id.to_s) %>)
  Post.cache_sample_urls();
  new TagCompletionBox($("post_tags"));
  if($("tag-script"))
    new TagCompletionBox($("tag-script"));
</script>

<script class="js-preload-posts" type="application/json">
  <%= @preload.map { |post| { id: post.id, url: post.preview_url } }.to_json.html_safe %>
</script>
<% end %>

<% content_for :html_header do %>
  <%= auto_discovery_link_tag :rss, { :controller => '/post', :action => :piclens, :format => :rss, :tags => params[:tags], :page => page_number } %>
  <%= navigation_links(@posts) %>
<% end %>

<%= render :partial => "footer" %>

<% if content_for? :subnavbar %>
  <!-- Align the links to the content, not the window. -->
  <div style="clear: both;">
    <div class="sidebar">&nbsp;</div>
    <div class="footer" style="clear: none;">
      <ul class="flat-list" id="subnavbar">
        <%= yield :subnavbar %>
      </ul>
    </div>
  </div>
  <% @view_flow.set(:subnavbar, "") %>
<% end %>

