journalduhacker/app/views/stories/show.html.erb
joshua stein 700d338b23 unbreak story previews
@comments is nil, but there's no point in showing an empty comment
tree anyway
2014-01-20 21:18:03 -06:00

42 lines
1.1 KiB
Plaintext

<ol class="stories">
<%= render :partial => "stories/listdetail",
:locals => { :story => @story, :single_story => true } %>
</ol>
<div class="story_content">
<% if @story.markeddown_description.present? %>
<div class="story_text">
<%= raw @story.markeddown_description %>
</div>
<% end %>
</div>
<% if !@story.previewing %>
<ol class="comments comments1">
<% if @user && !@story.is_gone? && !@story.previewing %>
<li><%= render "comments/commentbox", :comment => @comment %></li>
<% end %>
<% comments_by_parent = @comments.group_by(&:parent_comment_id) %>
<% subtree = comments_by_parent[nil] %>
<% ancestors = [] %>
<% while subtree %>
<% if (comment = subtree.shift) %>
<li>
<%= render "comments/comment", :comment => comment %>
<% if (children = comments_by_parent[comment.id]) %>
<% ancestors << subtree %>
<% subtree = children %>
<ol class="comments">
<% else %>
<ol class="comments"></ol></li>
<% end %>
<% elsif (subtree = ancestors.pop) %>
</ol></li>
<% end %>
<% end %>
</ol>
<% end %>