Activity Streams/Microformats Mapping
Mapping microformats [h-entry] -> Activity Streams 2.0.
Contents
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 embedh-card
,h-adr
, orh-geo
-
u-in-reply-to
- a URL the entry is posted as a response to.-
p-in-reply-to
with embeddedh-cite
- the in-reply-to property may also be published with an embedded fullh-cite
object which itself may contain ap-name
(title) of the citation,dt-published
datetime it was published, andu-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:
- 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