diff --git a/app/helpers/posts_helper.rb b/app/helpers/posts_helper.rb index 05167df0c..baf9df0d5 100644 --- a/app/helpers/posts_helper.rb +++ b/app/helpers/posts_helper.rb @@ -40,4 +40,32 @@ module PostsHelper source_link end end + + def belongs_to_parent_message(post, child_post_set) + html = "" + + html << "This post belongs to a " + html << link_to("parent", post_path(post.parent_id)) + html << " (deleted)" if child_post_set.posts.first.is_deleted? + + html << " (#{link_to("learn more", wiki_pages_path(:title => "help:post_relationships"))}) " + + html << link_to("show »".html_safe, "#", :id => "child-relationship-preview-link") + + html.html_safe + end + + def has_children_message(post, parent_post_set) + html = "" + + html << "This post has " + text = parent_post_set.posts.count == 1 ? "a child" : "#{parent_post_set.posts.count} children" + html << link_to(text, posts_path(:tags => "parent:#{post.id}")) + + html << " (#{link_to("learn more", wiki_pages_path(:title => "help:post_relationships"))}) " + + html << link_to("show »".html_safe, "#", :id => "parent-relationship-preview-link") + + html.html_safe + end end diff --git a/app/views/posts/partials/show/_notices.html.erb b/app/views/posts/partials/show/_notices.html.erb index 9e894454c..31f763675 100644 --- a/app/views/posts/partials/show/_notices.html.erb +++ b/app/views/posts/partials/show/_notices.html.erb @@ -48,14 +48,14 @@ <% if post.parent_id %>
- This post belongs to a <%= link_to "parent", post_path(post.parent_id) %> (<%= link_to "learn more", wiki_pages_path(:title => "help:post_relationships") %>) <%= link_to "show »".html_safe, "#", :id => "child-relationship-preview-link" %> + <%= belongs_to_parent_message(post, @child_post_set) %>
<%= @child_post_set.presenter.post_previews_html(self) %>
<% end %> <% if post.has_children? %>
- This post has <%= link_to "children", posts_path(:tags => "parent:#{post.id}") %> (<%= link_to "learn more", wiki_pages_path(:title => "help:post_relationships") %>) <%= link_to "show »".html_safe, "#", :id => "parent-relationship-preview-link" %> + <%= has_children_message(post, @parent_post_set) %>
<%= @parent_post_set.presenter.post_previews_html(self) %>
<% end %>