4.4.1 Making & Recording Webmentions

The first step in making a Webmention is to express that intent in our Org Mode source files. indie-org implements this by See Adding Hyperlink Types in Adding Hyperlink Types, Adding Hyperlink Types.

When the site author invokes indie-org-webmentions-enable four new link types will be defined:

  1. mention
  2. reply
  3. like
  4. repost

Each link type has a few properties, in particular :follow and :export. indie-org’s link types all implement follow in the same way as standard HTML links; it’s the export aspect in which they differ. While they will all render as standard HTML, they will take the opportunity to note each of them via indie-org-webmentions-record-webmention

For example, the author can indicate a mention like so:

I am mentioning Alice's [[mention:https://alice.net/i-made-a-thing.html][post]].

The site author shall include their publication state’s indie-org-webmentions-made (see Publication Environments & State) in the project properties (under the name :indie-org/webmentions-made); at export time, the custom link types will, first, produce See Microformats appropriate to the sort of webmention being made, then invoke indie-org-webmentions-record-webmention to record them in the current publication environment’s state:

(defun iosh/publish (prod)
  "Publish indie-org.sh to production if PROD is non-nil, locally else."
  (indie-org-enable)
  ;; ...
  (let* ((env (if prod :prod :local))
         (pub-states
          (if (file-exists-p publication-state-file)
           (indie-org-state-read publication-state-file)
         `(:prod ,(indie-org-state-make) :local ,(indie-org-state-make))))
         (publication-state (plist-get pub-states env))
         (webmentions-made
          (or (indie-org-state-v2-webmentions-made publication-state)
              (indie-org-webmentions-make-made)))
         ;; ...
         )
    ;; This is all to setup the call to `org-publish-all'.
    (let* (
           ;; ...
           (org-publish-project-alist
            `(("indie-org.sh" :components ("h-feed" "pages" "posts" "rss"))
              ("posts"
               ;; ...
               :indie-org/webmentions-made ,webmentions-made))))
      (org-publish-all t)
      ;; During the course of publication, we may have updated state: in
      ;; particular, we may have made new webmentions & POSSE requests.  Update
      ;; the publication state's most recent publication time...
      (setf (indie-org-state-v2-last-published publication-state)   (current-time)
            ;; along with new requests:
            (indie-org-state-v2-webmentions-made publication-state) webmentions-made)
      (plist-put pub-states env publication-state)
      ;; and write it all out to disk.
      (indie-org-state-write pub-states publication-state-file))))

You can see an example on indie-org.sh here.