Google Wave

  • Tags: google, wave
  • Latest: 0.4
  • Last Updated: 12 November 2009
  • Grails version: 1.1.1 > *
  • Authors: null
3 votes
Dependency:
compile ":wave:0.4"

 Documentation

Summary

Installation

To install type:

grails install-plugin wave

Description

The Wave plugin aims to ease the use of the Wave Embed and Wave Robots API by wrapping access through the Grails artifacts. Please note that the features represent the current stage of the Google Wave API which is still under development.

Wave Embed API

The plugin provides a taglib WaveEmbedTagLib to embed wave in your views. You can define following properties in your Config.groovy (optional) to use a custom Wave provider or embed API library.

//custom configuration to access sandbox instance (optional)
grails.plugins.wave.defaultProvider="https://wave.google.com/a/wavesandbox.com/"
grails.plugins.wave.embedAPI="https://wave-api.appspot.com/public/embed.js"

Note: By default the Wave Preview instance is used:

To embed a wave the API has to be initialized by placing a <g:waveHead/> tag in the head of your GSP. Optionally you can use a custom Wave provider for this specific view by setting the provider attribute.

<g:waveHead />

Embedding a Wave

To render a wave in your GSP you can use one of the following tags. The wave will be embedded into an iFrame surrounded by a generated div container. If you want to use a custom id for the div container set to the value of the id attribute.

embedded wave with minimal settings

<g:waveEmbed waveId="googlewave.com!w+BmNwtyw5qH" />
since v0.4 you can pass a raw wave URL.
<g:waveEmbed waveUrl="https://wave.google.com/wave/#restored:wave:googlewave.com!w%252B6YtkJl3kH.14" />
embedded wave with custom div id
<g:waveEmbed id="myWave" waveId="googlewave.com!w+BmNwtyw5qH" />
embedded wave with all attributes
<g:waveEmbed waveId="wavesandbox.com!w+SZ0L_lAi%A" bgcolor="black" color="red" fontsize="15pt"
font="Arial" frameId="waveframe" style="width:500px;height:300px"/>

The only mandatory attribute is the waveId. The rendered wave is being placed in a <div id="waveframe">..</div> container where the id is the given frameId attribute (optional). Please note that the style attribute is applied to the <div> but doesn't affect the look and feel of the wave itself. To customize the wave's styling the properties bgcolor, color fontsize and font can be used.

Note: In order to embed a Wave it has to be public. Check the FAQs (tab on top) if you are facing problems with embedding waves.

Wave Robots API

Currently the Google Robots API allows only implementations hosted at Google App Engine. Hence an installed and configured Grails http://www.grails.org/plugin/app-engine is required to use the following examples.

Creating a new robot

A Wave robot implementation can be seen as a simple Grails service which implements the interface org.grails.plugins.wave.GrailsWaveRobot provided by the package. To generate a robot template service type:

grails create-wave-robot FooBar

This script creates a robot class FooBarRobotService.groovy in your service folder of the app. If you have several robot implementations in your service folder add following definition to your Config.groovy:

grails.plugins.wave.robotBeanName = "FooBarRobotService"

A generic robot implementation looks like this:

import org.grails.plugins.wave.*
import com.google.wave.api.*

class MyRobotService implements GrailsWaveRobot {

boolean transactional = true

static robotName = "Robot Name" static robotVersion = "0.1" static profileUrl = "http://myapp.appspot.com/robot/profile" static imageUrl = "http://myapp.appspot.com/robot/image" static robotCapabilities = [EventType.WAVELET_BLIP_CREATED, EventType.WAVELET_BLIP_REMOVED ]

public void processEvents (RobotMessageBundle eventsBundle) { // place your robot implementation here … } }

Simply set the properties robotName, robotVersion, robotCapabilities and implement the processEvents method. Voilá, your first robot is born. RobotMessageBundle eventsBundle is a DTO for receiving Wave status updates and rendering robot operations to the wave. Information on the structure of the eventsBundle object can be obtained from the Wave Robot API documentation.

The plugin defines following required URL Mappings by default:

  • /_wave/capabilities.xml - Dynamically rendered XML file holding the robot's metadata
  • /_wave/robot/jsonrpc - REST service which delegates to your robot implementation
  • /_wave/robot/profile - REST service for the robot profile

Version History

  • 0.4 - Added auto-wire of robot implementations, reworked script and added artefact template, utils and tag for embbeding by URL
  • 0.3 - Initial release

Bug Tracker

Defects and enhancements can be posted in the Grails-Plugins JIRA: http://jira.codehaus.org/browse/GRAILSPLUGINS/component/14214

Live Demo

You can try the demo implementation at http://grails-wave-plugin.appspot.com. The sources of the sample app can be found at http://code.google.com/p/g-wave/source/checkout

Source Code

The plugin source code can by found in Subversion at http://svn.codehaus.org/grails-plugins/grails-wave. The project is released under Apache Software License 2.0.

References