Archive pour août 2009

WordPress As Back End For Posh Widgets and OpenSocial Gadgets

Mercredi 26 août 2009

I developed for percolab.com, under the supervision of my friend Yves Otis a framework that can generate interfaces for OpenSocial gadgets (Orkut, iGoogle), widgets (Portaneo Posh) and HTML.

The goal of this framework is to offer to Québec’s immigrants a way to show to others and themselves their abilities. These abilities are regrouped in activities, themselves grouped under broader terms like Practical Life, Learning French, Experiences, About Me, Working Outside Québec and so on.

The idea is for the immigrant to be able to edit a widget in Posh, or a gadget in Orkut or iGoogle that is generated by the framework. The same core templates are used to generate all the interfaces.

Here’s two examples:

gadget.orkut.png
gadget.igoogle.png

You will note that nothing is really styled or designed. This is an early stage of the project where the designers have not yet worked on the templates.

The framework is based on the marvelous CodeIgniter. Fundamentally, here how it works. Sorry, I’m not very good at modelling, but you will get the basic idea.

schema_simple_epimm.png

Ok, it’s much more complicated than that. I’ll post about it later because the framework use MySQL 5.1 XML capabilities as an almost free form database, where the all the values populating the forms are filtered using a mix of SQL/XPath, XSLT and jQuery, bypassing PHP to do this work. Basically, you drop a form in the framework, and it just work, you don’t have to write new PHP code to handle the values, you don’t need to modify the database schema, you don’t need to edit a config file for the database like in Rails.

To get back to my schema, the first request to the framework is done by a GET from Posh/Orkut/iGoogle, and then, CodeIgniter throw back at the host of the widgets/gadgets a chunk of XHTML where all interactions (create, update, delete )are done with Ajax. In a way, the widget/gadget contains a self-contained mini application.

Some activities are basically resources where the user does not need to edit anything. The only thing he/she can do to contribute is to comment about the resource and add some pointer to other resources on the Internet. Yves, being what he is, asked me, why not using WordPress, so, average people who are not programmers will be able to edit the resources and control/approve the comments? Since WordPress offer a nice interface that almost anybody can use, I plugged WordPress for some activities on the framework.

Here’s an example of an activity of the kind « ressource ».

The top of the gadget.

orkutdico1.png

The bottom of the same gadget.

orkutdico2.png

The content of this gadget is coming from WordPress, and the comment fields, while done in the template that generate the gadget are done in the framework, are hook to WordPress.

When for example, Orkut load this particular gadget, the framework do an XML-RPC request to WordPress using the WordPress XML-RPC API with the methods metaWeblog.getPost and get the content of a specific WordPress post related to the resource needed. The framework also does a request to get all the approved comments for this post with the method wp.getComments. Then the framework throws back the content to the Orkut gadget.

When a user press the button to submit a comment, the values of the comment fields are send to the framework via Ajax (gadget.io.makeRequest() on Orkut/iGoogle and jQuery/$.ajax with Posh). Then the framework does an XML-RPC request with the method wp.newComment to the WordPress blog. The comment is inserted in the WordPress blog, and an email is sent to the administrator to approve this comment.

Here’s another schema that shows what is happening. (Gee, I should really learn how to use OmniGraffle.)

schema_simple2_epimm.png

Letting the framework doing the XML-RPC calls to WordPress is the way to bypass the troubles you get with Ajax and the same origin policy. Also, it’s easier to program this way, than trying to do this from the Orkut gadget or Posh widget, because these kind of environments are quite hard to debug.

So, to sum it up, the user of the gadget never goes to the WordPress blog, she/he never knows in fact that we are using a WordPress blog. We post the comment anonymously, and set WordPress to accept XML-RPC requests, and also allow commenter not to be registered in WordPress.

There was a catch that I have too figured out how to post comment under the name of the commenter on WordPress. In fact the solution was provided kindly by Joseph Scott on one of the WordPress forums. The basic idea, is to leave blank the name and password of the owner of the blog (param 2 and 3) with the method wp.newComment and install a plugin that will implement a filter to allow XML-RPC anonymous comment.

Sylvain Carle will be guest speaker at an event on using WordPress beyond the blog. I’ll guess I will now have to attend :) .

Update (2009-08-27): This conf is just too expensive for me (300 $ to 400 $ for 4 hours).

Rami G. Khouri: Two opposing trends, the same failure

Mercredi 12 août 2009

Very good piece by Rami G. Khouri:

The clash between the colonialism of Israel and the incompetence of Fatah is one of the great tragedies of the modern Middle East, but like all such dynamics it does not pass unnoticed. The rise of Hamas and other militant Palestinian movements has been a direct response to both of these trajectories, an organic Palestinian determination to resist both the pain of perpetual occupation and the added pain of Palestinian complicity in perpetuating this condition.
(…)
The three strategies on show – Israeli colonialism, Fatah’s acquiescence, and Hamas’ resistance – all reflect short-term approaches that are unlikely to generate lasting, just solutions to this conflict, while inflicting more moral pain and physical suffering on all concerned. There are no easy exits from this corner, though the starting point for any movement toward more effective and mutually beneficial policies is to accept that current approaches have been universally catastrophic for all concerned. This lesson is especially relevant for external mediators who try their hand at peace-making.

Rami G. Khouri, Two opposing trends, the same failure, The Daily Star