<style>
  .top-nav {
    line-height: 1.4em;
  }

  .top-nav a {
    display: inline-block;
  }
</style>

<div class="editor-image-upload" style="position:fixed;top:50px;z-index:10000;padding:10px;background:white;left:0;right:0;text-align:center;border-bottom:2px solid gray">
  <input type="file" id="image-upload" name="file" accept="image/*" style="display:none">
  <button id="image-upload-button">Upload Image</button>
  <span style="width:500px;display:inline-block">
    <label id="image-upload-file-label">(or paste URL directly into Social Image input)</label>
    <input type="submit" id='image-upload-submit' value="Upload" style="display:none">
    <input id="uploaded-image" style="display:none;width:100%;" />
  </span>
</div>
<br />
<br />
<style>.top-nav a {
  border: 1px solid #d8d8d8;
  font-weight: bold;
  margin-right: 3px;
  font-size: 0.66em
}</style>
<h3 class="top-nav">
  <a href="/internal/articles" class="btn <%= "btn-success" if params[:state].blank? %>">Hot</a>
  <a href="/internal/articles?state=chronological" class="btn <%= "btn-success" if params[:state] == "chronological" %>">Chronological</a>
  Not Buffered:
  <a href="/internal/articles?state=not-buffered-0.25" class="btn <%= "btn-success" if params[:state] == "not-buffered-0.25" %>">6hr</a>
  <a href="/internal/articles?state=not-buffered-1" class="btn <%= "btn-success" if params[:state] == "not-buffered-1" %>">1d</a>
  <a href="/internal/articles?state=not-buffered-7" class="btn <%= "btn-success" if params[:state] == "not-buffered-7" %>">7d</a>
  <a href="/internal/articles?state=satellite" class="btn <%= "btn-success" if params[:state] == "satellite" %>">🛰</a>
  Top:
  <a href="/internal/articles?state=top-3" class="btn <%= "btn-success" if params[:state] == "top-3" %>">3mo</a>
  <a href="/internal/articles?state=boosted-additional-articles" class="btn <%= "btn-success" if params[:state] == "boosted-additional-articles" %>">Boosted</a>
</h3>
<br />
<% if params[:state] && params[:state].include?("top-") && params[:state] != "top-3" && params[:state] != "top-6" %>
  <h1 style="color:red">
    <%= params[:state] %>-months
  </h1>
<% end %>

<% @pending_buffer_updates.each do |buffer_update| %>
  <div class="row">
    <h2><%= buffer_update.article.title %></h2>
    <h4>Score: <%= buffer_update.article.score %></h4>
    <hr />
              <%= HTML_Truncator.truncate(buffer_update.article.processed_html,
                                        50, ellipsis: '<a class="comment-read-more" href="' + buffer_update.article.path + '">... Read Entire Post</a>').html_safe %>
    <hr />
    <code><b><%= Tag.find_by(id: buffer_update.tag_id)&.name || buffer_update.social_service_name %>:</b></code>
    <form action="/internal/buffer_updates/<%= buffer_update.id %>" accept-charset="UTF-8" method="post">
      <input name="utf8" type="hidden" value="✓">
      <input type="hidden" name="authenticity_token" value="<%= form_authenticity_token %>" />
      <input type="hidden" name="_method" value="patch" />
      <input type="hidden" name="status" value="confirmed" />
      <textarea name="body_text" style="height: 100px"><%= buffer_update.body_text %></textarea>
      <br />
      <button value="confirmed" name="status" class="btn btn-success">confirm</button>
    </form>
    <form action="/internal/buffer_updates/<%= buffer_update.id %>" accept-charset="UTF-8" method="post">
      <input name="utf8" type="hidden" value="✓">
      <input type="hidden" name="authenticity_token" value="<%= form_authenticity_token %>" />
      <input type="hidden" name="_method" value="patch" />
      <input type="hidden" name="status" value="dismissed" />
      <button value="dismissed" name="status" class="btn btn-danger">dismiss</button>
    </form>
  </div>
<% end %>

<% if @featured_articles && @featured_articles.any? %>
  <h1>Manually Featured Articles</h1>
  <% @featured_articles.each do |article| %>
    <%= render "individual_article", article: article %>
  <% end %>
<% end %>

<div class="row" style="font-size:1.5em;border:0px">
  <h1>All Articles</h1>
  <%= paginate @articles %>
</div>

<% @articles.each do |article| %>
  <%= render "individual_article", article: article %>
<% end %>

<div class="row" style="font-size:1.5em;border:0px">
  <%= paginate @articles %>
</div>

<%= render "article_script" %>
