<% provide :title do %><%= @debate.title %><% end %>
<% cache [locale_and_user_status(@debate), @debate, @debate.author, Flag.flagged?(current_user, @debate), @debate_votes] do %>
  <section class="debate-show">
    <div id="<%= dom_id(@debate) %>" class="row">
      <div class="small-12 medium-9 column">
        <%= render "shared/back_link" %>

        <% if current_user && @debate.editable_by?(current_user) %>
          <%= link_to edit_debate_path(@debate), class: 'edit-debate button success small float-right' do %>
            <span class="icon-edit"></span>
            <%= t("debates.show.edit_debate_link") %>
          <% end %>
        <% end %>

        <h1><%= @debate.title %></h1>
        <% if @debate.conflictive? %>
          <div data-alert class="callout alert margin-top">
            <strong><%= t("debates.show.flag") %></strong>
          </div>
        <% end %>

        <div class="debate-info">
          <%= render '/shared/author_info', resource: @debate %>

          <span class="bullet">&nbsp;&bull;&nbsp;</span>
          <%= l @debate.created_at.to_date %>
          <span class="bullet">&nbsp;&bull;&nbsp;</span>
          <span class="icon-comments"></span>&nbsp;
          <%= link_to t("debates.show.comments", count: @debate.comments_count), "#comments" %>
          <span class="bullet">&nbsp;&bull;&nbsp;</span>
          <span class="js-flag-actions">
            <%= render 'debates/flag_actions', debate: @debate %>
          </span>
        </div>

        <%= safe_html_with_links @debate.description %>

        <%= render 'shared/tags', taggable: @debate %>

        <div class="js-moderator-debate-actions margin">
          <%= render 'actions', debate: @debate %>
        </div>
      </div>

      <aside class="small-12 medium-3 column">
        <div class="sidebar-divider"></div>
        <h3><%= t("votes.supports") %></h3>
        <div class="text-center">
          <div id="<%= dom_id(@debate) %>_votes">
           <%= render 'debates/votes', debate: @debate %>
          </div>
        </div>
        <div class="sidebar-divider"></div>
        <h3><%= t("debates.show.share") %></h3>
        <div class="social-share-full">
          <%= social_share_button_tag("#{@debate.title} #{setting['twitter_hashtag']}") %>
          <% if browser.device.mobile? %>
            <a href="whatsapp://send?text=<%= @debate.title %> <%= debate_url(@debate) %>" data-action="share/whatsapp/share">
              <span class="icon-whatsapp whatsapp"></span>
            </a>
          <% end %>
        </div>
    </div>
  </section>
<% end %>

<%= render "comments" %>
