2014-01-16 03:21:05 +01:00
|
|
|
|
2014-01-16 03:17:32 +01:00
|
|
|
<% @threads.each do |thread| %>
|
2014-01-16 03:21:05 +01:00
|
|
|
<ol class="comments comments1">
|
|
|
|
<% comments_by_parent = thread.group_by(&:parent_comment_id) %>
|
|
|
|
<% subtree = comments_by_parent[nil] %>
|
|
|
|
<% ancestors = [] %>
|
|
|
|
|
|
|
|
<% while subtree %>
|
|
|
|
<% if (comment = subtree.shift) %>
|
2014-01-16 04:25:20 +01:00
|
|
|
<li>
|
2014-01-16 03:21:05 +01:00
|
|
|
<%= render "comments/comment", :comment => comment,
|
|
|
|
:show_story => ancestors.empty? %>
|
|
|
|
|
|
|
|
<% if (children = comments_by_parent[comment.id]) %>
|
|
|
|
<% ancestors << subtree %>
|
|
|
|
<% subtree = children %>
|
|
|
|
<ol class="comments">
|
|
|
|
<% else %>
|
2014-01-16 04:25:20 +01:00
|
|
|
<ol class="comments"></ol></li>
|
2014-01-16 03:21:05 +01:00
|
|
|
<% end %>
|
|
|
|
<% elsif (subtree = ancestors.pop) %>
|
2014-01-16 04:25:20 +01:00
|
|
|
</ol></li>
|
2012-06-30 21:14:35 +02:00
|
|
|
<% end %>
|
|
|
|
<% end %>
|
2014-01-16 03:21:05 +01:00
|
|
|
</ol>
|
2014-01-16 03:17:32 +01:00
|
|
|
<% end %>
|