It was great seeing the Embedded experiences demo at the Rave Hackleton last 
week; this is a proposed feature for OpenSocial whereby widgets can be embedded 
into activity streams and other kinds of feeds with some context data, and 
looks like a really nice feature for users.

I had a look at the spec[1], and it actually wouldn't need any new code in 
Wookie to work fine for W3C Widgets too, and minimal additions to the W3C 
provider in Rave.

E.g., an embed referencing a widget identifier rather than OpenSocial XML file 
looks like this:

<embed>
        <gadget>http://wookie.apache.org/widgets/youtube</gadget>
        <context>9gW2YVBrNVA</context>
</embed>

In this case, we want the YouTube widget to be embedded, playing the specified 
movie.

To render, we can just push the context into the widget using widget 
preferences; in WookieWidgetService in rave-w3c-provider it would look like 
this:

    private W3CWidget getWidgetForViewer(Widget widget, String sharedDataKey, 
User viewer, String eeContextData){
       try {
            connectorService = getWookieConnectorService(wookieServerUrl, 
wookieApiKey, sharedDataKey);
            org.apache.wookie.connector.framework.User user = new 
org.apache.wookie.connector.framework.User(String.valueOf(viewer.getUsername()),
 viewer.getUsername());
            connectorService.setCurrentUser(user);
            
            WidgetInstance instance = 
connectorService.getOrCreateInstance(widget.getUrl());
            // Now push the context data in for embedded experiences//
            connectorService.setPropertyForInstance(instance, false, 
"org.opensocial.ee.context", eeContext);
            return createWidget(instance);

The Widget can then call 
widget.preferences.getItem("org.opensocial.ee.context") to check for the movie 
id.

So if/when Rave does add support for embedded experiences, we can do so across 
widget types pretty trivially.

S

[1] http://docs.opensocial.org/display/OSD/Embedded+Experiences

Reply via email to