-
-
Notifications
You must be signed in to change notification settings - Fork 7k
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
Add support for structured data and more OpenGraph tags to link cards #16938
Conversation
9962be6
to
565973d
Compare
565973d
to
4f80e1f
Compare
There is a validation error caused by the canonical URL handling that I need to fix before merging 😔 |
da5b470
to
a82198e
Compare
a82198e
to
a93799f
Compare
Save preview cards under their canonical URL Increase max redirects to follow from 2 to 3
a93799f
to
7795ab7
Compare
if @status.local? | ||
urls = @status.text.scan(URL_PATTERN).map { |array| Addressable::URI.parse(array[1]).normalize } | ||
else | ||
html = Nokogiri::HTML(@status.text) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I fixed shadowing of the html
method
end | ||
|
||
def opengraph_tag(name) | ||
document.xpath("//meta[@property=\"#{name}\" or @name=\"#{name}\"]").map { |meta| meta['content'] }.first |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old method used to search all meta nodes for any attribute that had the searched-for value, but I don't think that is needed, OpenGraph tags can either be identified by name
or property
and nothing else.
…mastodon#16938) Save preview cards under their canonical URL Increase max redirects to follow from 2 to 3
Previously, link card generation was focused mainly on OEmbed, with OpenGraph details being merely the fallback. This adds more first-class treatment of OpenGraph data as well as JSON-LD structured data available on many news publications.
In particular, now
author_name
,author_url
,provider_name
, andprovider_url
will be available for OpenGraph links whereas previously those fields were only present on OEmbed links.Respect canonical URL as long as the host is the same as of the page it is served from, but respect redirects leading up to it (e.g. through link shorteners) to avoid saving previews as belong to "t.co" and similar nonsense.