Signalling "open in app" behaviour for AP content
-
mauve@mastodon.mauve.moereplied to julian@community.nodebb.org on last edited by
@julian @evan @silverpill Cool mind sending a link to the post json-ld and maybe the source code? I'd love to test it against my implementations and see what's up.
-
julian@community.nodebb.orgreplied to mauve@mastodon.mauve.moe on last edited by
@mauve@mastodon.mauve.moe Yeah, sure thing! This is the source code for one of them, it adds the link header when loading a topic.
You can try viewing the source of
https://community.nodebb.org/post/99307
or making aHEAD
call against it to see the meta tag and Link header, respectively. -
julian@community.nodebb.orgreplied to julian@community.nodebb.org on last edited by
@mauve@mastodon.mauve.moe Also tested a user link, and that also didn't work — shrug maybe it'll work in yours?
-
silverpill@mitra.socialreplied to julian@community.nodebb.org on last edited by
-
fedilinks web+ap is probably the most widely supported, depending on how you count.
-
julian@community.nodebb.orgreplied to silverpill@mitra.social on last edited by
Thanks @silverpill@mitra.social, in my case while making the call is definitely an option, I was hoping for something I could do pre-flight (e.g. an opportunistic HEAD call).
This issue provides some good guidance (with comments from @mauve@mastodon.mauve.moe and @snarfed.org@fed.brid.gy too!), so I'll have to see.
Perhaps it's just the app I'm using and it'll work fine via the web app for Mastodon.
NodeBB will implement a pre-flight HEAD call I think, although we don't yet.
-
silverpill@mitra.socialreplied to julian@community.nodebb.org on last edited by
@julian @mauve @snarfed.org Content negotiation is a standard procedure described in the ActivityPub spec. Supporting other discovery methods might be a good idea (and a good topic for a FEP), but I don't recommend relying on them exclusively.
-
evan@cosocial.careplied to silverpill@mitra.social on last edited by
@silverpill @julian @evan@community.nodebb.org I don't think content negotiation can be the be-all end-all. The <link> element and Link: HTTP headers are good to use. Julian, I will write it up and we'll see where it lands.
-
nightpool@socialhub.activitypub.rocksreplied to evan@cosocial.ca on last edited by@evan1 I agree in theory but in this specific instance I'm not sure I understand where the Link header or meta tag would be helpful (I can definitely see where it'd be helpful for the case of e.g. a browser extension though)
-
julian@community.nodebb.orgreplied to evan@cosocial.ca on last edited by
Thanks @evan@cosocial.ca — that'd be appreciated!
@nightpool@socialhub.activitypub.rocks, this would be helpful in NodeBB's case where we have a web app, so rendering a link to something is just an anchor.
I could theoretically override the anchor click handler to do a backend round-trip to check whether we could load the content in-app, otherwise fall back to a regular browser behaviour (a page navigation).
For example, let's say I link out to Evan's profile here. If NodeBB knew that this link had an alternative AP endpoint, then we could redirect the user instead to the local representation of his profile
-
evan@cosocial.careplied to julian@community.nodebb.org on last edited by
@julian @nightpool agreed. That's positive behaviour.
-
julian: Thanks @silverpill@mitra.social, in my case while making the call is definitely an option, I was hoping for something I could do pre-flight (e.g. an opportunistic HEAD call). Can you explain what you mean by this? Making a GET or HEAD request with Accept: activity+json as the highest priority and HTML as the fallback should work fine and wouldn't require any extra round trips (like a preflight or Link header would)
-
julian: I could theoretically override the anchor click handler to do a backend round-trip to check whether we could load the content in-app, otherwise fall back to a regular browser behaviour (a page navigation). i believe this is what mastodon does, but it's also worth mentioning fep-e232 Object Links as a way to tag a given Link with the appropriate mediaType used for content negotiation: { "@context": "https://www.w3.org/ns/activitystreams", "content": "
This is an object link.
", "tag": { "type": "Link", "name": "object link", "href": "https://example.com/some-object", "mediaType": "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"" } } -
blaine@mastodon.socialreplied to evan@cosocial.ca on last edited by
@evan @julian @nightpool for what it's worth, webfinger should be (re: is) able to do this, even if the implementations in the wild don't. The intent at the time was for webfinger to be the "DNS records" for "social addresses", and the main reasons we didn't just use DNS was because (1) DNS doesn't support anything but bare domain names, (2) management of DNS records at scale is hard, and (3) it wasn't possible to query DNS via the web.
-
blaine@mastodon.socialreplied to blaine@mastodon.social on last edited by
@evan @julian @nightpool lots of folks advocated to support any URI scheme in a webfinger lookup, and that's why we have the "acct" scheme at all - so that email-style addresses could be used alongside http etc URIs!
The <Link> approach definitely works, but feels a bit reinventing-webfinger/creating more complexity in lookups (on the client side).
Hope the context is helpful!
-
evan@cosocial.careplied to blaine@mastodon.social on last edited by
So, for finding the AP equivalent of an URL that I think is a Web page, I'd take these steps:
- Link header: HEAD and look for the Link: header (easy, fast)
- Webfinger: Webfinger the URL (a little more complicated)
- Content negotiation: GET with Accept header set to AS2 type
- Parsing: GET and look for Link: header or <link> elementFor finding the HTML page for an AP object:
- Link header: HEAD and look for Link:
- AS2: GET and look for `url` at top level -
evan@cosocial.careplied to evan@cosocial.ca on last edited by
For finding the HTML page for an AP object:
- Link header: HEAD and look for Link:
- Content negotiation: HEAD with Accept: set to text/html
- AS2: GET and look for `url` at top level -
blaine@mastodon.socialreplied to evan@cosocial.ca on last edited by
@evan @julian @nightpool in the Postel sense, though, it's too bad that a client implementor needs to maintain (at least) four discovery pathways, and may require four separate requests to validate the information. Similarly, an ap host doesn't know which spots a client will check, so needs to implement all four. I'm well out of the standards game, but I'd very much advocate for "pick one and stick with it"
-
evan@cosocial.careplied to blaine@mastodon.social on last edited by
@blaine @julian @nightpool we need you back in the standards game
-
julian@community.nodebb.orgreplied to evan@cosocial.ca on last edited by
@evan@cosocial.ca @blaine@mastodon.social indeed, four different implementations is not ideal. We're at the point where they're all vying for attention.
Would need to weigh pros and cons of each and see whether there is one winner we can all agree on.