From ded8f48d34406bdf3fbc80a560bd9b4d8da10abf Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 13 Jul 2016 15:20:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=9A=E5=AE=A2=E7=9A=84=E4=BA=8C=E7=BA=A7?= =?UTF-8?q?=E5=9B=9E=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/at_controller.rb | 6 +- app/controllers/blog_comments_controller.rb | 11 +++- app/controllers/users_controller.rb | 5 ++ app/helpers/application_helper.rb | 2 +- app/views/blog_comments/reply.js.erb | 2 +- .../users/_blog_comments_replies.html.erb | 59 +++++++++++++++++++ app/views/users/_reply_to.html.erb | 13 ++++ app/views/users/_user_blog.html.erb | 5 +- 8 files changed, 95 insertions(+), 8 deletions(-) create mode 100644 app/views/users/_blog_comments_replies.html.erb diff --git a/app/controllers/at_controller.rb b/app/controllers/at_controller.rb index 5b29565ad..69c33f90e 100644 --- a/app/controllers/at_controller.rb +++ b/app/controllers/at_controller.rb @@ -47,6 +47,8 @@ class AtController < ApplicationController find_journals_for_message(id) when 'Principal' find_principal(id) + when 'BlogComment' + find_blog_comment(id) when 'All' nil else @@ -166,8 +168,8 @@ class AtController < ApplicationController #BlogComment def find_blog_comment(id) - blog = BlogComment.find(id).blog - blog.users + blog = BlogComment.find(id) + blog.author.watcher_users end end \ No newline at end of file diff --git a/app/controllers/blog_comments_controller.rb b/app/controllers/blog_comments_controller.rb index 4a8de5814..a6e383504 100644 --- a/app/controllers/blog_comments_controller.rb +++ b/app/controllers/blog_comments_controller.rb @@ -130,9 +130,16 @@ class BlogCommentsController < ApplicationController params[:blog_comment][:sticky] = params[:blog_comment][:sticky] || 0 params[:blog_comment][:locked] = params[:blog_comment][:locked] || 0 @blogComment.safe_attributes = params[:blog_comment] - @blogComment.content = @quote + @blogComment.content @blogComment.title = "RE: #{@article.title}" unless params[:blog_comment][:title] - @article.children << @blogComment + if params[:activity_id] + @blogComment.content = params[:blog_comment][:content] + parent = BlogComment.find params[:parent_id] + @blogComment.reply_id = params[:reply_id] + parent.children << @blogComment + else + @blogComment.content = @quote + @blogComment.content + @article.children << @blogComment + end @article.save # @article.update_attribute(:updated_on, @blogComment.updated_on) @user_activity_id = params[:user_activity_id] diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 373b4f514..633254978 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -120,6 +120,11 @@ class UsersController < ApplicationController @is_course = params[:is_course] @is_board = params[:is_board] @type = 'Message' + when 'BlogComment' + @reply = BlogComment.find params[:reply_id] + @user_activity_id = params[:user_activity_id] + @activity_id = params[:activity_id] + @type = 'BlogComment' end respond_to do |format| format.js diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 3a28e4b72..3d8d970b5 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -3141,7 +3141,7 @@ end #获取所有子节点 def get_all_children result, jour - if (jour.kind_of? JournalsForMessage) || (jour.kind_of? Message) + if (jour.kind_of? JournalsForMessage) || (jour.kind_of? Message) || (jour.kind_of? BlogComment) jour.children.each do |jour_child| result << jour_child get_all_children result, jour_child diff --git a/app/views/blog_comments/reply.js.erb b/app/views/blog_comments/reply.js.erb index baf4418e9..f612cfe98 100644 --- a/app/views/blog_comments/reply.js.erb +++ b/app/views/blog_comments/reply.js.erb @@ -5,7 +5,7 @@ $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/user_blog', :locals => {:activity => @article,:user_activity_id =>@user_activity_id}) %>"); // init_activity_KindEditor_data(<%#= @user_activity_id%>,"","87%", 'UserActivity'); <% else%> -$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'blogs/article', :locals => {:activity => @article,:user_activity_id =>@user_activity_id}) %>"); +$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/user_blog', :locals => {:activity => @article,:user_activity_id =>@user_activity_id}) %>"); //init_activity_KindEditor_data(<%#= @user_activity_id%>,"","87%", 'UserActivity'); <% end %> sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", 'UserActivity'); \ No newline at end of file diff --git a/app/views/users/_blog_comments_replies.html.erb b/app/views/users/_blog_comments_replies.html.erb new file mode 100644 index 000000000..181f6698a --- /dev/null +++ b/app/views/users/_blog_comments_replies.html.erb @@ -0,0 +1,59 @@ + \ No newline at end of file diff --git a/app/views/users/_reply_to.html.erb b/app/views/users/_reply_to.html.erb index 8a2909ad4..8358a7d23 100644 --- a/app/views/users/_reply_to.html.erb +++ b/app/views/users/_reply_to.html.erb @@ -44,6 +44,19 @@

<% end%> + <% elsif @type == 'BlogComment' %> + <%= form_for('new_form', :url => {:controller => 'blog_comments',:action => 'reply', :id => reply.id, :blog_id => reply.blog.id}, :method => "post", :remote => true) do |f| %> + + <%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>@user_activity_id %> + <%= hidden_field_tag 'activity_id',params[:activity_id],:value =>@activity_id %> + <%= hidden_field_tag 'parent_id', params[:parent_id], :value => reply.id %> + <%= hidden_field_tag 'reply_id', params[:reply_id], :value => reply.author_id %> +
+ + +
+

+ <% end%> <% end %>
diff --git a/app/views/users/_user_blog.html.erb b/app/views/users/_user_blog.html.erb index 77510c858..868f92979 100644 --- a/app/views/users/_user_blog.html.erb +++ b/app/views/users/_user_blog.html.erb @@ -45,10 +45,11 @@
<%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id} %> - <% comments = activity.children.reorder("created_on desc").limit(3) %> + <% all_comments = []%> + <% comments = get_all_children(all_comments, activity)[0..2] %> <% if count > 0 %>
- <%= render :partial => 'users/all_replies', :locals => {:comments => comments}%> + <%= render :partial => 'users/blog_comments_replies', :locals => {:comments => comments, :user_activity_id => user_activity_id, :type => 'BlogComment', :activity_id =>activity.id}%>
<% end %>