Monday, December 14, 2009

Wave blogging… and how it leads me to create my first robot.

Some time ago I have created a “wave” with some funny stuff to share it among my friends. It is working OK, every one of us can put something funny or comment it. But for me there is one missing feature. I cannot directly embed that wave on my blog. (Since I have two blogs, I would prefer also to have choice where exactly I wish to publish this wave.) I would not mind also to give me friends, or everyone, a possibility to comment it.

Since both, Blogger (that I use) and Wave, are from Google, it seemed that they should work already together, but the reality is different.

In the Google Wave Developer Preview video we could see a robot that publish a wave on a special blog . It was bloggy (currently blog-wave@appspot.com ). It evaluates now a bit and the last working version publish the blog on http://blog-wave.appspot.com/your_wave_nickname. Currently is not working.

In the meantime a special kind of user - public@a.googlewave.com  - has been created. It changed recently to easypublic@appspot.com and gives access to everyone who find the wave . (To find public waves search for group:public.)

There is also a possibility to embed a wave in desired website using JavaScript. Very good tutorial about it is here: http://code.google.com/intl/pl/apis/wave/embed/guide.html. The one thing here is that we need to know an id of the wave we want to embed. For that exist already some solutions e.g. robot embeddy (embeddy@appspot.com) that generates the whole JavaScript with the wave id included.

With a small template modification it is also possible to embed a wave inBlogger. We only need to keep in mind that the div id must be unique. The modification can be e.g. as follow:

In head section of the template:

<script>
function showWave(elementId, waveId){
  document.write("<div id="+elementId+"></div>");
  var wave =new WavePanel('https://wave.google.com/wave/');
  wave.setUIConfig('white', 'black', 'Arial', '13px');
  wave.loadWave(waveId);
  wave.init(document.getElementById(elementId));
}
</script>

Since the template is already modified, it is enough just one line of code to embed a wave:

<script>
showWave('unique div id ','googlewave_id…');
</script>

This is working really fine but it is not the same as publishing from a blip.

Google Wave is almost ideal to create extensions for it. I decided to try to create a robot that will help to publish a wave on a Blogger blog. This robot lives under blogroby@appspot.com.

The source code of this robot is here: https://code.google.com/p/blogroby/source/browse/#svn/trunk If someone feels like to extend it, is very welcome.

This robot involves Google Appengine, Blogger API and AuthSub authorization. Describing everything step by step would be a bit complicated. I will just highlight some issues and give links to all the documentation.

My robot consists of two parts. Blogroby.py which is the real robot and Publish.py which is responsible for creating a draft posts with embedded wave.

The only thing what blogroby actually does is to create a link that will authorize publish.py (that lies under http://blogroby.appspot.com/) to the Blogger service. For authorization AuthSub proxy is used, so you newer pass your password to my application. (More about the authorization here: http://code.google.com/intl/pl/apis/blogger/docs/1.0/developers_guide_python.html#Authenticating)

This link passes also a wave id to the publish.py.

Publish.py is a simple Python webapp framework application. (http://code.google.com/intl/pl/appengine/docs/python/gettingstarted/usingwebapp.html) This script first prints a list of your blogs and ask on which blog you want to embed a wave. You choose one blog by clicking its name and then a draft post is created. To avoid double authorization I keep Auth Session Token in session, and since webapp doesn’t support session I used GAEUtilities for that (http://code.google.com/p/gaeutilities/).

That’s it . Enjoy.

PS. I noticed problems with getting blog list when even one blog’s name have any national character.

The wave below demonstrates blogroby. (Visible only for those who are currently logged into Google Wave.)