show full story threads when highlighting a comment
we're not paginating (yet) so just show the whole thread like normal and highlight the specific comment which gets scrolled to closes #107
This commit is contained in:
parent
d277011a0f
commit
e6ce3a5d68
|
@ -127,6 +127,15 @@ class StoriesController < ApplicationController
|
|||
|
||||
@comments = @story.comments.includes(:user).arrange_for_user(@user)
|
||||
|
||||
if params[:comment_short_id]
|
||||
@comments.each do |c,x|
|
||||
if c.short_id == params[:comment_short_id]
|
||||
c.highlighted = true
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
@comment = @story.comments.build
|
||||
|
@ -141,38 +150,6 @@ class StoriesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def show_comment
|
||||
@story = Story.where(:short_id => params[:id]).first!
|
||||
|
||||
@title = @story.title
|
||||
|
||||
@showing_comment = Comment.where(:short_id => params[:comment_short_id]).first
|
||||
|
||||
if !@showing_comment
|
||||
flash[:error] = "Could not find comment. It may have been deleted."
|
||||
return redirect_to @story.comments_url
|
||||
end
|
||||
|
||||
@comments = @story.comments
|
||||
if @showing_comment.thread_id
|
||||
@comments = @comments.where(:thread_id => @showing_comment.thread_id)
|
||||
end
|
||||
@comments = @comments.includes(:user).arrange_for_user(@user)
|
||||
|
||||
@comments.each do |c,x|
|
||||
if c.id == @showing_comment.id
|
||||
c.highlighted = true
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
@comment = @story.comments.build
|
||||
|
||||
load_user_votes
|
||||
|
||||
render :action => "show"
|
||||
end
|
||||
|
||||
def undelete
|
||||
if !(@story.is_editable_by_user?(@user) &&
|
||||
@story.is_undeletable_by_user?(@user))
|
||||
|
|
|
@ -62,7 +62,7 @@ Lobsters::Application.routes.draw do
|
|||
post "keep_as_new"
|
||||
end
|
||||
|
||||
get "/s/:id/:title/comments/:comment_short_id" => "stories#show_comment"
|
||||
get "/s/:id/:title/comments/:comment_short_id" => "stories#show"
|
||||
get "/s/:id/(:title)" => "stories#show"
|
||||
|
||||
get "/u" => "users#tree"
|
||||
|
|
Loading…
Reference in a new issue