Receiving Webmentions may seem like a particularly daunting problem for the staticly generated site owner. In order to receive them, we need a server capable of handling the HTTP posts and implement the server-side of the protocol (Webmention validation, asynchronous processing, possibly another endpoint at which senders can check their results).
It turns out, there’s a service for that: webmention.io. Once you sign-up via See IndieAuth, advertise your Webmention endpoint like so:
<link rel="webmention" href="https://webmention.io/indie-org.sh/webmention" /> <link rel="pingback" href="https://webmention.io/indie-org.sh/xmlrpc" />
Webmention senders will now POST to webmention.io who will store
them on your behalf. You can retrieve them via API call to webmention.io.
indie-org handles this for you via
indie-org-webmentions-check. This function takes the domain name
for which you are checking Webmentions, your webmtion.io API token, and
an
indie-org-webmentions-received struct (another attribute of
indie-org-publication-state). indie-org-webmentions-check
will update the struct with any new Webmentions made.
So armed, we can add a method to our site’s Lisp, meant to be invoked periodically, for checking Webmentions made to our site:
(defun iosh/check-webmentions ()
"Check for new webmentions; update publication state."
(indie-org-enable)
(let* ((env :prod) ;; no staging support ATM
(publication-state
(if (file-exists-p publication-state-file)
(indie-org-state-read publication-state-file)))
(state-for-env
(or (plist-get publication-state env) (indie-org-state-make)))
(webmentions-received
(or (indie-org-state-v2-webmentions-received state-for-env)
(indie-org-webmentions-make-received)))
(token
(indie-org-read-token
webmentions-io-token-file)))
(indie-org-webmentions-check "indie-org.sh" token webmentions-received)
(setf (indie-org-state-v2-webmentions-received state-for-env) webmentions-received)
(plist-put publication-state env state-for-env)
(indie-org-state-write publication-state publication-state-file)))
The site owner will need to arrange for this method to be invoked on a regular basis, perhaps as a cron job. If the owner wishes to display mentions as part of their page template(s), they will need to re-publish on receipt of new Webmentions.