Monday 15 October 2007

Digg API on AIR

Digg API on AIR

Larger screenshot on Flickr.

Hey, everyone. I do have a programming related post today.

I have been coding in JavaScript, XML/HTML and CSS to create the above simple Digg API AIR application, which retrieves the top (e.g. newest) story for each category on Digg.

I have as good as finished it and will be releasing the AIR installation package (*.air) and source code (*.zip) for anyone who is interested in the AIR platform to look at.

Although I could have done an XmlHttp request without any additional framework, I did use the Prototype JavaScript framework for this project.


Here is a quick rundown of the files used in my application and their purpose:


DiggAPI.xml - This is the file which specifies the name, copyright information and file to use for content, etc. An XML file such as this is a standard requirement in any AIR application.


DiggAPI.html - The application content. This contains all of the HTML code for my application and calls to the neccessary JavaScript functions in my external *.js files.


sampleCert.pfx - The certificate used to sign the AIR application. All AIR applications must be signed to be built, even if not by a recognised body such as VeriSign.


script/AIRAliases.js - JavaScript file containing code used by the AIR runtime. Referencing this file provides convenient aliases for use in your code. Included with AIR SDK.


script/prototype.js - JavaScript file containing code for the Prototype framework. I used the cross-browser new Ajax.request provided by Prototype in my application.


script/DiggAPI.js - JavaScript file containing my code used by the application.


style/DiggAPI.css - Style sheet used to format my links and text colours, etc in my application.


style/digg.png - Digg guy logo image used in my application.


Check back soon for included AIR package and source code. Happy coding. :)



Digg This Story

3 comments:

Timothy Parez said...

Hey,
Looks great, I'll have to look into the whole Air thing as well.

Now that you've tried it, what are the advantages and disadvantages of using Air?

Why use Air as opposed to a desktop application, dashboard or live bar widget?

Sam Saint-Pettersen said...

Thanks.

The advantage to AIR was that I could leverage what I already knew - namely HTML, CSS and JavaScript.

A lot of application frameworks use languages such as Python - which I can get by in (just about), but I'm not so up to speed on.

Although development on that, as my first project in AIR, took longer than I thought; now that I have built one application with it - I can probably use a lot of that HTML as a template.

Compared to a traditional desktop applications, I would say it really depends on what you are doing - you probably would not write a console-based application for the AIR platform or a full blown text editor.

Although another advantage of AIR was that I could do cross-platform - Windows and Mac OS. :)

You use a Mac, I've got a few tweaks to do before I release the package. But after I'm done, maybe you can check it out.

Disadvantages are obviously the requirement to have the runtime installed on the end-client. But this is common nowadays - .NET framework runtimes, anyone?

Another disadvantage concerning development was the need to sign every application, although I do see the advantages for security due to this. But a lot of (hobbyist) developers probably don't have a VeriSign or whatever contract. So its just an extra annoying step.

Timothy Parez said...

I'll give it a try on Mac for you.
It's true that you need the .NET runtime for .NET applications, but they can leverage the power of your operating system and still be cross platform. To me, at the moment, AIR looks a mini browser with the web page built-in.

When compared with technologies such as Silverlight (also JavaScript if you want) or ClickOnce (for automatic deployment) I see very little room for Air, yet I'm hoping to be proven wrong.

I think the problem is that AIR applications are subject to the same limitations as Widgets. For widgets these limitations do not matter as anything more than a widget would have to be an application...

AIR seems to offer more than widgets, less than applications, perhaps something useful in between :-)