博客的详情页回复分页、博客列表的回复数未统计二级回复

This commit is contained in:
cxt 2016-10-09 11:12:44 +08:00
parent f332f2a469
commit 3b44f05b2b
6 changed files with 86 additions and 66 deletions

View File

@ -40,7 +40,14 @@ class BlogCommentsController < ApplicationController
end
def show
@article = BlogComment.find(params[:id])
all_comments = []
@replies = get_all_children(all_comments, @article)
@reply_count = @replies.count
@page = params[:page] ? params[:page].to_i + 1 : 0
@limit = 10
@replies = @replies[@page * @limit..@page * @limit + 9]
respond_to do |format|
format.js
format.html {render :layout=>'new_base_user'}
end
end

View File

@ -0,0 +1,63 @@
<% @replies.each do |comment| %>
<script type="text/javascript">
$(function(){
showNormalImage('reply_content_<%= comment.id %>');
autoUrl('reply_content_<%= comment.id %>');
});
</script>
<li class="homepagePostReplyContainer" nhname="reply_rec">
<div class="homepagePostReplyPortrait">
<%= link_to image_tag(url_to_avatar(comment.creator_user), :width => 33, :height => 33, :alt => "用户头像"), user_url_in_org(comment.creator_user.id) %>
</div>
<div class="homepagePostReplyDes" onmouseover="$('#delete_reply_<%=comment.id%>').show();" onmouseout="$('#delete_reply_<%=comment.id%>').hide();">
<%= render :partial => 'users/message_contents', :locals => {:comment => comment}%>
<% if !comment.content_detail.blank? %>
<div class="homepagePostReplyContent break_word list_style upload_img table_maxWidth" id="reply_content_<%= comment.id %>">
<%= comment.content_detail.html_safe %>
</div>
<div class="orig_reply mb10 mt-10">
<div class="reply">
<span class="reply-right">
<span id="reply_praise_count_<%=comment.id %>">
<%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%>
</span>
<span style="position: relative" class="fr mr20">
<%= link_to(
l(:button_reply),
{:controller => 'blog_comments', :action => 'quote', :user_id => comment.author_id, :blog_id => comment.blog_id, :id => comment.id},
:remote => true,
:method => 'get',
:title => l(:button_reply)) if !@article.locked? %>
<span id="reply_iconup_<%=comment.id %>" class="reply_iconup02" style="display: none"> ︿</span>
</span>
<% if comment.author == User.current %>
<%= link_to(
l(:button_delete),
{:controller => 'blog_comments', :action => 'destroy', :id => comment.id},
:method => :delete,
:id => "delete_reply_#{comment.id}",
:class => 'fr mr20 undis',
:data => {:confirm => l(:text_are_you_sure)},
:title => l(:button_delete)
) %>
<% end %>
</span>
<div class="cl"></div>
</div>
</div>
<p id="reply_message_<%= comment.id%>"></p>
<% end %>
</div>
<div class="cl"></div>
</li>
<% end %>
<% if @reply_count > @page * @limit + 10 %>
<div id="more_blog_replies">
<div class="detail_cont_hide clearfix">
<span class="orig_icon" >&darr; </span>
<span class="orig_icon" style="display:none;" > &uarr;</span>
<%= link_to '点击展开更多回复', blog_comment_path(@article, :page => @page),:remote=>true %>
</div>
</div>
<% end %>

View File

@ -105,13 +105,13 @@
<div class="cl"></div>
</div>
<div class="cl"></div>
<% all_comments = []%>
<% all_replies = get_all_children(all_comments, @article) %>
<% count= all_replies.count %>
<%# all_comments = []%>
<%# all_replies = get_all_children(all_comments, @article) %>
<%# count= all_replies.count %>
<div class="homepagePostReply">
<div class="homepagePostReplyBanner">
<div class="homepagePostReplyBannerCount">回复
<sapn class="mr15"><%= count>0 ? "#{count}" : "" %></sapn>
<sapn class="mr15"><%= @reply_count > 0 ? "#{@reply_count}" : "" %></sapn>
<span style="color: #cecece;">▪</span>
<span id="praise_count_<%= @article.id %>">
<%= render :partial => "praise_tread/praise", :locals => {:activity => @article, :user_activity_id => @article.id, :type => "activity"} %>
@ -120,62 +120,10 @@
<div class="homepagePostReplyBannerTime"></div>
</div>
<% comments = all_replies %>
<% if count > 0 %>
<%# comments = all_replies %>
<% if @reply_count > 0 %>
<div class="" id="reply_div_<%= @article.id %>">
<% comments.each do |comment| %>
<script type="text/javascript">
$(function(){
showNormalImage('reply_content_<%= comment.id %>');
autoUrl('reply_content_<%= comment.id %>');
});
</script>
<li class="homepagePostReplyContainer" nhname="reply_rec">
<div class="homepagePostReplyPortrait">
<%= link_to image_tag(url_to_avatar(comment.creator_user), :width => 33, :height => 33, :alt => "用户头像"), user_url_in_org(comment.creator_user.id) %>
</div>
<div class="homepagePostReplyDes" onmouseover="$('#delete_reply_<%=comment.id%>').show();" onmouseout="$('#delete_reply_<%=comment.id%>').hide();">
<%= render :partial => 'users/message_contents', :locals => {:comment => comment}%>
<% if !comment.content_detail.blank? %>
<div class="homepagePostReplyContent break_word list_style upload_img table_maxWidth" id="reply_content_<%= comment.id %>">
<%= comment.content_detail.html_safe %>
</div>
<div class="orig_reply mb10 mt-10">
<div class="reply">
<span class="reply-right">
<span id="reply_praise_count_<%=comment.id %>">
<%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%>
</span>
<span style="position: relative" class="fr mr20">
<%= link_to(
l(:button_reply),
{:controller => 'blog_comments', :action => 'quote', :user_id => comment.author_id, :blog_id => comment.blog_id, :id => comment.id},
:remote => true,
:method => 'get',
:title => l(:button_reply)) if !@article.locked? %>
<span id="reply_iconup_<%=comment.id %>" class="reply_iconup02" style="display: none"> ︿</span>
</span>
<% if comment.author == User.current %>
<%= link_to(
l(:button_delete),
{:controller => 'blog_comments', :action => 'destroy', :id => comment.id},
:method => :delete,
:id => "delete_reply_#{comment.id}",
:class => 'fr mr20 undis',
:data => {:confirm => l(:text_are_you_sure)},
:title => l(:button_delete)
) %>
<% end %>
</span>
<div class="cl"></div>
</div>
</div>
<p id="reply_message_<%= comment.id%>"></p>
<% end %>
</div>
<div class="cl"></div>
</li><% end %>
<%= render :partial => 'blog_comment_show_replies' %>
</div>
<% end %>

View File

@ -0,0 +1 @@
$("#more_blog_replies").replaceWith("<%= escape_javascript(render :partial => 'blog_comment_show_replies')%>");

View File

@ -36,12 +36,13 @@
<% end %>
<div class="cl"></div>
</li>
<% count=0 %>
<% if activity.parent %>
<% count=activity.parent.children.count%>
<% else %>
<% count=activity.children.count%>
<% end %>
<% all_comments = [] %>
<% count = (get_all_children all_comments, activity).count %>
<%# if activity.parent %>
<%# count=activity.parent.children.count%>
<%# else %>
<%# count=activity.children.count%>
<%# end %>
<li class="ml15">
<span class="grayTxt">发布:<%= format_time(activity.created_on) %></span>
<span class="grayTxt">更新:<%= format_time(activity.updated_on) %></span>

View File

@ -39,7 +39,7 @@
<div class="homepageRight mt0">
<div class="homepageRightBanner">
<div class="f16 fl fontGrey3">
<%= @user.name%>的博客
<%= @user.show_name%>的博客
</div>
</div>