This fixes issue #2032. Anyone can now view all comments on a public post without needing to log in.
This commit is contained in:
parent
39dd39e9e3
commit
35a0c56346
4 changed files with 12 additions and 5 deletions
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
class CommentsController < ApplicationController
|
class CommentsController < ApplicationController
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
before_filter :authenticate_user!
|
before_filter :authenticate_user!, :except => [:index]
|
||||||
|
|
||||||
respond_to :html, :mobile, :except => :show
|
respond_to :html, :mobile, :except => :show
|
||||||
respond_to :js, :only => [:index]
|
respond_to :js, :only => [:index]
|
||||||
|
|
@ -55,7 +55,12 @@ class CommentsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def index
|
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
|
if @post
|
||||||
@comments = @post.comments.includes(:author => :profile).order('created_at ASC')
|
@comments = @post.comments.includes(:author => :profile).order('created_at ASC')
|
||||||
render :layout => false
|
render :layout => false
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@ module CommentsHelper
|
||||||
def comment_toggle(post, commenting_disabled=false)
|
def comment_toggle(post, commenting_disabled=false)
|
||||||
if post.comments.size <= 3
|
if post.comments.size <= 3
|
||||||
link_to "#{t('stream_helper.hide_comments')}", post_comments_path(post.id), :class => "toggle_post_comments"
|
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
|
else
|
||||||
link_to "#{t('stream_helper.show_more_comments', :number => post.comments.size - 3)}", post_comments_path(post.id), :class => "toggle_post_comments"
|
link_to "#{t('stream_helper.show_more_comments', :number => post.comments.size - 3)}", post_comments_path(post.id), :class => "toggle_post_comments"
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,13 @@
|
||||||
-# licensed under the Affero General Public License version 3 or later. See
|
-# licensed under the Affero General Public License version 3 or later. See
|
||||||
-# the COPYRIGHT file.
|
-# the COPYRIGHT file.
|
||||||
.comment_stream
|
.comment_stream
|
||||||
- unless comments_expanded
|
- unless comments_expanded || params['all_comments']
|
||||||
%ul.show_comments{:class => ("hidden" if post.comments.size <= 3)}
|
%ul.show_comments{:class => ("hidden" if post.comments.size <= 3)}
|
||||||
%li
|
%li
|
||||||
= comment_toggle( post)
|
= comment_toggle( post)
|
||||||
|
|
||||||
%ul.comments{:class => ('loaded' if post.comments.size <= 3)}
|
%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}
|
= render :partial => 'comments/comment', :collection => post.comments.last(3), :locals => {:post => post}
|
||||||
-else
|
-else
|
||||||
= render :partial => 'comments/comment', :collection => post.comments, :locals => {:post => post}
|
= render :partial => 'comments/comment', :collection => post.comments, :locals => {:post => post}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue