parent
048c614590
commit
11385d6b65
|
@ -114,10 +114,20 @@ class StoriesController < ApplicationController
|
||||||
@short_url = @story.short_id_url
|
@short_url = @story.short_id_url
|
||||||
|
|
||||||
@comments = Comment.ordered_for_story_or_thread_for_user(@story.id, nil,
|
@comments = Comment.ordered_for_story_or_thread_for_user(@story.id, nil,
|
||||||
@user ? @user : nil)
|
@user)
|
||||||
@comment = Comment.new
|
|
||||||
|
|
||||||
load_user_votes
|
respond_to do |format|
|
||||||
|
format.html {
|
||||||
|
@comment = Comment.new
|
||||||
|
|
||||||
|
load_user_votes
|
||||||
|
|
||||||
|
render :action => "show"
|
||||||
|
}
|
||||||
|
format.json {
|
||||||
|
render :json => @story.as_json(:with_comments => @comments)
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def show_comment
|
def show_comment
|
||||||
|
|
|
@ -59,6 +59,28 @@ class Comment < ActiveRecord::Base
|
||||||
|
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def as_json(options = {})
|
||||||
|
h = super(:only => [
|
||||||
|
:short_id,
|
||||||
|
:created_at,
|
||||||
|
:updated_at,
|
||||||
|
:is_deleted,
|
||||||
|
:is_moderated,
|
||||||
|
])
|
||||||
|
h[:score] = score
|
||||||
|
|
||||||
|
if self.is_gone?
|
||||||
|
h[:comment] = "<em>#{self.gone_text}</em>"
|
||||||
|
else
|
||||||
|
h[:comment] = markeddown_comment
|
||||||
|
end
|
||||||
|
|
||||||
|
h[:url] = url
|
||||||
|
h[:indent_level] = indent_level
|
||||||
|
h[:commenting_user] = user
|
||||||
|
h
|
||||||
|
end
|
||||||
|
|
||||||
def assign_short_id_and_upvote
|
def assign_short_id_and_upvote
|
||||||
10.times do |try|
|
10.times do |try|
|
||||||
|
|
|
@ -113,12 +113,17 @@ class Story < ActiveRecord::Base
|
||||||
:created_at,
|
:created_at,
|
||||||
:title,
|
:title,
|
||||||
:url,
|
:url,
|
||||||
:comments_url,
|
|
||||||
])
|
])
|
||||||
h[:score] = score
|
h[:score] = score
|
||||||
h[:comment_count] = comment_count
|
h[:comment_count] = comment_count
|
||||||
h[:description] = markeddown_description
|
h[:description] = markeddown_description
|
||||||
|
h[:comments_url] = comments_url
|
||||||
h[:submitter_user] = user
|
h[:submitter_user] = user
|
||||||
|
|
||||||
|
if options && options[:with_comments]
|
||||||
|
h[:comments] = options[:with_comments]
|
||||||
|
end
|
||||||
|
|
||||||
h
|
h
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue