This Gem is Mentionable

submited by
Style Pass
2023-01-27 22:00:19

Mentionable is useful for blogs, news sites, apps that have associated blogs, social apps, and any other Rails app that might be linked to or that links out to other websites.

I mentioned (heh) that I’d been working on a gem to handle inbound Webmentions in Rails on my first newsletter issue last month, but I haven’t spoken too loudly about it elsewhere. While I’ve had it running here on my site since November of 2022, it hasn’t been ready to actually use because it’s really only been saving incoming Webmentions but hasn’t provided a very good API for using them. Until this week that is.

Webmentions are a way for sites to share that they’ve linked to one another. At a very high level, when a site that wants to send Webmentions publishes new content, it can loop through every URL that’s linked to (or embedded, as for a <video>, <audio>, etc.) and check to see if the target of that link supports Webmention by querying for a <link rel="webmention"> element or an HTTP Link header with rel="webmention". If it does, it sends a POST to that URL with the target URL (the page that’s been linked to) and source URL (the page that’s doing the linking). That’s it! You’ve sent a Webmention.

Receiving a Webmention involves checking that the target is actually one of your URLs, saving the Webmention, and later confirming that the source links to the target. Up to now, this is what Mentionable has handled for me. Since setting it up, I’ve received about 100 Webmentions and they’ve been sitting in the site’s database. I’ve been using Brid.gy which polls sites like Mastodon, Reddit, GitHub, and other “siloes” for links to my site, builds a page that’s representative of that link, and sends a Webmention to that representation with a <meta http-equiv="refresh” content> tag that points to the original. Lobste.rs—the smaller, friendlier Hacker News—also sends Webmentions when a link is shared there.

Leave a Comment