<%def name="comment_block(comments)">
-<h1>${len(comments)} comments</h1>
-## XXX make sure these do the right thing when this is a subtree
+<h1>${len(comments)} comment${'' if len(comments) == 1 else 's'}</h1>
<p><a href="${url(controller='comments', action='thread', owner_url=h.get_comment_owner_url(**c.route))}">View all</a></p>
<p><a href="${url(controller='comments', action='reply', owner_url=h.get_comment_owner_url(**c.route))}">Reply</a></p>
${comment_thread(comments)}
</%def>
<%def name="comment_thread(comments)">
-% for comment in comments:
+<%! from floof.model.comments import indent_comments %>\
+% for comment in indent_comments(comments):
+${single_comment(comment)}
+% endfor
+</%def>
+
+<%def name="single_comment(comment)">
+% if hasattr(comment, 'indent'):
+<div class="comment" style="margin-left: ${comment.indent}em;">
+% else:
<div class="comment">
- <div class="user">${comment.user.name}</div>
- <div class="time">${comment.time}</div>
+% endif
+ <div class="header">
+ <div class="user">${comment.user.name}</div>
+ <div class="time">${comment.time}</div>
+ <div class="links">
+ <a href="${url(controller='comments', action='thread', id=comment.id, owner_url=h.get_comment_owner_url(**c.route))}">Link</a>
+ <a href="${url(controller='comments', action='reply', id=comment.id, owner_url=h.get_comment_owner_url(**c.route))}">Reply</a>
+ % if comment.parent:
+ <a href="${url(controller='comments', action='thread', id=comment.parent.id, owner_url=h.get_comment_owner_url(**c.route))}">Parent</a>
+ % endif
+ </div>
+ </div>
<p>${comment.text}</p>
</div>
-% endfor
</%def>