Developing Firefox Extensions with GNU/Linux

Developers' Corner, continued (publishing)

Publishing

If you're in the business for publishing your extensions yourself, publish will get you started. publish places a numbered copy of your extension installer in Stantz's web repository and reconstructs update.rdf to reflect the currently available version.

After you've deployed your Firefox extension to several million desktops, update.rdf is where each of those instances of Firefox will look to discover that you've released a new version. Firefox will poll this file and notify their user when a new release is available.

Rather than write this file yourself, invoking the publish script calls upon www/update.rdf.build to reconstruct www/update.rdf. Thus, all of your version information stays confined to config.py. www/update.rdf.build will work verbatim with your Firefox extension project.

Content

The content/ branch of your Firefox project contains the meat of your extension. Stantz contains stantz.xul, about.xul, options.xul, browser.xul, and browser.js, along with a resource description file, contents.rdf. stantz.xul is a definition of Stantz's main window. A reference to options.xul in install.rdf causes the Options button in the Firefox extension interface to open this window. browser.xul is an overlay on the main browser's interface that adds a Stantz menu item to the Tools menu.

A word on overlays

Overlays permit extension developers to augment Firefox's core XUL and (hush) other extensions. All this is done without any modification to the definition XUL files. In the grand style of Aspect Oriented Programming, overlays let you yank the carpet from under existing interfaces. Better yet, when you uninstall an extension, Firefox doesn't have to engage in the dubious mess of backtracking your changes without deleting anything important; it simply neglects to overlay your functionality.

Here are the major use cases with overlays. You might want to add something to the main browser interface, like a menu item. First, look through the application's XUL for where you would put your menuitem tag. Your overlay must match the structure of the existing XUL. Your overlay will augment tags that match existing tags by their ids. Tags in overlays can have insertafter and insertbefore attributes which contain comma delimited lists of ids.

This will put a Stantz option in Firefox's Tools menu. Firefox automagically transforms the chrome URL for the entities.dtd file so that &stantz.*; are defined the the user's language, albeit en-US or sumerian.

In a slightly more caffeinated mood, you might want to listen to whenever the main browser interface gets loaded.