Monday, February 18, 2008

More with Shindig and Open Social

Get Going
  • After svn checkout, cd to $HOME/shindig/java/gadgets (or wherever you installed).

  • Run "mvn package" and then "mvn jetty:run-war" from this directory.

  • Point your browser at

    http://localhost:8080/gadgets/files/container/sample1.html

    or similar. Note this is an "aggregating client container" for collecting and displaying gadgets. The gadgets are loaded as XML from a specified remote URL and arranged using a layout manager. However, these containers don't know anything about your social networks--they are just for presentation and organization of content. If you actually want to host your own social gadgets you will need to deploy them into the "gadget hosting container"(e.g. Orkut or some other app). This is available on your Shindig server at

    http://localhost:8080/gadgets/files/samplecontainer/samplecontainer.html

  • Note the aggregating client container just shows how to add gadgets from multiple providers. Any social networking information is NOT controlled or accessible by these containers. To run your own gadget and manipulate social network information (such as a user's profile and list of friends), you will need to run your gadget in a container.

  • If you want to add your own sample HTML file for aggregating gadgets, you need to put these in $HOME/shindig/javascript/container/. The maven package command will move these files into java/gadgets/target/gadgets/files/container/myjunk.html.

    You'll then have to shutdown and restart jetty.

    This is a little non-intuitive directory layout but see java/gadgets/pom.xml.

  • The $HOME/shindig/javascript/README is a good place to start.


Hosting your own gadgets.
  • Place your widget code in

    $HOME/shindig/javascript/samplecontainer

    or any subdirectory (like /examples/).

  • After compilation, these will be located in

    ./target/gadgets/files/samplecontainer/

    or any subdirectory (/examples/ in the shindig SVN).

  • These will be served up from

    http://localhost:8080/gadgets/files/samplecontainer/examples/myapp.xml

  • You can use the XML from the sample widget at

    http://code.google.com/apis/opensocial/docs/0.6/devguide.html

  • Just download or cut and past this XML file onto your local file system.


  • For some reason, you will need to change the top:

    <ModulePrefs title="Title of Your Application">
    <Require feature="opensocial-0.6"/>
    </ModulePrefs>

    to
    <ModulePrefs title="People API Howto">
    <Require feature="opensocial-samplecontainer"></Require>
    </ModulePrefs>

    This seems to have been corrected in newer versions. Check the header of the sample gadget and use this as a guideline for your gadget.
  • Anyway, load the samplecontainer URL (http://localhost:8080/gadgets/files/samplecontainer/examples/myapp.xml) in your browser, and then load your gadget by pasting in the URL

    http://localhost:8080/gadgets/files/samplecontainer/examples/myapp.xml
  • If you edit your gadget in any way, you must (apparently) restart your Jetty server.


This gadget is now ready to be displayed in any gadget container.


Putting Your Gadget Into Your Display Container
In the last previous two steps, you a) displayed existing gadgets using the gadget display container and b) set up your own gadget hosting container. The documentation doesn't very clearly distinguish these, but you should see this by now. The display container can load any gadgets (including production gadgets available from iGoogle). The gadget hosting container, on the other hand, is used to run your gadgets with your social network data.

We can now combine the two. Edit any of the sample HTML files in java/target/gadgets/files/container, changing the URL to point to the gadget you made in the previous example. Restart your Jetty server and you should see it correctly displayed.

Similarly, you should be able (if your Jetty server's URL is publicly accessible) to add your social gadget to other display containers.

No comments: