Trac Changeset Links from Chatzilla

2007-03-21T22:12:48Z in web, programming

Update: Chatzilla 0.9.78 breaks this script. Looks like I'll have to add some priority levels to the munger rules when I get some spare time.

Update: New version 0.2, here, allows per-channel Trac sites.

Following this tutorial, I just wrote a Chatzilla script that makes links to Trac changesets from IRC text matching /r\d{1,6}/. You enter:

r42

and you see:

<a href="http://.../changeset/42">r42</a>

It's a bit rough (no per-channel control) but useful enough.

Under your "Auto-load scripts" directory, create a sub-directory named "trac-rev". Save the following script as trac-rev/init.js and modify the changeset URL accordingly:

CHANGESET_URL = "http://YOUR_PROJECT/changeset/%s";

function initPlugin(glob)
{
  plugin.id = "trac-rev";
  plugin.major = 0;
  plugin.minor = 1;
  plugin.version = plugin.major + "." + plugin.minor;
  plugin.description = "link to trac revisions";
  client.munger.addRule(
    "trac-rev-link", /(?:\s|\W|^)(r\d{1,6})/i, mungerTracRev, 1
    );
  display(plugin.id + " v" + plugin.version + " enabled.");
}

function mungerTracRev(matchText, containerTag)
{
  var number = matchText.match(/(\d+)/i)[1];
  var anchor = document.createElementNS("http://www.w3.org/1999/xhtml",
                       "html:a");
  anchor.setAttribute("href", CHANGESET_URL.replace("%s", number));
  anchor.setAttribute("class", "chatzilla-link");
  anchor.appendChild(document.createTextNode(matchText))
  containerTag.appendChild(anchor);
}

Comments

1Re: Trac Changeset Links from Chatzilla

Christopher Schmidt, 2007-03-22T11:21:52Z
Sounds like what oltrac does:
07:21:42 < crschmidt> r783
07:21:46 < oltrac> http://trac.openlayers.org/changeset/783, at , by crschmidt: 
                   Refactor GeoRSS Layer to support 'real' GeoRSS :) (geo:lat, 
                   geo:lon).
07:21:47 < crschmidt> #541
07:21:51 < oltrac> Ticket #541: Drawing a single point takes inordinate amount 
                   of time, http://trac.openlayers.org/ticket/541

Comments are closed after 13 days.

about archive feed search

Some rights reserved by Sean Gillies.