{% extends "community/_base.html" %}

{% from "macros/box.html" import m_box_menu, m_box_content %}
{% from "forum/macros.html" import m_postattachments %}


{% block content %}
  {% call m_box_content(_("Recent conversations attachments")) %}
    {% for month, posts in grouped_posts %}
      <h2>{{ month }}</h2>
      <ul class="attachments-archives">
        {% for post in posts %}
          {{ m_postattachments(post) }}
        {% endfor %}
      </ul>
    {% else %}
      <p>{{ _("No attachment has been posted to this community yet") }}</p>
    {% endfor %}
  {% endcall %}
{% endblock %}

{% block sidebar %}
  {% call m_box_menu() %}
    <ul class="nav nav-list">
      {%- set global_actions = actions.for_category('forum:global') %}
      {%- for action in global_actions %}
        <li>{{ action.render() }}</li>
      {%- endfor %}
    </ul>
  {% endcall %}
{% endblock %}


{% macro m_thread(thread) %}
  {%- set thread_href = url_for(".thread", thread_id=thread.id, community_id=g.community.slug) %}
  {%- set thread_length = thread.posts|length %}
  <li>
    <a href="{{ thread_href }}"><b>{{ thread.title }}</b></a>
    {%- if thread_length > 1 %}
    <span class="comments">
      (<i class="fa fa-comments"></i> {{ thread_length-1 }})
        {%- for post in thread.posts %}
          {{ m_postattachments(post) }}
        {%- endfor %}
    </span>
    {%- endif %}
  </li>
{% endmacro %}



