Skip to content

Commit

Permalink
Merge pull request #138 from hackatron/feature/parent-link
Browse files Browse the repository at this point in the history
Add link to parent comment for replies
  • Loading branch information
fcambus committed May 22, 2013
2 parents 513719e + a69942d commit f4fdc77
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions app.rb
Expand Up @@ -399,7 +399,7 @@
def render_comment_subthread(comment,sep="")
H.div(:class => "singlecomment") {
u = get_user_by_id(comment["user_id"]) || DeletedUser
comment_to_html(comment,u)
comment_to_html(comment,u,true)
}+H.div(:class => "commentreplies") {
sep+
render_comments_for_news(comment['thread_id'],comment["id"].to_i)
Expand Down Expand Up @@ -1888,7 +1888,8 @@ def urls_to_links(s)
# Render a comment into HTML.
# 'c' is the comment representation as a Ruby hash.
# 'u' is the user, obtained from the user_id by the caller.
def comment_to_html(c,u)
# 'show_parent' flag to show link to parent comment.
def comment_to_html(c,u,show_parent = false)
indent = "margin-left:#{c['level'].to_i*CommentReplyShift}px"
score = compute_comment_score(c)
news_id = c['thread_id']
Expand Down Expand Up @@ -1920,6 +1921,11 @@ def comment_to_html(c,u)
"link"
}+" "
else "" end +
if show_parent && c["parent_id"] > -1
H.a(:href=>"/comment/#{news_id}/#{c["parent_id"]}", :class=>"reply") {
"parent"
}+" "
else "" end +
if $user and !c['topcomment']
H.a(:href=>"/reply/#{news_id}/#{c["id"]}", :class=>"reply") {
"reply"
Expand Down

0 comments on commit f4fdc77

Please sign in to comment.