{% import "macro.html.twig" as web_macro %}
<li id="post-{{ post.id }}" data-user-id="{{ author.id }}" class="thread-post thread-post-{{ post.id }} media media-comment user-id-{{author.id}}">
  <div class="media-left">
    {{ web_macro.user_avatar(author, 'user-avatar', 'avatar-sm', true) }}
  </div>

  <div class="media-body">
    <div class="metas title">
      {% include 'thread/post-manage-menu.html.twig' %}
      <a href="{{ path('user_show', {id:author.id}) }}" class="nickname">{{ author.nickname }}</a>
      <span class="bullet">•</span>
      <span class="color-gray">{{post.createdTime|smart_time}} </span>
      {% if author.badgeTitle|default(null) %}<span class="mll color-danger">({{ dict_text('classroomRoles', author.badgeTitle) }}) </span>{% endif %}
    </div>
    <div class="editor-text">{{ post.content|at(post.ats)|raw }}</div>
    {% include 'attachment/widget/list.html.twig' with {targetType:'classroom.thread.post', targetId:post.id} %}
    <div class="comment-sns">
      {% include 'thread/post-interaction.html.twig' %}
    </div>
    <div class="thread-subpost-container subcomments clearfix {% if not post.subposts %}hide{% endif %}">
      <div class="thread-subpost-content">
        {{ render(controller('AppBundle:Thread:subposts', {threadId: post.threadId|default(0), postId:post.id, less:true})) }}
      </div>
      <div class="thread-subpost-morebar clearfix {% if not post.subposts %}hide{% endif %}">
        {% if service.canAccess('post.create', post) %}
          <button class="btn btn-default btn-xs pull-right js-toggle-subpost-form">{{'我也说一句'|trans}}</button>
        {% endif %}
        <span class="thread-subpost-moretext {% if post.subposts <= 5 %}hide{% endif %}"><span class="color-gray">{{'还有%post.subposts%条回复，'|trans({'%post.subposts%': post.subposts - 5})}}</span><a href="javascript:;" class="js-post-more">{{'点击查看'|trans}}</a></span>
      </div>

      {% set goto = goto|default(path('homepage')) %}
      {% if service.canAccess('post.create', post) and app.user %}
      
        {% set postReplyUrl =  postReplyUrl|default(path('thread_post_reply', {threadId:post.threadId, postId:post.id})) %}
        <form method="post" action="{{ postReplyUrl }}" class="thread-subpost-form {% if post.subposts %}hide{% endif %}">
          <div class="form-group">
            <div class="controls">
              <textarea class="form-control" name="content" data-display="{{'内容'|trans}}"></textarea>
            </div>
          </div>
          <div class="form-group">
            <input type="hidden" name="_csrf_token" value="{{ csrf_token('site') }}">
            <button type="submit" data-loading-text="{{'正在发表'|trans}}" class="btn btn-primary btn-sm pull-right">{{'发表'|trans}}</button>
          </div>
        </form>
      {% else %}
        <div class="empty">
          {{'你还没有登录，请先'|trans}}<a href="{{ path('login',{goto:goto}) }}">{{'登录'|trans}}</a>{{'或'|trans}}<a href="{{ path('register',{goto:goto}) }}">{{'注册'|trans}}</a>！
        </div>
      {% endif %}

    </div>
  </div>
</li>
