Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Restore author on non-first-post crawler views #26459

Merged
merged 2 commits into from Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/views/topics/show.html.erb
Expand Up @@ -51,7 +51,7 @@
<% end %>
</div>

<% if @topic_view.posts&.first && !@topic_view.posts.first.is_first_post? %>
<% if @topic_view.crawler_posts&.first && !@topic_view.crawler_posts.first.is_first_post? %>
<span itemprop='author' itemscope itemtype="http://schema.org/Person">
<meta itemprop='name' content='<%= @topic_view.topic.user.username %>'>
<link itemprop='url' href='<%= Discourse.base_url %>/u/<%= @topic_view.topic.user.username %>'>
Expand Down
17 changes: 17 additions & 0 deletions spec/requests/topics_controller_spec.rb
Expand Up @@ -5261,6 +5261,23 @@ def invite_group(topic, expected_status)
)
end

it "includes top-level author metadata when the view does not include the OP naturally" do
get "#{topic.relative_url}/2"
expect(body).to have_tag(
"[itemtype='http://schema.org/DiscussionForumPosting'] > [itemprop='author']",
)

get "#{topic.relative_url}/27"
expect(body).to have_tag(
"[itemtype='http://schema.org/DiscussionForumPosting'] > [itemprop='author']",
)

get "#{topic.relative_url}?page=2"
expect(body).to have_tag(
"[itemtype='http://schema.org/DiscussionForumPosting'] > [itemprop='author']",
)
end

context "with canonical_url" do
fab!(:topic_embed) { Fabricate(:topic_embed, embed_url: "https://markvanlan.com") }
let!(:user_agent) do
Expand Down