root/discussion/thread.tt
<div class="add-new-comment">
<a href="[% c.uri_for( '/discussion', discussion.id, 'add-comment' ) %]">Add a new comment</a>
</div>
<div class="comment-thread">
[%- can_like = c.controller('Discussion').can_like %]
[%- VIEW comment_thread %]
[%- nest_depth = 0 %]
[%- BLOCK list %]
[%- nest_depth = nest_depth + 1 %]
[%- FOREACH comment IN item %]
[%- NEXT IF comment.spam %]
<div class="comment_container">
<a name="comment-[% comment.id %]"></a>
[%- IF comment.hidden %]
<small><i>comment removed by moderator</i></small>
<div class="comment_links">
[%- IF c.user.has_role( 'Comment Moderator' ) %]
[ <a href="[% c.uri_for( '/discussion', discussion.id, 'reply-to', comment.id ) %]">Reply to this comment</a>
| <a href="#comment-[% comment.id %]">Link to this comment</a>
| <a href="[% c.uri_for( '/discussion', discussion.id, 'hide', comment.id ) %]">Show this comment</a>
| <a href="[% c.uri_for( '/discussion', discussion.id, 'delete', comment.id ) %]">Delete this comment[% IF comment.children.size > 0 %] and all replies[% END %]</a>
[%- IF c.user.has_role( 'Discussion Admin' ) %]
| <a href="[% c.uri_for( '/discussion', discussion.id, 'spam', comment.id ) %]">Mark as spam</a>
[%- END %]
]
[%- END %]
</div>
[%- ELSE %]
<div class="collapsed" id="collapsed_[% comment.id %]"
[%- IF discussion.comments.size >= 50 AND nest_depth >= 3 %] style="display:block;"
[%- ELSE %] style="display:none;"
[%- END %]>
[% comment.title _ ' - ' IF comment.title %]
Posted by
[% IF comment.author_type == 'Site User' -%]
<a href="[% c.uri_for( '/user', comment.author.username ) %]">[% comment.author.display_name || comment.author.username | html %]</a>
[%- ELSIF comment.author_type == 'Unverified' %]
[%- IF comment.author_link -%]
<a href="[% comment.author_link | url %]">[% comment.author_name | html %]</a>
[%- ELSE -%]
[% comment.author_name | html %]
[%- END -%]
[%- ELSE %]
Anonymous
[%- END %]
at [% comment.posted.strftime('%H:%M') %] on [% comment.posted.day %] [% comment.posted.month_abbr %] [% comment.posted.year %]
(<a href="#" onClick="javascript:document.getElementById('collapsed_[% comment.id %]').style.display='none';document.getElementById('expanded_[% comment.id %]').style.display='block';">expand</a>)
</div>
<div class="expanded" id="expanded_[% comment.id %]"
[%- IF discussion.comments.size >= 50 AND nest_depth >= 3 %] style="display:none;"
[%- ELSE %] style="display:block;"
[%- END %]>
<div class="comment_header">
[%- IF comment.author_type == 'Site User' %]
[%- IF comment.author.profile_pic %]
<img class="user_icon" src="[% c.uri_for( '/static/cms-uploads/user-profile-pics', comment.author.username, comment.author.profile_pic ) %]" alt="">
[%- END %]
[%- END %]
<h3>[% comment.title | html %]</h3>
<div class="comment_byline">
Posted by
[% IF comment.author_type == 'Site User' %]
<a href="[% c.uri_for( '/user', comment.author.username ) %]">[% comment.author.display_name || comment.author.username | html %]</a>
[%- ELSIF comment.author_type == 'Unverified' %]
[%- IF comment.author_link -%]
<a href="[% comment.author_link | url %]">[% comment.author_name | html %]</a>
[%- ELSE -%]
[% comment.author_name | html %]
[%- END -%]
[%- ELSE %]
Anonymous
[%- END %]
at [% comment.posted.strftime('%H:%M') %] on [% comment.posted.day %] [% comment.posted.month_abbr %] [% comment.posted.year %]
</div>
</div>
<div class="comment_body">
[% comment.body | html_line_break %]
</div>
<div class="links_container">
<div class="comment_likes">
[%- IF can_like == 'Anonymous' OR c.user_exists %]
[%- IF ( c.user_exists AND comment.liked_by_user( c.user.id ) )
OR ( comment.liked_by_anon( c.request.address ) AND NOT c.user_exists ) %]
<a href="[% c.uri_for( '/discussion', discussion.id, 'like', comment.id ) %]" title="You like this (click to undo)"><img src="/static/images/likes.png" alt="Thumbs up" class="likes-image"></a>
[%- ELSE %]
<a href="[% c.uri_for( '/discussion', discussion.id, 'like', comment.id ) %]" title="Like this comment"><img src="/static/images/likes.png" alt="Thumbs up" class="likes-image"></a>
[%- END %]
[%- ELSE %]
<img src="/static/images/likes.png" alt="Thumbs up" class="likes-image">
[%- END %]
<div class="like-count">
<a href="[% c.uri_for( '/discussion', discussion.id, 'like', comment.id ) %]" title="You like this (click to undo)">[% comment.like_count -%]
[%- IF comment.like_count == 1 %] like[% ELSE %] likes[% END %]</a>
</div>
</div>
<div class="comment_links">
<a href="[% c.uri_for( '/discussion', discussion.id, 'reply-to', comment.id ) %]" title="Reply to this comment">Reply</a>
| <a href="#comment-[% comment.id %]" title="Link directly to this comment">Link</a>
[%- IF c.user.has_role( 'Comment Moderator' ) %]
| <a href="[% c.uri_for( '/discussion', discussion.id, 'hide', comment.id ) %]" title="Hide this comment">Hide</a>
| <a href="[% c.uri_for( '/discussion', discussion.id, 'delete', comment.id ) %]" title="Delete this comment[% IF comment.children.size > 0 %] and all replies[% END %]">Delete</a>
[%- IF c.user.has_role( 'Discussion Admin' ) %]
| <a href="[% c.uri_for( '/discussion', discussion.id, 'spam', comment.id ) %]">Mark as spam</a>
[%- END %]
[%- END %]
</div>
</div>
</div>
[%- END %]
</div>
<div class="comment_children_container">
[%- IF comment.children %]
[% view.print(comment.children.list) %]
[%- END %]
</div>
[%- END %]
[%- END %]
[%- END %]
</div>
[%- comments = discussion.get_thread -%]
[%- IF comments.size > 0 %]
[%- IF reverse_discussion;
comments = comments.reverse;
END;
%]
[% comment_thread.print(comments) %]
[%- ELSE %]
<p>
No comments.
</p>
[%- END %]
[%- IF comments.size > 0 %]
<p>
<a href="[% c.uri_for( '/discussion', discussion.id, 'add-comment' ) %]">Add a new comment</a>
</p>
[%- END %]