Activity Streams/Microformats Mapping
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/titlep-summary- short entry summarye-content- full content of the entrydt-published- when the entry was publisheddt-updated- when the entry was updatedp-author- who wrote the entry, optionally embedded h-card(s)p-category- entry categories/tagsu-url- entry permalink URLu-uid- unique entry IDp-location- location the entry was posted from, optionally embedh-card,h-adr, orh-geou-in-reply-to- a URL the entry is posted as a response to.p-in-reply-towith embeddedh-cite- the in-reply-to property may also be published with an embedded fullh-citeobject which itself may contain ap-name(title) of the citation,dt-publisheddatetime it was published, andu-urlURL 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:
- HTML5 Parsing
- microformats2 Parsing
There are several open source libraries implementations may use to parse HTML+microformats into JSON:
- See: HTML+microformats2 parsers available for Javascript, node.js, PHP, Ruby and Python.
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": "http://example.org/profiles/sally"
}
... which is equivalent to
{
"@context": "...",
"actor": {
"id": "http://example.org/profiles/sally"
}
}
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="http://sally.example.org/"> <img src="http://sally.example.org/photo.jpg" alt=""/> Sally Jones </a>
... which is equivalent to
<span class="p-author h-card">
<a class="u-url" href="http://sally.example.org/">
<img class="u-photo" src="http://sally.example.org/photo.jpg" alt=""/>
<span class="p-name">Sally Jones</a>
</a>
</span>
... and can be interpreted as the AS2 JSON:
{
"@context": "...",
"author": {
"id": "http://sally.example.org/",
"type": "vcard:Individual",
"vcard:fn": "Sally Jones",
"vcard:photo": "http://sally.example.org/photo.jpg",
}
}
References
- h-adr specification (microformats.org)
- h-card specification (microformats.org)
- h-cite specification (microformats.org)
- h-entry specification (microformats.org)
- h-geo specification (microformats.org)
- microformats2 parsing specification (microformats.org)
- activitystreams-unofficial.py