make linking to specific comments work
This commit is contained in:
parent
d9b95b2a1d
commit
e535a1387f
|
@ -359,7 +359,8 @@ li.downvoted div.voters a.downvoter {
|
|||
ol.stories li,
|
||||
ol.comments li {
|
||||
clear: both;
|
||||
padding-top: 1em;
|
||||
padding-top: 0.5em;
|
||||
padding-bottom: 0.5em;
|
||||
}
|
||||
ol.stories li:first-child {
|
||||
padding-top: 0.5em;
|
||||
|
@ -382,6 +383,10 @@ ol.comments li.negative_7 {
|
|||
opacity: 0.2;
|
||||
}
|
||||
|
||||
ol.comments li.highlighted {
|
||||
background-color: #ffffbf;
|
||||
}
|
||||
|
||||
li .link {
|
||||
font-weight: bold;
|
||||
vertical-align: middle;
|
||||
|
@ -540,8 +545,8 @@ div#story_box div.markdown_help_toggler {
|
|||
width: 610px;
|
||||
}
|
||||
|
||||
div.comment_form_container {
|
||||
max-width: 550px;
|
||||
div.comment_form_container, div.comment_reply {
|
||||
max-width: 500px;
|
||||
}
|
||||
|
||||
/* data tables */
|
||||
|
|
|
@ -76,27 +76,67 @@ class StoriesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@story = Story.find_by_short_id!(params[:id])
|
||||
def show
|
||||
@story = Story.find_by_short_id!(params[:id])
|
||||
|
||||
@page_title = @story.title
|
||||
|
||||
@comments = Comment.ordered_for_story_or_thread_for_user(
|
||||
@story.id, nil, @user ? @user.id : nil)
|
||||
@comments = Comment.ordered_for_story_or_thread_for_user(@story.id, nil,
|
||||
@user ? @user.id : nil)
|
||||
@comment = Comment.new
|
||||
|
||||
if @user
|
||||
if v = Vote.find_by_user_id_and_story_id(@user.id, @story.id)
|
||||
@story.vote = v.vote
|
||||
if @user
|
||||
if v = Vote.find_by_user_id_and_story_id(@user.id, @story.id)
|
||||
@story.vote = v.vote
|
||||
end
|
||||
|
||||
@votes = Vote.comment_votes_by_user_for_story_hash(@user.id, @story.id)
|
||||
@comments.each do |c|
|
||||
if @votes[c.id]
|
||||
c.current_vote = @votes[c.id]
|
||||
@votes = Vote.comment_votes_by_user_for_story_hash(@user.id, @story.id)
|
||||
@comments.each do |c|
|
||||
if @votes[c.id]
|
||||
c.current_vote = @votes[c.id]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def show_comment
|
||||
@story = Story.find_by_short_id!(params[:id])
|
||||
|
||||
@page_title = @story.title
|
||||
|
||||
@showing_comment = Comment.find_by_short_id(params[:comment_short_id])
|
||||
|
||||
if !@showing_comment
|
||||
flash[:error] = "Could not find comment. It may have been deleted."
|
||||
return redirect_to @story.comments_url
|
||||
end
|
||||
|
||||
@comments = Comment.ordered_for_story_or_thread_for_user(@story.id,
|
||||
@showing_comment.thread_id, @user ? @user.id : nil)
|
||||
|
||||
@comments.each do |c,x|
|
||||
if c.id == @showing_comment.id
|
||||
c.highlighted = true
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
@comment = Comment.new
|
||||
|
||||
if @user
|
||||
if v = Vote.find_by_user_id_and_story_id(@user.id, @story.id)
|
||||
@story.vote = v.vote
|
||||
end
|
||||
|
||||
@votes = Vote.comment_votes_by_user_for_story_hash(@user.id, @story.id)
|
||||
@comments.each do |c|
|
||||
if @votes[c.id]
|
||||
c.current_vote = @votes[c.id]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
render :action => "show"
|
||||
end
|
||||
|
||||
def undelete
|
||||
|
|
|
@ -9,7 +9,7 @@ class Comment < ActiveRecord::Base
|
|||
attr_accessible :comment
|
||||
|
||||
attr_accessor :parent_comment_short_id, :current_vote, :previewing,
|
||||
:indent_level
|
||||
:indent_level, :highlighted
|
||||
|
||||
before_create :assign_short_id_and_upvote
|
||||
after_create :assign_votes, :mark_submitter, :email_reply
|
||||
|
@ -150,6 +150,8 @@ class Comment < ActiveRecord::Base
|
|||
}
|
||||
recursor.call(nil, 0)
|
||||
|
||||
# TODO: handle deleted comments, show for user_id
|
||||
|
||||
ordered
|
||||
end
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<li id="comment_<%= comment.short_id %>" data-shortid="<%= comment.short_id %>"
|
||||
class="comment <%= comment.current_vote ? (comment.current_vote[:vote] == 1 ?
|
||||
"upvoted" : "downvoted") : "" %>
|
||||
<%= comment.highlighted ? "highlighted" : "" %>
|
||||
<%= comment.score <= 0 ? "negative" : "" %>
|
||||
<%= comment.score <= -3 ? "negative_3" : "" %>
|
||||
<%= comment.score <= -5 ? "negative_5" : "" %>
|
||||
|
|
|
@ -37,6 +37,7 @@ Lobsters::Application.routes.draw do
|
|||
post "/comments/:story_id" => "comments#create"
|
||||
post "/comments/preview/:story_id" => "comments#preview"
|
||||
|
||||
get "/s/:id/:title/comments/:comment_short_id" => "stories#show_comment"
|
||||
get "/s/:id/(:title)" => "stories#show"
|
||||
get "/u/:id" => "users#show"
|
||||
|
||||
|
|
Loading…
Reference in a new issue