Add support for structured data and more OpenGraph tags to link cards#16938
Merged
Add support for structured data and more OpenGraph tags to link cards#16938
Conversation
9962be6 to
565973d
Compare
565973d to
4f80e1f
Compare
ykzts
approved these changes
Nov 5, 2021
Member
Author
|
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
Gargron
commented
Nov 5, 2021
| if @status.local? | ||
| urls = @status.text.scan(URL_PATTERN).map { |array| Addressable::URI.parse(array[1]).normalize } | ||
| else | ||
| html = Nokogiri::HTML(@status.text) |
Member
Author
There was a problem hiding this comment.
Here I fixed shadowing of the html method
Gargron
commented
Nov 5, 2021
| end | ||
|
|
||
| def opengraph_tag(name) | ||
| document.xpath("//meta[@property=\"#{name}\" or @name=\"#{name}\"]").map { |meta| meta['content'] }.first |
Member
Author
There was a problem hiding this comment.
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.
jesseplusplus
pushed a commit
to jesseplusplus/decodon
that referenced
this pull request
Feb 10, 2022
…mastodon#16938) Save preview cards under their canonical URL Increase max redirects to follow from 2 to 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_urlwill 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.