Skip to content

Microformats

Michael Beaton edited this page Nov 2, 2022 · 4 revisions

Incoming webmentions may be annotated with microformats. django-wm will look for these data while verifying an incoming webmention.

H-Cards

An h-card contains data about the author of a webmention. This may be embedded within a parent h-entry or h-feed of the mentioning link, or it may be on its own elsewhere on the page.

An h-card element can have many properties but django-wm only records a name, a homepage URL, and an avatar URL. None of these fields are required but at least one of name or homepage must be present in order to create an HCard model instance.

Webmention types

A link may be tagged with, or embedded within an h-cite tagged with, any of the following:

| Type | Microformat/CSS class | Serialized | |----|-- | Default | - | webmention | | Bookmark | u-bookmark-of | bookmark | | Like | u-like-of | like | | Listen | u-listen-of | listen | | Reply | u-in-reply-to | reply | | Repost | u-repost-of | repost | | Translation | u-translation-of | translation | | Watch | u-watch-of | watch |

Examples

<!-- A link tagged with a 'Like' microformat -->
I like this <a class="u-like-of" href="https://your-site.org/content/">post</a>!

<article class="h-entry">
  <!-- h-card associated with the article author -->
  <p>Written by <a href="https://their-site.org" class="h-card">Them</a>.</p>

  <!-- A link embedded within an `h-cite` tagged with a 'Reply' microformat -->
  This article is a response to <span class="h-cite u-in-reply-to">
    <a href="https://your-site.org/content/"> this post </a> by <span class="h-card">YourName</span>.
  </span>
</article>

Once these are accepted by django-wm, they will be serialized in the API as:

// /webmention/get?url=/content/

{
  "target_url": "https://your-site.org/content/",
  "mentions": [
    {
      "hcard": null,
      "quote": null,
      "source_url": "https://their-site.org/some-article",
      "published": "2020-01-17T21:45:24.542Z",
      "type": "like"
    },
    {
      "hcard": {
        "name": "Them",
        "avatar": null,
        "homepage": "https://their-site.org"
      },
      "quote": null,
      "source_url": "https://their-site.org/some-article",
      "published": "2020-01-17T21:45:24.542Z",
      "type": "reply"
    }
  ]
}