diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index 660e4d76c..07a3ba393 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -171,6 +171,10 @@ class NewsController < ApplicationController result = cs.show_course_news params,User.current @news = result[:news] @comments = result[:comments] + @comments_count = @comments.count + @page = params[:page] ? params[:page].to_i + 1 : 0 + @limit = 10 + @comments = @comments[@page * @limit..@page * @limit + 9] @comment = Comment.new #@comments = @news.comments #@comments.reverse! if User.current.wants_comments_in_reverse_order? @@ -179,12 +183,23 @@ class NewsController < ApplicationController @course = Course.find(@news.course_id) if @course @left_nav_type = 4 - render :layout => 'base_courses' + respond_to do |format| + format.js + format.html {render :layout => 'base_courses'} + end + end + elsif @project + respond_to do |format| + format.js + format.html {render :layout => 'base_projects'} end elsif @news.org_subfield_id @org_subfield = OrgSubfield.find(@news.org_subfield_id) @organization = @org_subfield.organization - render :layout => 'base_org' + respond_to do |format| + format.js + format.html {render :layout => 'base_org'} + end end end diff --git a/app/views/news/_news_all_replies.html.erb b/app/views/news/_news_all_replies.html.erb index 8333ac4e1..4bfad4c96 100644 --- a/app/views/news/_news_all_replies.html.erb +++ b/app/views/news/_news_all_replies.html.erb @@ -1,6 +1,6 @@
回复 - <%= @comments.count>0 ? "(#{@comments.count})" : "" %> + <%= @comments_count>0 ? "(#{@comments_count})" : "" %> <%=render :partial=> "praise_tread/praise", :locals => {:activity=>@news, :user_activity_id=>@news.id,:type=>"activity"}%> @@ -8,60 +8,7 @@
<% unless @comments.empty? %>
- <% @comments.each_with_index do |comment,i| %> - -
  • -
    - <%= link_to image_tag(url_to_avatar(comment.creator_user), :width => 33, :height => 33, :alt => "用户头像"), user_url_in_org(comment.creator_user.id) %> -
    -
    - <%= render :partial => 'users/news_contents', :locals => {:comment => comment}%> - - <% if !comment.content_detail.blank? %> -
    - <%= comment.content_detail.html_safe %> -
    -
    -
    - - - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> - - - <%= link_to( - l(:button_reply), - {:controller => 'comments',:action => 'quote', :id => comment}, - :remote => true, - :method => 'get', - :title => l(:button_reply))%> - - - <%= link_to( - l(:button_delete), - {:controller => 'comments', - :action => 'destroy', :id => @news, - :comment_id => comment}, - :method => :delete, - :id => "delete_reply_#{comment.id}", - :class => 'fr mr20 undis', - :data => {:confirm => l(:text_are_you_sure)}, - :title => l(:button_delete) - ) if User.current.allowed_to?(:manage_news, object) %> - -
    -
    -
    -

    - <% end %> -
    -
    -
  • - <% end %> + <%= render :partial => 'news/news_replies_detail', :locals => {:object => object} %>
    <% end %> diff --git a/app/views/news/_news_replies_detail.html.erb b/app/views/news/_news_replies_detail.html.erb new file mode 100644 index 000000000..f79bbdfc0 --- /dev/null +++ b/app/views/news/_news_replies_detail.html.erb @@ -0,0 +1,63 @@ +<% @comments.each_with_index do |comment,i| %> + +
  • +
    + <%= link_to image_tag(url_to_avatar(comment.creator_user), :width => 33, :height => 33, :alt => "用户头像"), user_url_in_org(comment.creator_user.id) %> +
    +
    + <%= render :partial => 'users/news_contents', :locals => {:comment => comment}%> + + <% if !comment.content_detail.blank? %> +
    + <%= comment.content_detail.html_safe %> +
    +
    +
    + + + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> + + + <%= link_to( + l(:button_reply), + {:controller => 'comments',:action => 'quote', :id => comment}, + :remote => true, + :method => 'get', + :title => l(:button_reply))%> + + + <%= link_to( + l(:button_delete), + {:controller => 'comments', + :action => 'destroy', :id => @news, + :comment_id => comment}, + :method => :delete, + :id => "delete_reply_#{comment.id}", + :class => 'fr mr20 undis', + :data => {:confirm => l(:text_are_you_sure)}, + :title => l(:button_delete) + ) if ((object.kind_of? Organization) ? User.current.allowed_to?(:manage_news, object) : (User.current.admin_of_org?(object) || User.current == comment.author)) %> + +
    +
    +
    +

    + <% end %> +
    +
    +
  • +<% end %> +<% if @comments_count > @page * @limit + 10 %> +
    +
    + + + <%= link_to '点击展开更多回复', news_path(@news, :page => @page), :remote=>true %> +
    +
    +<% end %> \ No newline at end of file diff --git a/app/views/news/_organization_show.html.erb b/app/views/news/_organization_show.html.erb index 9790c1305..c86d71d63 100644 --- a/app/views/news/_organization_show.html.erb +++ b/app/views/news/_organization_show.html.erb @@ -72,7 +72,7 @@
    - <%= render :partial => 'news/news_all_replies' %> + <%= render :partial => 'news/news_all_replies', :locals => {:object => @organization} %>