I started my first thunderbird extension.
After some success at the start my motivation now rapidly decreases but I still would like to present my results.
Perhaps some information from it is helpful for other beginners.
The idea was an extension which parses a message to be displayed for text fragments matching some regular expression and then map the matching text to some link.
In my company, for example, we are using Jira.
The tickets in Jira can be accessed by URLs like
http://company-server/jira/browse/PROJECT-1
where PROJECT is an example project name in the company Jira.
I want the extension to map the text "PROJECT-1" to the ticket url.
The great vision was then to have a preferences window where regular expressions and urls can be defined, the mapped links should be displayed inline in the message text.
The source code for the extension can be downloaded via anonymous svn from http://subversion.banapple.de/public/linkator/ .
What I got in the end was an extension which was generally able to process a message and do something with it. So if you want to create an extension which manipulates a message or does some action depending on a message when it is displayed you make take my extension. There is a function called processDocument in content/overlay.js where you can implement your own stuff. The function is called when a message is displayed. You can, for example, set the background color of the message with doc.bgColor="#00FF00".
I am not really convinced if this extension makes sense at all, so my motivation was not good enough to finish it.
The parsing of the message is not finished, links are not really mapped, mapped links are not displayed in the text.
Instead only matching texts are added to a linkator box which is placed above the message.
This box is not finished because it is never cleared from old matches.
But it shows how the xul interface of thunderbird can be extended with overlays.
The extension is a mess but here is how I got there.
First I created a dummy extension with the
Extension Wizard.
To test this (already runnable) extension I inserted a file in my thunderbird profile in the extensions directory as described in http://developer.mozilla.org/en/Building_an_Extension (this page is for firefox extensions but it is all the same for thunderbird).
Then I adjusted content/thunderbirdOverlay.xul until I got a new xul element above the message.
The next step was to implement the behaviour of the extension in content/overlay.js.
I got information about how to do this from the source of other extensions
One was Remote Image Cache which showed how to hook in for message processing.
Other useful references:
The XUL tutorial at http://developer.mozilla.org/En/XUL_Tutorial
http://www.xulplanet.com/
Development was hard. To test it thunderbird always had to be restarted. I would like to hear what tools professional extension writers are using.
Saturday, 20 September 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment