webmention- 2 minutes read - 347 words
Let’s see if this works!?
I’ve added the following link to this site’s
baseof.html so that it is now rendered for each page:
<link href="https://us-central1-webmention.cloudfunctions.net/webmention" rel="webmention" />
I discovered indieweb yesterday reading about webmention. Who knows what got me to webmention!?
The principles of both are sound. Instead of relying on come-go behemoths to run our digital world, indieweb seeks to provide technologies that enable us to achieve things without them. webmention is a cross-walled-garden mechanism to perform an evolved form of pingbacks. If X references one of Y’s posts, X’s server notifies Y’s server during publication through a webmention service and, Y can then decide to add reference counts of copies of the referring link to their page. Clever.
There’s a services
Webmention.io that does this all for you but I thought I’d write a simple Golang-based Google Cloud Function to do some of the basics.
Using Aaron’s exemplar but replaced with my target:
POST /webmention-endpoint HTTP/1.1 Host: aaronpk.example Content-Type: application/x-www-form-urlencoded source=https://waterpigs.example/post-by-barnaby target=https://pretired.dazwilkin.com/posts/201203
The idea is that the author of
https://waterpigs.example/post-by-barnaby included a reference (link) to
post-by-barnaby is published, some service looks for links in the page and then, for each external link (e.g.
https://pretired.dazwilkin.com/posts/201203), it GETs the page, looks for a
rel="webmention" link. In this case, it will find the link shown above (
https://us-central1-webmention.cloudfunctions.net/webmention). It then POSTs to the given endpoint with the headers including the
The Google Cloud Function (hopefully) accepts the POST, reads the headers, finds the
target and then it adds this data with a timestamp value to Firestore.
It takes advantage of Firestore’s document hierarchy to create a tree:
pretired.dazwilkin.com/ └── 201203 └── waterpigs.example └── post-by-barnaby
pretired.dazwilkin.com is my site and
201203 is the post which was mentioned.
waterpigs.example is the site and
post-by-barnaby is the post on that site that mentioned it.
The document at the leaf currently simply contains a timestamp for when the mention was detected.
Datetime: December 3, 2020 at 11:02:41 AM UTC-8
But, of course, could be enhanced to include additional metadata.