mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
FIX: OpenGraph should feature the desired post, if found in the set.
This commit is contained in:
parent
013ad0fdda
commit
cfc4dda9ff
3 changed files with 17 additions and 5 deletions
|
@ -346,7 +346,6 @@ Discourse.TopicView.reopenClass({
|
||||||
var header = $('header');
|
var header = $('header');
|
||||||
var title = $('#topic-title');
|
var title = $('#topic-title');
|
||||||
var expectedOffset = title.height() - header.find('.contents').height();
|
var expectedOffset = title.height() - header.find('.contents').height();
|
||||||
console.log(expectedOffset);
|
|
||||||
|
|
||||||
if (expectedOffset < 0) {
|
if (expectedOffset < 0) {
|
||||||
expectedOffset = 0;
|
expectedOffset = 0;
|
||||||
|
|
|
@ -86,14 +86,23 @@ class TopicView
|
||||||
@topic.title
|
@topic.title
|
||||||
end
|
end
|
||||||
|
|
||||||
def summary
|
def desired_post
|
||||||
|
return @desired_post if @desired_post.present?
|
||||||
return nil if posts.blank?
|
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
|
end
|
||||||
|
|
||||||
def image_url
|
def image_url
|
||||||
return nil if posts.blank?
|
return nil if desired_post.blank?
|
||||||
posts.first.user.small_avatar_url
|
desired_post.user.small_avatar_url
|
||||||
end
|
end
|
||||||
|
|
||||||
def filter_posts(opts = {})
|
def filter_posts(opts = {})
|
||||||
|
|
|
@ -257,22 +257,26 @@ describe TopicView do
|
||||||
|
|
||||||
it "snaps to the lower boundary" do
|
it "snaps to the lower boundary" do
|
||||||
near_view = topic_view_near(p1)
|
near_view = topic_view_near(p1)
|
||||||
|
near_view.desired_post.should == p1
|
||||||
near_view.posts.should == [p1, p2, p3]
|
near_view.posts.should == [p1, p2, p3]
|
||||||
end
|
end
|
||||||
|
|
||||||
it "snaps to the upper boundary" do
|
it "snaps to the upper boundary" do
|
||||||
near_view = topic_view_near(p5)
|
near_view = topic_view_near(p5)
|
||||||
|
near_view.desired_post.should == p5
|
||||||
near_view.posts.should == [p2, p3, p5]
|
near_view.posts.should == [p2, p3, p5]
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns the posts in the middle" do
|
it "returns the posts in the middle" do
|
||||||
near_view = topic_view_near(p2)
|
near_view = topic_view_near(p2)
|
||||||
|
near_view.desired_post.should == p2
|
||||||
near_view.posts.should == [p1, p2, p3]
|
near_view.posts.should == [p1, p2, p3]
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns deleted posts to an admin" do
|
it "returns deleted posts to an admin" do
|
||||||
coding_horror.admin = true
|
coding_horror.admin = true
|
||||||
near_view = topic_view_near(p3)
|
near_view = topic_view_near(p3)
|
||||||
|
near_view.desired_post.should == p3
|
||||||
near_view.posts.should == [p2, p3, p4]
|
near_view.posts.should == [p2, p3, p4]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue