{% import "macros.html" as macros %}
{% if 'SIDEBAR_QUESTION_HEADER'|show_block_to(request.user) %}
<div class="sidebar-box">
    {{ settings.SIDEBAR_QUESTION_HEADER }}
</div>
{% endif %}
<div class="sidebar-box vote-buttons">
  <h2>{{ settings.WORDS_QUESTION_TOOLS|escape }}</h2>
    <div class="follow-question">
      <button class="js-follow-question-btn btn"
          data-is-on="{{ favorited|as_js_bool }}"
          data-off-prompt-text="{% trans %}Unfollow{% endtrans %}"
          data-on-prompt-text="{% trans %}Follow{% endtrans %}"
          data-on-state-text="{% trans %}Following{% endtrans %}"
          data-off-state-text="{% trans %}Follow{% endtrans %}"
          data-toggle-url="{{ url('toggle_follow_question') }}"
      >
          {% if favorited %}
              {% trans %}Following{% endtrans %}
          {% else %}
              {% trans %}Follow{% endtrans %}
          {% endif %}
      </button>
      <div class="js-question-follower-count">
          {% set follower_count = thread.favourite_count %}
          {% if follower_count > 0 %}
              {% trans count=follower_count %}{{count}} follower{% pluralize %}{{count}} followers{% endtrans %}
          {% endif %}
      </div>
    </div>
    {% if settings.RSS_ENABLED %}
    <a class="js-rss-link with-rss-icon"
        href="{{ url('individual_question_feed',  question.id ) }}"
        title="{% trans %}subscribe to the rss feed{% endtrans %}"
        >{% trans %}subscribe to the rss feed{% endtrans %}
    </a>
    {% endif %}
</div>

{#% include "question/sidebar_sharing_tools.html" %#}

{% if show_public_question_stats %}
<div class="sidebar-box">
    <h2>{% trans %}Stats{% endtrans %}</h2>
    <p>
        {% trans %}Asked{% endtrans %}: <strong>{{ macros.timeago(question.added_at) }}</strong>
    </p>
    <p>
        {% trans %}Seen{% endtrans %}: <strong>{{ thread.view_count|intcomma }} {% trans %}times{% endtrans %}</strong>
    </p>
    <p>
        {% trans %}Last updated{% endtrans %}: <strong title="{{ thread.last_activity_at }}">{{thread.last_activity_at|diff_date}}</strong>
    </p>
</div>
{% endif %}

{% if show_admin_question_stats %}
<div class="sidebar-box">
    <h2>{% trans %}Stats{% endtrans %}</h2>
    <p>
        {% trans %}Asked{% endtrans %}: <strong>{{ macros.timeago(question.added_at) }}</strong>
    </p>
    <h3>{% trans %}Visits{% endtrans %}</h3>
    {% for segment in views_per_segment_name %}
    <p>
        {{ segment.segment_name }}: <strong>{{ segment.views_count|intcomma }} {% trans %}times{% endtrans %}</strong>
    </p>
    {% endfor %}
    <p>
        <a href="{{ url('analytics_activity',
                        activity_segment=analytics_activity_field.QUESTION_VIEWED,
                        content_segment='thread:' ~ thread.id|string,
                        users_segment='all-users',
                        dates='all-time') }}">
            {% trans %}See all visits{% endtrans %}
        </a>
    </p>
    <p>
        <a href="{{ url('analytics_activity',
                        activity_segment=analytics_activity_field.ALL_ACTIVITY,
                        content_segment='thread:' ~ thread.id|string,
                        users_segment='all-users',
                        dates='all-time') }}">
            {% trans %}See all activity{% endtrans %}
        </a>
    </p>
    <p>
        {% trans %}Last updated{% endtrans %}: <strong title="{{ thread.last_activity_at }}">{{thread.last_activity_at|diff_date}}</strong>
    </p>
</div>
{% endif %}

{% if settings.SIDEBAR_QUESTION_SHOW_RELATED and similar_threads.data() %}
    {#% cache 1800 "related_questions" related_questions question.id language_code %#}
    <div class="sidebar-box">
      <h2>{{ settings.WORDS_RELATED_QUESTIONS|escape }}</h2>
        <div class="related-questions">
            {% for thread_dict in similar_threads.data() %}
            <p>
                <a href="{{ thread_dict.url }}">{{ thread_dict.title|escape }}</a>
            </p>
            {% endfor %}
        </div>
    </div>
    {#% endcache %#}
{% endif %}

{% if 'SIDEBAR_QUESTION_FOOTER'|show_block_to(request.user) %}
    <div class="sidebar-box">
        {{ settings.SIDEBAR_QUESTION_FOOTER }}
    </div>
{% endif %}
