Thinking through a “share with Mastodon” button that anyone could embed on a website. It’s a harder problem than a “share with Twitter” button, because there’s no one central host, and it would be ideal to avoid creating a central location to handle these requests. (Mastodon is decentralized, after all.)
As a bonus, I think it would work for indieweb or any other decentralized social platform. Maybe any social platform at all?
This would all be easier if web intents had stuck around. Nonetheless, here’s how it might work. Let’s call it “microshare”, to sit alongside micropub:
- User clicks button on page.
- JS on the page detects whether the
web+social
URI scheme has been registered (I wish this was easier, but you can do this by making an asynchronous request and waiting for it to succeed or fail). - If it has, great! Just forward the user to that URI.
- If not, ask the user what the domain of their social profile is.
- JS (or a back-end server process) goes and fetches that base URL and looks for either a
microshare
metatag or an HTTP header of the formLink: <
. (Mastodon etc would need to support this endpoint and discovery of same.) ;; rel="microshare" - If the endpoint exists, the browser opens a new tab and forwards the user to that URI with additional
text
andurl
URL string parameters populated with the name and the URL of the page being shared respectively. - This new page contains a button to register the URI as the handler for the
web+social
URI scheme. It may also either prompt the user to log in, or, if they’re already logged in, share to that social platform, with the text and URL pre-filled into the form.
There are a few issues here that I’d like to iterate on: I wish URI scheme handling and detection was easier in a browser, for one. Secondly, there’s a potential phishing attack where a malicious website could show a fake login page and harvest someone’s login credentials.
Still, what I like about it is that it uses the web’s existing capabilities and doesn’t enforce a central domain handler (or even a domain as a shim). While it seems more convoluted than a standard href link (and it is), it can be achieved on publisher websites with just a few lines of JavaScript.
I’m sure I’ve missed something important, but I wanted to kick this off as a first step. Let me know what you think!
I’m writing about the intersection of the internet, media, and society. Sign up to my newsletter to receive every post and a weekly digest of the most important stories from around the web.