User:Clarkbw/Bugzilla Link Grabber Extension

From MozillaWiki
Jump to: navigation, search

What is This?

This is an extension I wrote on Thursday April 3rd 2008 for Thunderbird. The extension looks at the mail in thunderbird's message pane munging bugzilla links and references.

The extension converts in two ways:

  • converting long bugzilla links to short form
  • converting bug shorthand notation into links
    • e.g. bug XXX into <a>bug XXX</a>
    • these bug links use the default bugzilla urls and can sometimes be incorrect

The extension has 2 bugzilla system urls included by default

STOP!! This extension requires the STEEL Extension be installed, go grab it from bug 408370 before you wonder why it doesn't work. Also it currently only runs on the 3.0.* nightly builds of Thunderbird. Oh and I love pizza, yummm.

Mockups

Screenshots

Where can I get it?

Source 
github thunderbird-bugzilla-link-grabber

How to Install an Extension in Thunderbird

  1. Install the STEEL Extension from bug 408370
  2. Right-click the link below and choose "Save Link As..." to download and save the file to your hard disk.
  3. In Mozilla Thunderbird, open Add-ons from the Tools menu.
  4. Click the Install button, and locate/select the file you downloaded and click "OK".
Extension (for now) 
bugzillalinkgrabber.xpi

Will you be adding this Feature?

Right now this works just about as well as I'd like it to. The source code is completely available and I'd love to see people try out different things. Don't ask me if you can do something, just go try it. If you want to try something but aren't sure what to do, see the TODO below or ask me for some ideas.

Can you package this up for AMO?

I have no idea how to do that. If you do then I'd love to see you take over that part of the project, just send me an email or write in the Talk for this page.

Preferences

The different bugzillas are stored in the extension preferences. You'll notice the format in the defaults/preferences/bugzillalinkgrabber.js file.

The top level list of bugzillas is at this preference branch id

 "extensions.bugzillalinkgrabber@bryan.clark.bugzillas."

Such that any bugzilla will show up with the name that proceeds that id. This name is seen in the context menu of the user interface.

 "extensions.bugzillalinkgrabber@bryan.clark.bugzillas.bugzilla.mozilla.org"

And that name will be assigned the value of the URL it's equal to

 "https://bugzilla.mozilla.org/show_bug.cgi?id=%s"

So if you wanted to add a new default bugzilla in the preferences you could add a line like this.

 pref("extensions.bugzillalinkgrabber@bryan.clark.bugzillas.b.example.com",
 "http://b.example.com/%s");

And in the context menu people would see b.example.com' and bug URLs would link to http://b.example.com/BUG_ID

TODO

There are lots of things to get done, these are the ones that are on my radar.

I10n

This needs some work and I didn't get a chance to figure out how to fix it. If you know what you're doing with that then grab the source, fix it, and send patches.

Make Preferences Window useful

Right now the preferences window is just junk that came with the extension. The purpose of the options is to allow people to add and remove bugzilla URLs to help customize the plugin to their needs.

Here's some simple ASCII art of how it could look.

+----------------------------------------------------------------------------------------+
|   +--------------------------------------------------------------------------------+   |
|   | name                     | url                                                 |   |
|   | bugzilla.mozilla.org     | https://bugzilla.mozilla.org/show_bug.cgi?id=%s     |   |
|   | bugzilla.gnome.org       | http://bugzilla.gnome.org/show_bug.cgi?id=%s        |   |
|   | bugzilla.freedesktop.org | http://bugzilla.freedesktop.org/show_bug.cgi?id=%s  |   |
|   |                          |                                                     |   |
|   +--------------------------------------------------------------------------------+   |
|   [ add ]  [ edit ]  [ remove ]                                          [ close ]     |
+----------------------------------------------------------------------------------------+

There should also be a way to set the default bugzilla

Get the Context Link Menu Working

The point of the right click context menu is that every "bug ###" text gets linkified to your default bugzilla URL. However sometimes the bugzilla you want is actually another one. We can list the alternate bugzillas in the context menu allowing you to choose the correct one apart from the default.

+------------------------+
| Copy Link Location
|------------------------|
| Save Link Target       |
|------------------------|
| Open Bug in Bugzilla > | +--------------------------+
+------------------------+ | bugzilla.mozilla.org     |
                           | bugzilla.gnome.org       |
                           | bugzilla.freedesktop.org |
                           +--------------------------+

mockup of auto-link context menu

Known Issues

I found the following issues when using the preview version of STEEL and the just-released AJAX version of Bugzilla Link Grabber.

  • "undefined"
    • Sometimes comments that get appended by the AJAX version show up as "undefined".
  • "An error occurred executing the cmd_copy command"
    • Exception... "Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER) [nsIController.doCommand]" nsresult: "0x80004003 (NS_ERROR_INVALID_POINTER)" location: "JS frame :: chrome://global/content/globalOverlay.js :: goDoCommand :: line 81" data: no
    • Occurs when you highlight some comments in the AJAX-appended words and attempt to copy.
  • Leaks in
    • nsDocument
    • nsGlobalWindow

by nth10sd 22:48, 7 April 2008 (PDT)

Credits

The bugzilla regex was grabbed from the bugzilla munger for chatzilla. I'm glad they did the work to make that regex because I definitely couldn't have.