Activity Streams/Microformats Mapping

From W3C Wiki
Jump to: navigation, search

Mapping microformats [h-entry] -> Activity Streams 2.0.

Property Mapping Table

Activity Streams consumers can consume HTML+microformats and interpret h-entry as the following Activity Streams objects and properties:

h-entry AS 2.0 Notes
p-name as:name
p-summary as:summary
e-content as:content
dt-published as:published
dt-updated as:updated
p-author as:author
p-category as:tag
u-url as:url
u-uid as:id
p-location as:location
u-in-reply-to as:inReplyTo
p-comment as:replies Note, In AS2, the value of as:replies is an as:Collection
u-photo as:image

Informative h-entry property descriptions:

  • p-name - entry name/title
  • p-summary - short entry summary
  • e-content - full content of the entry
  • dt-published - when the entry was published
  • dt-updated - when the entry was updated
  • p-author - who wrote the entry, optionally embedded h-card(s)
  • p-category - entry categories/tags
  • u-url - entry permalink URL
  • u-uid - unique entry ID
  • p-location - location the entry was posted from, optionally embed h-card, h-adr, or h-geo
  • u-in-reply-to - a URL the entry is posted as a response to.
    • p-in-reply-to with embedded h-cite - the in-reply-to property may also be published with an embedded full h-cite object which itself may contain a p-name (title) of the citation, dt-published datetime it was published, and u-url URL of the citation.

These descriptions are informative. For normative definitions of h-entry properties, see the h-entry specification.

Parsing HTML and microformats

Activity Streams consumers that consume HTML+microformats SHOULD do so by implementing these specifications:

There are several open source libraries implementations may use to parse HTML+microformats into JSON:

h-card to AS Actor properties

In an h-entry, typical use of the p-author property includes an embedded h-card with author details such as p-name, u-url, u-photo.

as:author can specify author details such as name, URL, photo.

E.g. in AS2 JSON-LD, an author URL:

  "@context": "...",
  "actor": ""

... which is equivalent to

  "@context": "...",
  "actor": {
    "id": ""

You can add additional properties from from there. In fact, the AS @context definition defines the VCARD mapping already, so you can use VCARD properties directly. Thus:

<a class="p-author h-card" href="">
  <img src="" alt=""/>
  Sally Jones

... which is equivalent to

<span class="p-author h-card">
  <a class="u-url" href="">
    <img class="u-photo" src="" alt=""/>
    <span class="p-name">Sally Jones</a>

... and can be interpreted as the AS2 JSON:

  "@context": "...",
  "author": {
    "id": "",
    "type": "vcard:Individual",
    "vcard:fn": "Sally Jones",
    "vcard:photo": "",