New Datasources for XUL Templating [Part 3]

I have talked a bit about the new built-in datasources (XML and SQL) developers can use with XUL templating (guide and tutorial). I wanted to wrapup my little foray into XUL template datasources by also talking about custom datasources.

A generic framework for adding any kind of datasource (bug 321170) was created as part of the work to make the new XML and SQL datasources. Creating a custom datasource involves implementing 2 new XPCOM interfaces: nsIXULTemplateQueryProcessor and nsIXULTemplateResult.

With the help of Peter van Hardenberg (of Songbird), I got a simple JavaScript implementation working and available on MDC. The sample is fairly basic, but you could extend it to expose any kind of backend datasource.

Thoughts on STEEL – A Convenience JS Library for Thunderbird

Joey Minta has put together some API ideas for STEEL, a FUEL-like library for Thunderbird. I share David Ascher’s feelings that such a library would be a fantastic way to simplify Thunderbird extension development and get more people building Thunderbird extensions.

Personally, I’d like to see if we could move some FUEL interfaces into the toolkit level instead of duplicating the code for each application. Also, we could look at making a simple, general base interface for some things (like Window) and then override the base interface as needed (think BrowserWindow and MailWindow).

Add your thoughts to the newsgroup post and/or the wiki page.

New Datasources for XUL Templating [Part 2]

XUL, the XML-based UI language used in Mozilla products, has supported templating for a while now. Unfortunately, the only datasources you could use to drive the templates were RDF-based datasources. This has been a hurdle for some, including me, to really dive into XUL templates.

Back in July, I posted about support for using XML datasources with XUL templates. Recently, Laurent Jouanneau and Neil Deakin landed support for using SQLite-based (mozStorage) datasources. The SQL templates are a little harder to test/demo than the XML ones, but you can get a demo working fairly easily using XUL Explorer (use 0.8 just to be safe).

Laurent added some test cases to the bug. We can take those, add a manifest file and use them from XUL Explorer. Here is a storage-templates.zip archive of the test cases with a simple manifest added. Steps to get the mozStorage template tests working:

  1. Download and unzip somewhere
  2. Startup XUL Explorer
  3. Open the ‘Options’ dialog/sheet
  4. Use the ‘Manifest’ section to add the path to the unzipped manifest file
  5. Open one of the mozStorage XUL test files
  6. Preview the XUL to see it work

Here’s what a simple example looks like:





    template + storage
    Should display all 11 products
    
        
            
            
            
            
        
        
        
        
    


Here’s what that looks like when previewed in XUL Explorer:
simple-mozstorage-template.png

The “dynamic parameters” demo is sorta neat too. It lets you pass a value in to dynamically effect the template query and rebuilds the XUL. Here’s what it looks like:
dynamic-mozstorage-template.png

OpenKomodo is Open for Business

ActiveState is ready to start rocking the OpenKomodo project. They have everything ready to go:

All they need now is YOU! Head over and get involved. You can also start thinking about SnapDragon, the full-featured web development tool integrated with Firefox:

Komodo Snapdragon is an idea, a desire, a mission! Web development with Firefox benefits from excellent developer tools such as Firebug, but it needs more. We invite you to help define the future of Komodo Snapdragon. Join the Open Komodo community today and help shape the future!

Great mission! I look forward to SnapDragon planning and development.

Seneca & Extensions

Yesterday, I did my best to convince a bunch of smart, young developers that I was an expert at building extensions for Mozilla applications. It must have worked, they didn’t heckle me out of the room. Seneca’s Dave Humphrey and Chris Tyler have a great group of students working on Mozilla (and other Open Source) projects. I have been impressed with the types of projects the Seneca students completed in the past. This group of students and projects are just as impressive. I got a chance to talk to a few students after the presentation and hope to continue working with the group via IRC or anytime I happen to be at Seneca (like next week).

Can’t wait for the movie!

APNG New and Notable

I have been meaning to post this for a while now, so its kinda old news. The APNG format for animated PNG images is currently available in Firefox 3 alpha releases. I saw that the latest Opera 9.5 alpha releases also support APNG (look under Other Changes). I am glad to see support for the new format getting some traction.

I also came across an neat variation on Justin Dolske’s APNG image editor extension. Holger Will created an editor that uses SVG (& SMIL) to create APNG images. Updated information here. SVG paired with SMIL-based animations can produce some very good animated PNGs.

Andrew Smith, the guy who worked on APNG in Firefox, also has some examples and a review of Holger’s work here.

Hello JS-CTYPES, Goodbye Binary Components

I have been working on a small project that ports Python’s ctypes functionality to Mozilla’s XPCOM system. For those unfamiliar with ctypes, its a Python module that allows developers to declare and call exported methods from binary/shared libraries. Developers can then wrap these binary calls in pure Python.

The JavaScript port, called js-ctypes, will give developers this same kind of functionality in Mozilla’s privileged JavaScript. The idea for the library came after helping many extension developers through the process of building binary (C++) XPCOM components. The story usually went something like this:

  1. Developer wants functionality not built into the Mozilla platform, but easily supported by the native OS.
  2. Developer wants to use a 3rd party library in an extension or xul app.
  3. Developer has methods in native code for performance reasons.

The usual answer to these problems is creating a binary (C++) component to act as a wrapper so the native features can be exposed to JavaScript via XPCOM. However, the process of building binary XPCOM components is significantly harder than JavaScript components. The macros and memory management rules of binary components are harder than JavaScript, but its really the compiler and linker flags, IDL, makefiles and SDK versions that make the process painful. The build process must be repeated for each platform too. For many cases, its just too much work.

The goal of js-ctypes is to allow developers to declare methods in binary libraries and then expose those methods as callable JavaScript functions. Developers can then create pure JavaScript library wrappers around binary libraries – without making binary XPCOM wrappers.

Here is a really simple example of using Window’s native MessageBox call from JavaScript:


const nsINativeType = Components.interfaces.nsINativeType;
 
function msgbox() {
  var library = Components.classes["@mozilla.org/js-ctypes;1"]
                          .createInstance(Components.interfaces.nsINativeLibrary);
  library.open("user32.dll"); // Load the shared Windows DLL

  var messageBox = library.declare(
      "MessageBoxW",          // name of the exported method
      nsINativeType.INT32,    // return type
      nsINativeType.INT32,    // parent hwnd (its a Window's thing)
      nsINativeType.WSTRING,  // Unicode message string
      nsINativeType.WSTRING,  // Unicode title string
      nsINativeType.INT32     // bitflag for buttons to show
  );

  var ret = messageBox(0, "This is the message", "Msg Title 1", 3);
  alert(ret);

  // You can reuse the method
  var ret = messageBox(0, "This is another message", "Msg Title 2", 3);
  alert(ret);
}

The js-ctypes code uses the same libffi library as the Python ctypes module. It is currently known to work on Windows and compiles on Linux, but I haven’t got around to testing it. We need to start the Mac implementation. We also need to add support for struct and more primitive types.

The code is in SVN here and we have a Bugzilla component too (see bugs, file bug).

Note: This functionality cannot be accessed from JavaScript used in web content. Only JavaScript that runs with chrome privileges (extensions and Firefox UI for example) can use js-ctypes.

Mozilla @ OSCON 2007

Mozilla has a relatively large contingent headed to OSCON this year. Here’s the Mozilla speaking line up:

In addition to the speakers, we’ll also be in Booth #202 (floor plan). Its a great location right by the entrance of the convention center. The Mozilla Event Planning group had a cool idea for making the most of our booth – “Office Hours“:

We’d like the opportunity to speak face-to-face with contributors and folks interested in getting involved with Mozilla. Meet up with Mozilla folks during our booth “Office Hours” to ask any questions or relay any suggestions that you may have.

There is a schedule and sign-up sheet for various “Office Hours” topics. If you’re interested in talking about building extensions/XULRunner applications or how AMO works, sign-up and come talk to me and Justin Scott.

Tokyo Developer Conference – FUEL & XULRunner

I was a co-presenter for two sessions at the Tokyo developer conference held a few weeks ago:

  • FUEL & Chrome JavaScript Libraries (slides) : I presented with Gomita-san (picture), a Japanese extension developer who had a detailed presentation on the ways FUEL could help extension developers. We both handled a short Q&A session at the end.
  • Building Applications with XULRunner (slides) : I presented with Taro Matsuzawa (picture), a leader of the MozillaGumi community. Taro’s presentation was about localization issues with XULRunner applications. In the process, he showed how to convert an extension to a XULRunner application. It was a cool dashboard-style, transparent clock widget. We, also, did a short Q&A session at the end.

A couple things I came away with from the conference:

  • The Japanese Mozilla community is very strong, passionate and knowledgeable. Everyone appeared to have a lot of fun and the presenters certainly enjoyed showing off their extensions. I saw a developer build an extension in 3 minutes from scratch – with the help of some well planned editor keyboard macros.
  • Unsurprisingly, Japanese extension developers have the same wishlist for FUEL as any other extension developers: support in toolkit, support in Firefox 2 and support for files/streams, clipboard, … 🙂
  • XULRunner is relatively new to the Japanese scene. There have been some experiments and articles, but it definitely has some room to grow. With the strength and size of the extension development community, I would expect to see growth in Japanese XULRunner development.

Of Communities and Interface Friction

Dave Humphrey’s latest post really got me thinking about a couple things. First, I think what he proposes is a timely, interesting idea. It illustrates the power of the web brought to bear on a particular problem. Specifically, the post got me thinking about building communities and lowering interface friction placed on users. Not exactly peanut butter and chocolate, but I think they are related none the less.

Dave’s idea (read his post for the full details) develops as a reaction to someone else’s solution to a problem:

How can information (medical information, in this case) be vetted or deemed trustworthy by a knowledgeable community (medical professionals)? How can that trust data be used by others looking for reliable information?

The initial solution was to create a web application that contained the details and notes on web pages that were vetted. Users could log into the system and search for trustworthiness level of a given web page. Other users could log into the system and set the trustworthiness level of a given web page.

On the surface, it would seem that a community is being created around the medical information web application. If the service was useful enough to get users to accept the friction of logging into a web application to search or perform data entry, then the community would grow and sustain itself.

However, I doubt that would happen. The many steps needed to reach a result or enter data would turn away most people. We can certainly do better than that and, in fact, have done better. Though unrelated, I could use subscribing to RSS/ATOM feeds as an example. When I find an interesting feed (through normal browsing behavior), I subscribe to the feed from my browser chrome (one way or another). I don’t launch my feed aggregator and manually add the feed. Very soon, browsers will do the same thing for lots of types of information (can you say microformats? yeah, you in the back).

Any usablility guru (and even some normal folk) will tell you that interrupting the user’s flow is a bad thing. Instead of forcing the user into your conceptual model, try working within theirs. In Firefox, you can look at extensions like Operator, Fleck, The Coop and Joey to see where the trend is headed. Heck, Flock is built on the concept. Allowing the user to contribute or share while performing normal browsing, with as few steps as possible, will maximize the value of the community.

Creating an extension that overlays the medical meta-data into the current web page really lowers the friction for users looking for trustworthy data. Allowing the user to “markup” or “annotate” the current web page information really lowers the friction for users assigning trustworthiness to a web page. People who need to determine data trustworthiness can do so with zero effort. People who supply the trustworthiness can do so with minimal effort, so there is more, current trustworthiness data in the system. One side feeds the other to the benefit of both. Just imagine if everyday folk could use such an extension to look for reliable information on the web.

Another reason I like Dave’s idea is a bit selfish. I am not a Facebook guy and I don’t “do” a lot of the “social for the sake of social” stuff (see Twitter et al). But here is a real, social, community (albeit niche) that provides something more than social value. I guess that means I should offer services to make this become a reality. I can only look at pictures of cute cats with witty captions for so long. Dave, what’s your plan?