Skip to Content

Exclusive: Rock Band Unplugged Track List
AOL Tech

Filed under: Developer, Macintosh, Web services, Apple, Social Software

Dev Chair : Create a Tumblr widget using Dashcode


Back in December Apple released a beta version of Dashcode, a programming environment which makes it easy to develop OS X Dashboard widgets. The problem with Dashcode is that there is not much information on how to use it available on the internet. Even the documentation that comes with Dashcode provides only the most basic information and does not currently link back to Dashboard documentation.

Meanwhile, we like Tumblr here at Download Squad. It is great for posting quick snippet of content onto a blog-like web page without the need to compose a full length blog post. Tumblr provides a great bookmarklet to make this process even easier. You just click on it to post the current web page in your browser to Tumblr, or you can select some text which becomes a quote on your Tumblr.

Last week, I realised that Tumblr makes an ideal candidate for a Dashboard widget! So I decided to combine these two ingredients and see how easy it is to make a Tumblr widget using Dashcode.

Creating the widget
After firing up Dashcode, the first thing it asks you is which type of widget you want to create. Since a Tumblr widget does not fit within the pre-defined types (Countdown, RSS, Podcast, Photocast, Quartz Composer, Daily Feed, or Gauge), I pick 'Custom'. This tells Dashcode to present a completely blank widget in the Canvas window.

Adding UI elements to the widget canvas is very easy. Just drag the UI element from the 'Library' and drop them onto the canvas. The 'Library' not only includes standard elements such as a text box, text field, button, etc. but also photos from iPhoto and QuickTime movies from iTunes and iPhoto.

Then use the 'Inspector' to set the UI element's properties (e.g. position, name, colours, etc.). You can also use the 'Inspector' to create Javascript event handlers and Dashcode automatically creates the corresponding Javascript function for you.

It was at this point that I suddenly realized a widget is just a web page! Pretty obvious you may think but being a predominately desktop application developer my initial mindset is that widget is like a mini-desktop application.

Talking to Tumblr

Tumblr releases the Write API this week which makes it real easy to create entries in Tumblr. To make a long story short, it involves making a HTTP form POST request to http://tumblr.com/api/write. This is easily done by using the XmlHttpRequest object in JavaScript, and send the data as form data in query strings format. If you have been involved in AJAX, you probably already have an intimate relationship with XmlHttpRequest!

Testing the widget

Testing and debugging the widget is what Dashcode is good at. Before Dashcode, you would have to run the JavaScript code in Safari to test it out. Not a big deal you may say, but after doing this many times over the course of debugging the code, it can become a pain in the butt really quickly!

Dashcode integrates debugging into the IDE so now it's simply a click of a button to start the debug session. And since you are now debugging within an IDE, you have some of the usual IDE tools at your disposal. You can set breakpoints and step through them. There is an 'Evaluator Window' to check out object values, and a 'Stackframes & Variables' window to show all the variables in the current stack.

The Good, the Bad, and the Ugly
So what is good about Dashcode? If the type of widget you are creating falls into one of the pre-defined type then Dashcode will make it almost trivial to create your own widget. More effort is required for creating a custom widgets but Dashcode's drag-n-drop interface and great IDE make it very straightforward; letting you jump into the coding very quickly.

The bad parts? The most glaring omission in this beta release is that the documentation, though functional, is still very barebone in terms of teaching new users how to create a widget. The documentation also doesn't refer to any existing Dashboard documentation on Apple's site which is rather strange. Furthermore, there is only a single reference to Safari's documentation which is also strange since a widget is basically a Safari web page and the user has to know how the JavaScript DOM works in Safari in order to get a widget to do anything mildly interesting.

The ugly part? It is so much fun creating widgets that I can spent all weekend playing with it! Maybe I should file a bug report with Apple about my inability to do anything else from Friday to Sunday?

Reader Comments (Page 1 of 1)

Featured Time Waster

Civiballs is a beautiful, soothing physics puzzle Time Waster

CiviballsI have an absolute weakness for physics games, and while Civiballs isn't the strongest physics-based game, what it lacks in the physics department it makes up for a few times over in style and fun.

In Civiballs, you are presented with a few colored balls, and your goal is to get those balls into the same-colored urn on the level. The "civi" part of Civiballs is that there are 3 sets of levels to play, each representing a different civilization. While the civilization doesn't affect gameplay, the artwork for each level is beautifully themed to it's appropriate era.

To play the game, you are given only one tool - a sword with which to cut the chains that are holding the balls. The puzzle part of the game is in figuring out what order, and with what timing to cut each chain. Do it right, and all the right balls end up in the right urns, with no stray balls entering an urn (a no-no). Do it wrong, and you get to start over again.

Civiballs is not terribly deep on gameplay; the entire game can be completed in about 15 minutes. But if you enjoy this type of game, it will be a very enjoyable 15 minutes.

View more Time Wasters

Featured Galleries

Defective by Design, London: Protest Pictures
Microsoft Security Essentials
Chromium Pre-Alpha on CrunchBang Linux
Safari 4 Beta
10 Firefox themes that don't suck
IE8 RC1
Download Squad at the Crunchies After-Party
Download Squad at the Crunchies
WordPress 2.7
Cooking Mama: Mama Kills Animals
Windows 7 Hands On
Comodo Internet Security
Android First-look: Amazon.com MP3 Store
Android First-look: Twitroid
Google Reader Android
Android Hands-On
Twine 1.0
Photoshop Express Beta
Mozilla Birthday Cake
Palm stuff
Adobe Lightroom 1.1

 


Follow us on Twitter!

Flickr Pool

www.flickr.com

Download Squad bloggers (30 days)

#BloggerPostsCmts
1Lee Mathews7481
2Jay Hathaway671
3Brad Linder674
4Jason Clarke312
5Grant Robertson78
6Christina Warren28
7Nik Fletcher20

More Tech Coverage

AOL Radio