FIX: OpenGraph should feature the desired post, if found in the set.
This commit is contained in:
parent
013ad0fdda
commit
cfc4dda9ff
|
@ -346,7 +346,6 @@ Discourse.TopicView.reopenClass({
|
|||
var header = $('header');
|
||||
var title = $('#topic-title');
|
||||
var expectedOffset = title.height() - header.find('.contents').height();
|
||||
console.log(expectedOffset);
|
||||
|
||||
if (expectedOffset < 0) {
|
||||
expectedOffset = 0;
|
||||
|
|
|
@ -86,14 +86,23 @@ class TopicView
|
|||
@topic.title
|
||||
end
|
||||
|
||||
def summary
|
||||
def desired_post
|
||||
return @desired_post if @desired_post.present?
|
||||
return nil if posts.blank?
|
||||
Summarize.new(posts.first.cooked).summary
|
||||
|
||||
@desired_post = posts.detect {|p| p.post_number == @post_number.to_i}
|
||||
@desired_post ||= posts.first
|
||||
@desired_post
|
||||
end
|
||||
|
||||
def summary
|
||||
return nil if desired_post.blank?
|
||||
Summarize.new(desired_post.cooked).summary
|
||||
end
|
||||
|
||||
def image_url
|
||||
return nil if posts.blank?
|
||||
posts.first.user.small_avatar_url
|
||||
return nil if desired_post.blank?
|
||||
desired_post.user.small_avatar_url
|
||||
end
|
||||
|
||||
def filter_posts(opts = {})
|
||||
|
|
|
@ -257,22 +257,26 @@ describe TopicView do
|
|||
|
||||
it "snaps to the lower boundary" do
|
||||
near_view = topic_view_near(p1)
|
||||
near_view.desired_post.should == p1
|
||||
near_view.posts.should == [p1, p2, p3]
|
||||
end
|
||||
|
||||
it "snaps to the upper boundary" do
|
||||
near_view = topic_view_near(p5)
|
||||
near_view.desired_post.should == p5
|
||||
near_view.posts.should == [p2, p3, p5]
|
||||
end
|
||||
|
||||
it "returns the posts in the middle" do
|
||||
near_view = topic_view_near(p2)
|
||||
near_view.desired_post.should == p2
|
||||
near_view.posts.should == [p1, p2, p3]
|
||||
end
|
||||
|
||||
it "returns deleted posts to an admin" do
|
||||
coding_horror.admin = true
|
||||
near_view = topic_view_near(p3)
|
||||
near_view.desired_post.should == p3
|
||||
near_view.posts.should == [p2, p3, p4]
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue