Hey Pelle! Welcome and thanks for jumping in! Before anything else,
note that the original separate links draft has been discontinued in
favor of the approach described in the current draft of the core
schema document here:
http://activitystrea.ms/specs/json/schema/activity-schema.html#links
That said, a few comments inline...
On Wed, Jun 27, 2012 at 3:15 AM, Pelle Wessman <
voxp...@gmail.com> wrote:
> I'm a bit late to the party but I have to say that I agree with Evan, I'm -1
> on the state of the proposal discussed in here.
>
> I think this implementation of link relations is too different from the ones
> in HTML, Atom and HTTP.
>
> In HTML, Atom and HTTP each link has a single "href", the possibility to
> have multiple relations and some common attributes like type, title etc.
>
In Atom, links have only a single relation...
> In this proposal each link has a single relation, the possibility to have
> multiple "hrefs" and no other common attributes.
With the current proposal, links would be expressed as...
{
...,
"links": {
"self": "
http://example.org/1",
"alternate": [
"
http://example.org/2",
"
http://example.org/3"
]
},
...
}
This particular example defines *three* distinct links. The use of the
array does not imply that a single link has two hrefs.. just that
there are two separate links that each use the same link relation.
>
> I also have to disagree with James Snell's conclusion that "no one is simply
> going to throw arbitrary link relations into an activity stream without
> having some kind of application specific use" - I think one of the larger
> benefits of link relations is that you can describe them once and then have
> them used in whatever context they make sense in without any specific
> documentation for that specific file format. That freedom means that people
> not normally involved in standardization can invent new flows by just
> piecing together two already defined things.
Yes, but whoever chooses to use the link relation within the stream is
going to have some sense of why they're doing so.
>
> I'm currently drafting on some recommended guidelines for our Flattr
> community that describes how we think it should be implementing rel-payment
> links to Flattr. Currently I'm recommending them to specify both title and
> type. The title is useful to differentiate between different payment links
> in a UI and the type is useful for a UI to be able to know which links that
> are targeting HTML-pages and thus possible to open in a browser.
>
> Since I don't want to recommend others to do something that I'm not doing
> myself I have been implementing those guidelines in Flattr itself - but when
> I came to including it in the JSON Activity Streams I came across this
> issue.
>
> I'm much more favor of what Evan mentioned earlier:
>
> {
> "links": [{"rel": "payment",
> "href": "
http://flattr.com/example/123",
> "title": "Flattr this",
> "type": "text/html"},
> {"rel": "payment",
> "href": "
http://example.com/pay/123",
> "title": "Pay for this on Example.com",
> "type": "text/html"},
> {"rel": "first prev",
> "href": "
http://example.com/page/1"}],
> "items": [ ...]
> }
>
The challenge with this approach is that it makes the most common
simple cases quite a bit more difficult to implement. For instance,
providing links like "self", "canonical", "next", "prev", "first",
"last", "edit"... each of these are typically singletons within a
document. Why should I have to crawl through an array of an arbitrary
collection of links or parse every possible combination of relations
to find them? Doing so significantly increases the complexity. I think
an argument can be (and has been) made for using an object to
represent links rather than JUST the hrefs. Based on the feedback I've
seen, the majority consensus seems to be that objects are better.
To balance out the various goals, I would suggest the following...
{
"links": {
"payment": [
{"href": "
http://flattr.com/example/123",
"title": "Flattr this",
"type": "text/html"},
{"href": "
http://example.com/pay/123",
"title": "Pay for this on Example.com",
"type": "text/html"}
],
"first": {
"href": "
http://example.com/page/1"
},
"prev": {
Yes, it's more verbose, but I believe it provides a good compromise
given everything that I've seen in the various cases. It allows the
simple cases to remain as simple as possible while providing for the
additional extensibility and flexibility you (and others) suggest is
required... (which I agree with also.. I just wanted to make sure the
additional complexity was absolutely necessary).
- James