-
Notifications
You must be signed in to change notification settings - Fork 35
Add support for the alternate
link relation
#133
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
af1c48d
Add support for the `alternate` link relation with type `application/…
gkellogg eefa601
RFC8259 => RFC8288.
gkellogg be808f6
Alternate link header ignored for all JSON types.
gkellogg caecf69
Alternate link header ignored for all JSON types.
gkellogg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"@context": { | ||
"@vocab": "http://example.org/" | ||
}, | ||
"content": "alternate" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<html> | ||
<head> | ||
<title>Content to be skipped</title> | ||
<script type="application/ld+json"> | ||
{ | ||
"@context": { | ||
"@vocab": "http://example.org/" | ||
}, | ||
"content": "skipped" | ||
} | ||
</script> | ||
</head> | ||
<body> | ||
<p>This content should be skipped</p> | ||
</body> | ||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[{ | ||
"http://example.org/content": [{"@value": "alternate"}] | ||
}] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"@context": { | ||
"@vocab": "http://example.org/" | ||
}, | ||
"content": "alternate" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"@context": { | ||
"@vocab": "http://example.org/" | ||
}, | ||
"content": "not skipped" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[{ | ||
"http://example.org/content": [{"@value": "not skipped"}] | ||
}] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"@context": { | ||
"@vocab": "http://example.org/" | ||
}, | ||
"content": "alternate" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"@context": { | ||
"@vocab": "http://example.org/" | ||
}, | ||
"content": "not skipped" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[{ | ||
"http://example.org/content": [{"@value": "not skipped"}] | ||
}] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"@context": { | ||
"@vocab": "http://example.org/" | ||
}, | ||
"content": "alternate" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"@context": { | ||
"@vocab": "http://example.org/" | ||
}, | ||
"content": "not skipped" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[{ | ||
"http://example.org/content": [{"@value": "not skipped"}] | ||
}] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"@context": { | ||
"@vocab": "http://example.org/" | ||
}, | ||
"@id": "", | ||
"content": "alternate" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<html> | ||
<head> | ||
<title>Content to be skipped</title> | ||
<script type="application/ld+json"> | ||
{ | ||
"@context": { | ||
"@vocab": "http://example.org/" | ||
}, | ||
"@id": "", | ||
"content": "skipped" | ||
} | ||
</script> | ||
</head> | ||
<body> | ||
<p>This content should be skipped</p> | ||
</body> | ||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[{ | ||
"@id": "https://w3c.github.io/json-ld-api/tests/remote-doc/la05-in.html", | ||
"http://example.org/content": [{"@value": "alternate"}] | ||
}] |
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.
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.
This probably needs to be discussed (it is not just editorial).
This would create a different behaviour when the document is accessed directly, than when it is accessed through the "link header indirection". So I am not a big fan of the idea.
I would rather encourage the author of the JSON-LD document to explicitly set the base to the URL o the non-JSON-LD document, if that is the behaviour they intend.
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 PR is definitely prospective, as the issue is still marked to be discussed, but I wanted to get it out there and see the consequences. The link header shouldn’t affect any json format, but would affect html content. What document base should be applied can be debated, but using the original document has precedent.
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.
Hmm, I think I disagree with @pchampin ... and that we want to treat this like we do with redirects, which I believe uses the original document. The argument for doing what @pchampin suggests would be that there's no way to know ahead of time what the final document will be, so you couldn't set the base to it, whereas you could set the base to the original document if you wanted it to stick.
But, processors could have a flag to switch to this other behavior. It seems to me that the sensible default would be the original document. Especially given the way that we expect this feature to be used ... which is that the linked document is really a hidden implementation detail. If you wanted to use the linked document directly you would have specified it instead of some, e.g., HTML document.
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.
👎 to introducing another flag, though. If the document should have some specific base different from the originally referenced resource, it can use
@base
.My thought in using the original resource base, rather than the referenced document, is essentially the same reasoning that lead to the semantics of HTTP status 303 for range-14 considerations.
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.
If this use of
alternate
(which comes from HTML primarily) is meant to supplant using content negotiation, then the expectation would be (afaict) that the original resource URL would (semantically) be the correct base URL--which I think agrees with what @gkellogg said above.Once the
alternate
is retrieved it should experientially be like getting a content negotiated response with aContent-Location
set to thealternate
and havingLocation
still be set to the original Request-URI--which is how content negotiation plays out.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.
What I mentioned on the call Friday was that the only definition of
rel="alternate"
(that I'm aware of) is in https://html.spec.whatwg.org/multipage/links.html#rel-alternateThe summary definition is "Gives alternate representations of the current document." but the follow-on expansion on it includes "The meaning of this keyword depends on the values of the other attributes."
The examples in that section include alternate CSS styles (i.e.
rel="alternate stylesheet"
), Atom/RSS alternate representations (i.e.rel="alternate" type=""
), and using it for language [content] negotiation (i.e.rel="alternate" hreflang=""
+/-type=""
).So, using
alternate
here to accomplish a pre-flight content negotiation (of sorts) is not without its precedence conceptually. However, none of that directly answers the base URI situation...as in the closest experiential case (language negotiation) the browser would navigate to the new resource based on language preferences--thereby acting more like a30*
redirect than like content negotiation.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.
Additionally, if we stick with
alternate
, we may need to require other link parameters (or type parameters) to clarify that this is a representation of the current document as a context vs. a representation of the current document expressed in JSON-LD (i.e. as a data document).We could use the existing context profile URL (which is used as a
rel
in Interpreting JSON as JSON-LD). The experience would be similar to referencing a data document as the context of another data document.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.
There's a discussion in Cool URIs:
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.
Yes, but they do not say that a relative URI could or should be used for that...
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.
At this point, I think you need to raise a new issue for discussion, because we seem to have quite different views on this, and discussing in a merged PR isn't a good way to be sure we resolve it.