diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 8362ae018..c2a4738ac 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -4,7 +4,7 @@ class CommentsController < ApplicationController include ApplicationHelper - before_filter :authenticate_user! + before_filter :authenticate_user!, :except => [:index] respond_to :html, :mobile, :except => :show respond_to :js, :only => [:index] @@ -55,7 +55,12 @@ class CommentsController < ApplicationController end def index - @post = current_user.find_visible_post_by_id(params[:post_id]) + if user_signed_in? + @post = current_user.find_visible_post_by_id(params[:post_id]) + else + @post = Post.where(:id => params[:post_id], :public => true).includes(:author, :comments => :author).first + end + if @post @comments = @post.comments.includes(:author => :profile).order('created_at ASC') render :layout => false diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index a2905dee5..5b97ed27e 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -36,7 +36,7 @@ class PostsController < ApplicationController respond_to do |format| format.xml{ render :xml => @post.to_diaspora_xml } - format.mobile{render 'posts/show.mobile.haml'} + format.mobile{render 'posts/show.mobile.haml'} format.any{render 'posts/show.html.haml'} end diff --git a/app/helpers/comments_helper.rb b/app/helpers/comments_helper.rb index 541fa083b..13f788c13 100644 --- a/app/helpers/comments_helper.rb +++ b/app/helpers/comments_helper.rb @@ -7,6 +7,8 @@ module CommentsHelper def comment_toggle(post, commenting_disabled=false) if post.comments.size <= 3 link_to "#{t('stream_helper.hide_comments')}", post_comments_path(post.id), :class => "toggle_post_comments" + elsif ! user_signed_in? + link_to "#{t('stream_helper.show_more_comments', :number => post.comments.size - 3)}", post_path(post.id, :all_comments => '1'), :class => "toggle_post_comments" else link_to "#{t('stream_helper.show_more_comments', :number => post.comments.size - 3)}", post_comments_path(post.id), :class => "toggle_post_comments" end diff --git a/app/views/comments/_comments.html.haml b/app/views/comments/_comments.html.haml index 35433f7b8..daf379a32 100644 --- a/app/views/comments/_comments.html.haml +++ b/app/views/comments/_comments.html.haml @@ -2,13 +2,13 @@ -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. .comment_stream - - unless comments_expanded + - unless comments_expanded || params['all_comments'] %ul.show_comments{:class => ("hidden" if post.comments.size <= 3)} %li = comment_toggle( post) %ul.comments{:class => ('loaded' if post.comments.size <= 3)} - -if post.comments.size > 3 && !comments_expanded + -if post.comments.size > 3 && !comments_expanded && ! params['all_comments'] = render :partial => 'comments/comment', :collection => post.comments.last(3), :locals => {:post => post} -else = render :partial => 'comments/comment', :collection => post.comments, :locals => {:post => post}