Activity Streams/Actions

From W3C Wiki

Current Actions Editor's Draft: [1]

Some examples:

{
  "@context": "http://asjsonld.mybluemix.net",
  "@type": "http://example.org/Thing",
  "displayName": "A Thing",
  "action": {
    "@type": "http://example.org/ShareAction",
    "displayName": "Share This",
    "using": {
      "@type": "as:HttpRequest",
      "method": "GET",
      "url": "http://example.org/target-url"
    }
  }
}
{
  "@context": "http://asjsonld.mybluemix.net",
  "@type": "http://example.org/Thing",
  "displayName": "A Thing",
  "action": {
    "@type": "http://example.org/ShareAction",
    "displayName": "Share This",
    "using": {
      "@type": "as:BrowserView",
      "method": "GET",
      "browserContext": "_new",
      "url": "http://example.org/target-url"
    }
  }
}
{
  "@context": "http://asjsonld.mybluemix.net",
  "@type": "http://example.org/Thing",
  "displayName": "A Thing",
  "action": {
    "@type": "http://example.org/ShareAction",
    "displayName": "Share This",
    "using": {
      "@type": "as:EmbeddedView",
      "mediaType": "text/html",
      "content": "<div>Some embedded HTML</div>"
    }
  }
}
{
  "@context": "http://asjsonld.mybluemix.net",
  "@type": "http://example.org/Thing",
  "displayName": "A Thing",
  "action": {
    "@type": "http://example.org/ShareAction",
    "displayName": "Share This",
    "using": [
      {
        "@type": "as:BrowserView",
        "url": "http://example.org/share-service"
      },
      {
        "@type": "as:HttpRequest",
        "method": "POST",
        "url": "http://api.example.org/share-service?id=123",
        "potentialResult": {
          "@type": "as:Payload",
          "mediaType": "application/ld+json"
        }
      },
      "android-app://com.example/share-service?id=123",
      {
        "@type": [
          "as:Intent",
          "http://example.org/SoftwareApplication"
        ],
        "@id": "urn:app:1234567890",
        "displayName": "iPhone and iPad App",
        "operatingSystem": "iOS"
      },
      {
        "@type": [
          "as:Intent",
          "http://example.org/SoftwareApplication"
        ],
        "@id": "urn:app:0987654321",
        "displayName": "Windows Phone App",
        "operatingSystem": "Windows Phone 8"
      }
    ]
  }
}
{
  "@context": "http://asjsonld.mybluemix.net",
  "@type": "http://example.org/Thing",
  "displayName": "A Thing",
  "action": [
    {
      "@type": "http://example.org/ShareAction",
      "displayName": "Share This",
      "using": {
        "@type": "as:HttpRequest",
        "method": "GET",
        "url": "http://example.org/target-url"
      }
    },
    {
      "@type": "http://example.org/LikeAction",
      "displayName": "Like This",
      "using": {
        "@type": "as:HttpRequest",
        "method": "GET",
        "url": "http://example.org/target-url"
      }
    }
  ]
}
{
  "@context": "http://asjsonld.mybluemix.net",
  "@type": "urn:example:Share",
  "displayName": "A Share",
  "actor": "acct:sally@example.org",
  "object": "urn:example:notes:1",
  "action": {
    "@type": "urn:example:Share",
    "displayName": "Share",
    "using": {
      "@type": "as:HttpRequest",
      "method": "GET",
      "url": "http://www.example.org/targetUrl"
    }
  }
}
{
  "@context": "http://asjsonld.mybluemix.net",
  "@type": "urn:example:Thing",
  "displayName": "A Thing",
  "action": {
    "@type": "urn:example:Share",
    "displayName": "Share",
    "using": {
      "@type": "as:HttpRequest",
      "method": "POST",
      "url": "http://example.org/share",
      "expects": [
        {
          "@type": "as:HtmlForm",
          "parameter": [
            {
              "name": "comment",
              "valueType": "xsd:string",
              "required": false
            }
          ]
        }
      ],
      "potentialResult": [
        {
          "@type": "as:Payload",
          "mediaType": "application/ld+json"
        }
      ]
    }
  }
}

Attempt at something similar to [Indie-Actions] (we can easily render this into indie-actions markup):

{
  "@context": "http://asjsonld.mybluemix.net",
  "@type": "urn:example:Thing",
  "@id": "http://www.example.com/some-kind-of-post",
  "displayName": "A Thing",
  "action": {
    "@type": "urn:example:Share",
    "displayName": "Share"
  }
}

(Notice that there's no "using" attribute. This implies that we want to make the Action available but we're leaving it up to the implementation to figure out how to do it)

The rendered Indie-Action would be (I think):

<indie-action do="urn:example:Share" with="http://www.example.com/some-kind-of-post">Share<indie-action>

If nothing else, we can take a less-elegant but equally workable approach using EmbeddedView, and just drop the index-action markup in directly...

{
  "@context": "http://asjsonld.mybluemix.net",
  "@type": "urn:example:Thing",
  "@id": "http://www.example.com/some-kind-of-post",
  "displayName": "A Thing",
  "action": {
    "@type": "urn:example:Share",
    "displayName": "Share",
    "using": {
      "@type": "as:EmbeddedView",
      "mediaType": "text/html",
      "content": "<indie-action do="urn:example:Share" with="http://www.example.com/some-kind-of-post">Share<indie-action>"
    }
  }
}