{% load ads betty %}

{% for entry in entries %}
  <bulbs-liveblog-entry
    class="
      liveblog-entry
      {% if request.GET.entry == entry.id %}
        liveblog-entry-shared
      {% endif %}
    "
    entry-id="{{ entry.id }}"
    entry-url="{{ entry.get_absolute_url }}"
    entry-published="{{ entry.published | date:'c' }}"
  >

    {% if request.GET.entry|add:"0" == entry.id|add:"0" %}
      <button
        class="liveblog-entry-reset"
        data-track-action="Entry: Put Back"
        data-track-label="#">
        PUT BACK IN ORDER &times;
      </button>
    {% endif %}

    <div class="liveblog-entry-header">
      {% include 'liveblog/author_card.html' %}
    </div>

    <h1 class="liveblog-entry-headline">{{ entry.headline | safe }}</h1>

    <div
      class="liveblog-entry-body"
      data-track-action="Entry: Content Link">
      {{ entry.body | safe }}
    </div>

    {% for response in entry.responses.all %}
      <div class="liveblog-response">
        <div class="liveblog-avatar">
          {% cropped response.author.avatar '1x1' 100 %}
        </div>

        <div class="liveblog-response-content">
          <div class="liveblog-author-name">
            <a href="{{ response.author.get_absolute_url }}">
              {{ response.author.first_name }} {{ response.author.last_name }}
            </a>
          </div>

          <div class="liveblog-response-body">
            {{ response.body | safe }}
          </div>
        </div>
      </div>
    {% endfor %}


    {% if entry.recirc_content.all %}
      <div class="liveblog-related-header">
        RELATED
      </div>

      {% for recirc_item in entry.recirc_content.all %}
        <div class="liveblog-related-article">
          <a
            data-track-action="Entry: Recirc"
            data-track-label="{{ recirc_item.get_absolute_url }}"
            href="{{ recirc_item.get_absolute_url }}">
            <div class="liveblog-related-image">
              {% cropped recirc_item.thumbnail "1x1" 100 %}
            </div>

            <div class="liveblog-related-meta">
              <div class="liveblog-related-title">
                {{ recirc_item.title | safe }}
              </div>

              {% if content.subhead %}
                <div class="liveblog-related-excerpt">
                  {{ content.subhead | removetags:"p br" | safe }}
                </div>
              {% endif %}

              <div class="liveblog-published-date"></div>
            </div>
          </a>
        </div>
      {% endfor %}
    {% endif %}

    {% include "liveblog/entry_sharetools.html" %}

  </bulbs-liveblog-entry>

  {# Inserts an n ad AFTER the first item and every third item thereafter. #}
  {% if forloop.counter0|add:"3"|divisibleby:"3" %}
    <div class="liveblog-entries-ad-container">
      {% dfp_ad "mobile-only-cube" %}
    </div>
  {% endif %}

{% endfor %}
