December 24, 2004
Mozilla extensions: first steps I'll try to document what I'm doing and what I find, probably a lot is wrong or duplicated - but it may save other people time. The assumption is that you may want to write simple enhancements to your Mozilla/Firefox/Thunderbird - not some ultra-sophisticated application. If this is the case - you probably don't want to worry about the deep meenings of RDF or to understand the many file formats, at least for now. What matters is that you can (relatively) easily get access to almost all the inner features ( address book, editor, passwords, protocols, etc ) and automate almost everything.

Just like a web application starts with some directories in the webapps, and some WEB-INF/web.xml file - in mozilla you need to edit javascript files in certain locations and edit few config files. The syntax and locations are as arbitrary and confusing and complex as for a web server - no surprize here.

For the fastest start on Firefox, get http://xulconsole.mozdev.org/ - it will create a MOZILLA_HOME/chrome/xulconsole/content/repository directory where you can put your .xul or .js files. To execute them you need to enter "chrome://xulconsole/content/repository/myFile.xul" as URL. Same will work for Mozilla - but not Thunderbird, since xulconsole doesn't seem to work.

For Thunderbird and Mozilla, you need to start by editing MOZILLA_HOME/chrome/installed-chrome.txt ( the config file listing all directories - just like webapps ). You need to add a line in the weird syntax, for example:

content,install,url,resource:/chrome/costin/content/
Then create a directory chrome/costin/content, and edit the app config file - contents.rdf.

My example:

<?xml version="1.0"?>
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:chrome="http://www.mozilla.org/rdf/chrome#">
<RDF:Seq about="urn:mozilla:package:root">
<RDF:li resource="urn:mozilla:package:costin"/>
</RDF:Seq>
<RDF:Description about="urn:mozilla:package:costin"
chrome:name="costin"
chrome:displayName="Costin"
chrome:extension="true"
chrome:description="testing "
chrome:author="Costin" />
</RDF:RDF>

In Firefox - this doesn't seem to work very well - at least if you try to use more advanced features or use the advice of removing "overlayinfo" dir ( found in several places ) you'll have a bad surprise ( or I did ). The only solution I found so far is to create an XPI file - but that's far more complicated, lots of steps - so I would strongly advise you either play in Mozilla or use xulconsole as a starting point.

So for Mozilla, Firefox - xulconsole, for Thunderbird, Mozilla - you can start with a package.

For java web developers like me - the app directory is just like a webapplication, with contens.rdf serving the role of web.xml.Â

After you create the base dir, you can start playing using URLs like chrome://costin/content/myFile.xul.

You probably know already that XUL is the XML-based UI definition in mozilla, and that Javascript is the main language, combined with a weird Microsoft COM-like layer that gives access to all native features. That would be subject for another post ( assuming this one goes through my new extension :-)

One more thing - find your profile ( ~/.mozilla/firefox.... or Application Data\Mozilla\... ) and create a file "user.js" containing:

user_pref("nglayout.debug.disable_xul_cache", true);
user_pref("nglayout.debug.disable_xul_fastload", true);

This will allow you to edit and reload your page as much as you want.

A very usefull tool for Mozilla and Firefox ( especially when you start playing with xpi ) - http://ted.mielczarek.org/code/mozilla/extensiondev/

Posted by costin at December 24, 2004 11:00 PM
Comments
Disabled due to spam. Click on the link to post a comment, it'll be sent in email ( and thus usual mail spam filters and blacklist applied ). It may be made accessible later on, but code needs to be written for that. Comments