Monday, January 17, 2011

Tenth Day In India: Writing a Web App

On Tuesday we will give lectures at the HM Patel Institute, and these need some preparation. Gina and Deborah will give lectures about education, Brian and I will give a workshop on writing a "Book in 8 Minutes", involving collaborative technology. For this I have to write some software, enabling the joint authoring. So on Monday I devote the whole day to this, sitting outside near the entrance of the guest house and hacking away on my computer. The goal is that the students should be able to write a very short story related to the topic "My Place is Gujarat", amended by a photograph from my online collection. We did not want them to use other pictures because of possible copyright issues, therefore we focussed on my collection only. There was now one technical problem to solve: a few years ago, one could directly right-click any picture on Flickr and get the true URL. This has changed: right-click on a picture does not provide means for saving it or getting its true URL; for this one needs to use the Flickr API. So I had a quick look at it - straightforward, one first needs to get an API key, then call a specific function in the FLickr API to get all the info about the picture in an XML response, then parse this to build the actual URL. I did not want to write a parser for XML, so I was looking for something that would make this job easier, and I found phpflickr: this provides the tools for getting info of any Flick picture, just by passing the picture ID to it. Then there is another function for building the URL. So I began writing a little PHP script, using that phpflickr library: to the script the picture ID would be passed, then the image URL for a medium-sized image would be returned. This script in turn would be called from JavaScript on the main page, using AJAX. What the students then had to do when they would want to embed a picture in their page: they would copy the URL of the picture page into a field, click on a button, and the page would receive the unique image URL from where it could be passed on to a web form for storage in a database. All I had to do now was to write a parser to get the image ID from the Flickr image page URL.

This worked fine: the result is here: I did some more minor edits later in the night to have this ready for Tuesday.

At 17:00 we went to Asha Makheesha's C Z Patel College of Business, where an official awards ceremony took place. Gina and Deborah had gon there already earlier, Brian and I wanted to join just before the event would begin. I did not know where the college was, and Brian had missed one turn... so we were a bit lost, when suddenly we met a friend from the HM Patel Institute who recognised us. She engaged another motor cycle rider who was around, and then each of us was riding on the back of a motorcycle heading to the nearby College of Business. The floors on the halls were decorated with graphics made out of coloured powder or sand. The main event venue was outside on a roof terasse, under a large fabric tent roof. The honourable dignitaries were sitting on a podium, waiting for their time to speak. Then the official event started, Asha moderating the proceedings. Brian started to cough, probably a consequence of rushing to this event earlier, and also because of the dust and pollution in the streets. He left the proceedings and went back to the guest house for a brief rest. When he came back 2 1/2 hours later he just came in time for the closing of the official events, after all speeches and prize awards to the students.

Since Brian did not feel very well, we decided to not attend the following dinner and instead head back to the guest house, where I could finish my software for the workshop on Tuesday.

No comments: