Sunday, July 27, 2008

Shindig Basics

What is Shindig?

As for the famous wikipedia:

Shindig refers to any sort of clever party, covered dish gathering, box social, a brawl, or it can refer to a dance party with lots of music.

Well, we are not talking of dance parties or music here and not about brawl either. Now I wonder why they named the project Shindig?

Shindig is an open source project in the Apache Software Foundation incubator which began in December, 2007, to provide an open source implementation of the OpenSocial specification and gadgets specification.

The software contains both server-side and client-side code. Once the project is mature, an installation of this product will be capable of rendering OpenSocial gadgets in a web browser.

Shindig's goal is to allow new sites to start hosting social applications under an hour's worth of work.

An hour's work? Now that is quite handy and useful guys!

Lets get going...


The architectural components of Shindig:

  • Gadget Container JavaScript -- core JavaScript foundation for general gadget functionality. This JavaScript manages security, communication, UI layout, and feature extensions, such as the OpenSocial API.
  • Gadget Server -- an open source version of gmodules.com, which is used to render the gadget xml into JavaScript and HTML for the container to expose via the container JavaScript.
  • OpenSocial Container JavaScript -- JavaScript environment that sits on top of the Gadget Container JS and provides OpenSocial specific functionality (profiles, friends, activities).
  • OpenSocial Gateway Server -- an open source implementation of the server interface to container-specific information, including the OpenSocial REST APIs, with clear extension points so others can connect it to their own backends.

The Gadget Container JavaScript provides code to generate IFRAMES pointing to gmodules.com, offers some basic gadgets functionality (e.g. dynamic height), a layout manager, the edit dialog box, a cookie-based user preferences store, and an option to point IFRAMES at your Gadget Server instance instead of gmodules.com.

The initial Gadget Server written in Java provides extensible scaffolding for processing gadgets: retrieving XML, parsing it, and processing it into a form that allows rendering of the gadget to a user or retrieval of its metadata.

The initial contribution of the Gadget Server was written in Java, Shindig is language neutral. Ning is planning to contribute an initial version of a PHP Gadget Server, and rumors of C#, Perl, and Ruby.

Downloads

Currently they do not have an automated builds infrastructure set up to offer periodic builds yet, but it will be available soon.

Building and running Shindig

The following steps provide useful information on how to build and run Shindig.

  • Prequisites

  • Get the code

  • Build and run the code (with Maven)

  • Setting up an Eclipse project

  • Running with Caja

Prequisites before building Shindig

In order to build Shindig, you must have the following:

  • Java (JDK/JRE) 1.5 or later installed on your system and the JAVA_HOME environment variable set.

  • A Subversion client installed in order to checkout the code.

  • Apache Maven installed to perform the build.

Getting the code

Create a subdirectory and checkout the Shindig code from its Subversion repository

  1. mkdir ~/src/shindig (or wherever you'd like to put it)

  2. cd ~/src/shindig

  3. svn co http://svn.apache.org/repos/asf/incubator/shindig/trunk/ .

Building and running the code (with Maven)

To build a Web Archive (WAR) file for the Gadget server and run tests, perform the following:

  1. Make sure you have the prerequisites installed first.

  2. cd ~/src/shindig/java/gadgets

  3. mvn package

  4. Once the build successfully completes, you can install the built WAR file (gadgets.war) located in the /target subdirectory onto your JEE server.

To build the code (with no tests) and start a Jetty server that will run on at localhost:8080:

  • mvn jetty:run-war

To run the Jetty server on a different port, use:

  • mvn -Djetty.port= jetty:run

Once you've either installed the WAR file on your JEE server, or are running locally using the Jetty server, you can test the Gadget server using:

Setting up an Eclipse project to build Shindig

These steps, after completing the previous section, will allow you to build from within Eclipse using the Maven2 plugin. You should first install the Maven plugin, then create the new Java project.

  • Create ~/.m2/settings.xml consisting solely of


  • Install the Maven2 plugin

    1. Help -> Software Updates -> Find and Install

    2. Search for new features to install

    3. Create a new remote update site for the Maven 2 plugin

    4. Select the site and click "Finish"

    5. Select only the Maven Integration plug-in (mylyn and subclipse integration have other dependencies.)

    6. Complete the installation

  • Setup new workspace and project
    Creating a new workspace eliminates the performance cost from existing projects and makes it easier to manage the code.

    1. File -> Switch Workspace -> Other...

    2. Select directory to store workspace

      • Do not select a parent directory of the shindig source (e.g. ~/src/shindig) as Eclipse won't allow you to create the Java project.

      • Something like ~/eclipse/workspaces/shindig would work fine

    3. File -> New -> Java Project

      • Select 'Create project from existing source' and navigate to:
        ~/src/shindig/java/gadgets

      • Click Finish

      • If you see a dialog for "Open Associated Perspective", click Ok. Don't worry about the errors after loading as they will be fixed in the next step.

    4. Right-click the project, select Maven : Enable Dependency Management

    5. Right-click the project, select Maven : Update Source Folders

Running with Caja

Caja is an important part of OpenSocial that greatly enhances JavaScript security. Caja is managed in a separate open source project hosted by Google code projects. For more information on Caja, see: http://code.google.com/p/google-caja/wiki/CajaEasyIntro

  1. Load this page: http://localhost:8080/gadgets/samplecontainer/samplecontainer.html

  2. Point it to this gadget: http://hosting.gmodules.com/ig/gadgets/file/117247905274371511495/SocialHelloWorld.xml

To see the cajoled code (Firefox only), right-click inside the iframe and do "This Frame -> View Frame Source"

References

http://en.wikipedia.org

No comments:

Post a Comment