<div xmlns="http://www.w3.org/1999/xhtml"
     xmlns:xi="http://www.w3.org/2001/XInclude"
     xmlns:py="http://genshi.edgewall.org/" py:strip="True">
     <xi:include href="${g.allura_templates}/lib.html"/>
  <?python from allura.lib.security import has_artifact_access ?>
 	<div class="content">
 		<div class="row">
 			<div class="column grid_12">
        <a href="" class="btn ico-l sidebar_thread_reply" py:if="has_artifact_access('post', value)()"><b class="ui-icon ui-icon-arrowreturnthick-1-w"></b> <span>Reply</span></a>
        <py:if test="limit">
          ${widgets.page_list.display(limit=limit, page=page, count=count)}
        </py:if>
        <div id="comment">
          <py:def function="show_post(post, indent, supress_promote=False)">
            <li>
              ${widgets.post.display(value=post, show_subject=show_subject, indent=indent, supress_promote=supress_promote)}
              <ul>
              <py:for each="child in post.descendants()"
                      py:if="child.status == 'ok' and child.parent_id == post._id">
                <li>${show_post(child, indent+1)}</li>
              </py:for>
              </ul>
            </li>
          </py:def>
          <py:with vars="posts=value.find_posts(page=page, limit=limit)">
            <div py:if="not posts" style="clear:both">No posts found</div>
            <py:if test="posts">
              <ul py:for="t in value.create_post_threads(posts)">
                ${show_post(t['post'], 0, supress_promote=True)}
              </ul>
            </py:if>
          </py:with>
          <div id="allow_moderate" py:if="has_artifact_access('moderate', value)()"/>
          <py:if test="has_artifact_access('post', value)()">
            <div id="tag_thread_holder" style="display:none">
              ${widgets.tag_post.display(value=value,submit_text='Tag Post', action=value.url() + 'tag')}
            </div>
          </py:if>
        </div>
        <div style="clear:both"/>
        <div py:if="limit">
          ${widgets.page_list.display(limit=limit, page=page, count=count)}
          ${widgets.page_size.display(limit=limit)}
        </div>
      </div>
    </div>
  </div>
  <py:if test="has_artifact_access('post', value)()">
    <div id="new_post_holder">
      <a name="comment"></a>
      <div class="row reply">
      	<div class="column grid_1 tcenter">
      		<p class="gravatar">
                ${gravatar(c.user)}<br/><br/>
      			<a href="${c.user.url()}">$c.user.display_name</a>
      		</p>
      	</div>
      	<div class="column grid_8">
          ${widgets.edit_post.display(submit_text='New Post', action=value.url() + 'post')}
        </div>
      </div>
    </div>
  </py:if>
  &nbsp;
</div>
