parent
048c614590
commit
11385d6b65
|
@ -114,10 +114,20 @@ class StoriesController < ApplicationController
|
|||
@short_url = @story.short_id_url
|
||||
|
||||
@comments = Comment.ordered_for_story_or_thread_for_user(@story.id, nil,
|
||||
@user ? @user : nil)
|
||||
@comment = Comment.new
|
||||
@user)
|
||||
|
||||
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
|
||||
|
||||
def show_comment
|
||||
|
|
|
@ -59,6 +59,28 @@ class Comment < ActiveRecord::Base
|
|||
|
||||
nil
|
||||
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
|
||||
10.times do |try|
|
||||
|
|
|
@ -113,12 +113,17 @@ class Story < ActiveRecord::Base
|
|||
:created_at,
|
||||
:title,
|
||||
:url,
|
||||
:comments_url,
|
||||
])
|
||||
h[:score] = score
|
||||
h[:comment_count] = comment_count
|
||||
h[:description] = markeddown_description
|
||||
h[:comments_url] = comments_url
|
||||
h[:submitter_user] = user
|
||||
|
||||
if options && options[:with_comments]
|
||||
h[:comments] = options[:with_comments]
|
||||
end
|
||||
|
||||
h
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue