7

I love how FogBugz automatically creates hyperlinks on the case view page whenever it sees something like http://www.foo.com or https://secure.bar.org.

Can you make it auto-link URLs for other protocols that I use? For example:

  • ftp://ftp.google.com
  • file://fileserver/config.txt
  • gopher://quux.org
flag

2 Answers

6

This isn't built directly into FogBugz for security reasons. However, you can install the BugMonkey plug-in and insert the following JavaScript to link other protocols:

name:          Auto-link more protocols in cases
description:   Makes links out of ftp:// file:// mailto:// etc in cases
author:        Rob Sobers
version:       1.0.0.0

js:

jQuery.fn.addlink = function ()
{  
    var regex = /((ftp|telnet|gopher|file|news|mailto)\:\/\/\w*(\.[a-zA-Z0-9\/\$\-_\@\!\*\""\'\(\)\,\=\;\#\?\:\+\%\~]*)*[a-zA-Z0-9\/])/igm
    return this.each(function ()
    {
      if (this.className.indexOf("editable") < 0 && this.innerHTML.indexOf("emailActions") < 0) {
        this.innerHTML = this.innerHTML.replace(regex, "<a href=\"$1\">$1</a>");
      }
    });
};
$(".bugevent .body").addlink();
$(".bugevent .emailBody").addlink();

You can modify the RegEx to include (or remove) protocols as you wish.

link|flag
I noticed that doing this breaks Reply in cases: the From and To are cleared. Can anyone confirm and maybe even fix this? – Michel de Ruiter Apr 14 2010 at 11:36
If one uses outlook: item links, remove the \/\/ to make them work. I changed the regexp to: ((file|outlook|mailto):[^"'<>&\f\n\r\t\v\u0020\u00A0\u2028\u2029]*[_#a-z0-9\/\]) – Michel de Ruiter Apr 14 2010 at 11:37
@Michel - I replied via email, too. I can't seem to repro the case where this script breaks To and From on replies. I'd be happy to fix it once I do, though. :) – Rob Sobers Apr 14 2010 at 12:48
@Michel - see my latest edit for the fix to the Reply bug. – Rob Sobers Apr 15 2010 at 0:58
That fixed it, great! – Michel de Ruiter Apr 15 2010 at 7:51
show 4 more comments
3

Here's another version that targets Wiki pages and auto-links UNC paths of the type \\server\share:

name:          Auto-link UNC share paths
description:   Makes links out of \\server\share in Wiki pages
author:        Rob Sobers
version:       1.0.0.0

js:

jQuery.fn.addlink = function ()
{
    var regex = /(\\\\([a-z0-9_.$]+)\\([a-z0-9_.$]+))/igm
    return this.each(function ()
    {
      this.innerHTML = this.innerHTML.replace(regex, "<a href=\"$1\">$1</a>");
    });
};

$('#wiki-page-content .article-content').addlink();
link|flag
1 
Some small improvements: name: Auto-link Wiki UNC share paths description: Makes links out of \\server\share in Wiki pages author: Rob Sobers version: 1.0.0.1 js: jQuery.fn.addlink = function () { var regex = /(\\\\([a-z0-9_.$]+)\\([a-z0-9_.$]+)(\\[^"'<>&\f\n\r\t\v\u0020\u00A0\u2028\u2029]*[_#a-z0-9\/\\])?)/igm return this.each(function () { this.innerHTML = this.innerHTML.replace(regex, "<a href=\"file:///$1\">$1</a>"); }); }; $('#wiki-page-content .article-content').addlink(); – Michel de Ruiter Mar 29 2011 at 15:14

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.