{% extends "misago/base.html" %}
{% load i18n misago_absoluteurl %}


{% block title %}
  {% if paginator.page > 1 %}
    {{ thread.title }} ({% blocktrans with page=paginator.page context "page title pagination" %}page: {{ page }}{% endblocktrans %}) | {{ category.name }} | {{ block.super }}
  {% else %}
    {{ thread.title }} | {{ category.name }} | {{ block.super }}
  {% endif %}
{% endblock title %}


{% block og-title %}{{ thread.title }}{% endblock %}
{% block twitter-title %}{{ thread.title }}{% endblock %}


{% block og-description %}
  {% blocktrans trimmed with starter=thread.starter_name started_on=thread.started_on|date category=category.name context "thread page meta" %}
    Started by {{ starter }} on {{ started_on }} in the {{ category }} category.
  {% endblocktrans %} {% blocktrans trimmed count replies=thread.replies with last_post_on=thread.last_post_on|date context "thread page meta" %}
    {{ replies }} reply, last one from {{ last_post_on }}.
  {% plural %}
    {{ replies }} replies, last one from {{ last_post_on }}.
  {% endblocktrans %}{% if thread.has_best_answer %} {% trans "Answered." context "thread page meta" %}{% endif %}{% if thread.has_best_answer %} {% trans "Closed." context "thread page meta" %}{% endif %}
{% endblock og-description %}


{% block twitter-description %}
  {% blocktrans trimmed with starter=thread.starter_name started_on=thread.started_on|date category=category.name context "thread page meta" %}
    Started by {{ starter }} on {{ started_on }} in the {{ category }} category.
  {% endblocktrans %} {% blocktrans trimmed count replies=thread.replies with last_post_on=thread.last_post_on|date context "thread page meta" %}
    {{ replies }} reply, last one from {{ last_post_on }}.
  {% plural %}
    {{ replies }} replies, last one from {{ last_post_on }}.
  {% endblocktrans %}{% if thread.has_best_answer %} {% trans "Answered." context "thread page meta" %}{% endif %}{% if thread.has_best_answer %} {% trans "Closed." context "thread page meta" %}{% endif %}
{% endblock twitter-description %}


{% block og-url %}{% absoluteurl thread.get_absolute_url %}{% endblock %}
{% block twitter-url %}{% absoluteurl thread.get_absolute_url %}{% endblock %}


{% block og-image %}
{% if settings.og_image_avatar_on_thread and thread.starter %}
  {% with thread.starter.avatars|first as og_image %}
    <meta name="twitter:image" content="{% absoluteurl og_image.url %}" />
    <meta property="og:image" content="{% absoluteurl og_image.url %}" />
    <meta property="og:image:width" content="{{ og_image.size }}" />
    <meta property="og:image:height" content="{{ og_image.size }}" />
  {% endwith %}
{% else %}
  {{ block.super }}
{% endif %}
{% endblock og-image %}


{% block meta-extra %}
{% if paginator.page > 1 %}
  <link rel="canonical" href="{% url url_name slug=thread.slug pk=thread.pk page=paginator.page %}" />
{% else %}
  <link rel="canonical" href="{% url url_name slug=thread.slug pk=thread.pk %}" />
{% endif %}
{% if paginator.previous > 1 %}
  <link rel="prev" href="{% url url_name slug=thread.slug pk=thread.pk page=paginator.previous %}" />
{% elif paginator.first %}
  <link rel="prev" href="{% url url_name slug=thread.slug pk=thread.pk %}" />
{% endif %}
{% if paginator.next %}
  <link rel="next" href="{% url url_name slug=thread.slug pk=thread.pk page=paginator.next %}" />
{% endif %}
{% endblock meta-extra %}


{% block content %}
<div class="page page-thread {% if category.css_class %}page-thread-{{ category.css_class }}{% endif %}">
  {% include "misago/thread/header.html" %}
  <div class="container page-container">

    {% include "misago/thread/toolbar_top.html" %}
    {% if thread.poll %}
      {% include "misago/poll/index.html" with poll=thread.poll %}
    {% endif %}

    {% include "misago/thread/posts/index.html" %}
    {% include "misago/thread/toolbar_bottom.html" %}
    {% include "misago/thread/toolbar_third.html" %}

  </div>
</div>
{% endblock content %}
