Class Index

Classes


Class opensocial.Activity

Representation of an activity.

Activities are rendered with a title and an optional activity body.

You may set the title and body directly as strings when calling opensocial.createActivity.

However, it is usually beneficial to create activities using Activity Templates for the title and body. Activity Templates support:

Activity Templates are defined as messages in the gadget specification. To define messages, you create and reference message bundle XML files for each locale you support.

Example module spec in gadget XML:

<ModulePrefs title="ListenToThis">
  <Locale messages="http://www.listentostuff.com/messages.xml"/>
  <Locale lang="de" messages="http://www.listentostuff.com/messages-DE.xml"/>
</ModulePrefs>

Example message bundle:

<messagebundle>
 <msg name="LISTEN_TO_THIS_SONG">
    ${Subject.DisplayName} told ${Owner.DisplayName} to
    listen to a song!
 </msg>
</messagebundle>

You can set custom key/value string pairs when posting an activity. These values will be used for variable substitution in the templates.

Example JS call:

  var owner = ...;
  var viewer = ...;
  var activity = opensocial.newActivity('LISTEN_TO_THIS_SONG',
   {Song: 'Do That There - (Young Einstein hoo-hoo mix)',
    Artist: 'Lyrics Born', Subject: viewer, Owner: owner})

Associated message:

<msg name="LISTEN_TO_THIS_SONG">
    ${Subject.DisplayName} told ${Owner.DisplayName} to listen
    to ${Song} by ${Artist}
</msg>

People can also be set as values in key/value pairs when posting an activity. You can then reference the following fields on a person:

Users will have many activities in their activity streams, and containers will not show every activity that is visible to a user. To help display large numbers of activities, containers will summarize a list of activities from a given source to a single entry.

You can provide Activity Summaries to customize the text shown when multiple activities are summarized. If no customization is provided, a container may ignore your activities altogether or provide default text such as "Bob changed his status message + 20 other events like this."

Example summaries:

<messagebundle>
  <msg name="LISTEN_TO_THIS_SONG:Artist">
    ${Subject.Count} of your friends have suggested listening to songs
    by ${Artist}!
  </msg>
  <msg name="LISTEN_TO_THIS_SONG:Song">
    ${Subject.Count} of your friends have suggested listening to ${Song}
  !</msg>
  <msg name="LISTEN_TO_THIS_SONG:Subject">
   ${Subject.DisplayName} has recommended ${Song.Count} songs to you.
  </msg>
</messagebundle>

Activity Templates may only have the following HTML tags: <b>, <i>, <a>, <span>. The container also has the option to strip out these tags when rendering the activity.

See also: opensocial.newActivity(), opensocial.requestCreateActivity()
Defined in: opensocial.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Method Summary
Method Attributes Method Name and Description
 
getField(key, opt_params)
Gets the activity data that's associated with the specified key.
 
Gets an ID that can be permanently associated with this activity.
 
setField(key, data)
Sets data for this activity associated with the given key.
Class Detail
opensocial.Activity()
Method Detail
{String} getField(key, opt_params)
Gets the activity data that's associated with the specified key.
Parameters:
{String} key
The key to get data for; see the Field class for possible values
{Map.<opensocial.DataRequest.DataRequestFields|Object>} opt_params
Additional params to pass to the request.
Returns:
{String} The data

{String} getId()
Gets an ID that can be permanently associated with this activity.
Returns:
{String} The ID

setField(key, data)
Sets data for this activity associated with the given key.
Parameters:
{String} key
The key to set data for
{String} data
The data to set

Documentation generated by JsDoc Toolkit 2.0.2 on Wed Nov 12 2008 12:32:43 GMT-0800 (PST)