{% from "macros/user.html" import m_user_link, m_user_photo %}

{%- macro m_postinfos(post) %}
  {%- set author_href = url_for("social.user", user_id=post.creator.id) %}
  {%- set thread_href = url_for(".thread", thread_id=post.thread_id, community_id=g.community.slug) %}
  <div class="post-infos">
    <span class="date"><small>{{ post.created_at | age(date_threshold='day') }}</small></span>,
    <a href="{{ url_for(post) }}">
      <small>{{ post.thread.title }}</small>
    </a>,
    {% call m_user_link(post.creator) %}
      {{ m_user_photo(post.creator, size=15) }}
      <small>{{ post.creator }}</small>
    {% endcall %}
  </a>
  </div>
{%- endmacro %}

{%- macro m_postattachments(post) %}
  {%- if post.attachments %}
    <hr style="margin-top: 0px;margin-bottom: 0px;">
    <div id="attachments">
      <ul>
        {{ m_postinfos(post) }}
        {%- for attachment in post.attachments %}
          <li>
            <span class="attachment-item">
              <img src="{{ attachment.icon }}" style="vertical-align: middle;"
                  alt=""/>
              <a href="{{ url_for(attachment) }}">{{ attachment.name }}</a>
              ({{ attachment.content_length|filesize }})
            </span>
          </li>
        {%- endfor %}
      </ul>
    </div>
  {%- endif %}
{%- endmacro %}
