diff --git a/locales/en-US/chrome/chatzilla.properties b/locales/en-US/chrome/chatzilla.properties --- a/locales/en-US/chrome/chatzilla.properties +++ b/locales/en-US/chrome/chatzilla.properties @@ -1465,16 +1465,18 @@ pref.autoRejoin.help = If thi pref.away.label = Away status pref.away.help = pref.awayIdleTime.label = Auto-away timeout pref.awayIdleTime.help = After how many minutes of inactivity ChatZilla will set your status to "away". This only works on newer versions of &brandShortName;. Set to 0 to disable it. pref.awayIdleMsg.label = Auto-away message pref.awayIdleMsg.help = The away message ChatZilla will use when you go away. pref.awayNick.label = Nickname (away) pref.awayNick.help = This nickname will automatically be used when you mark yourself away, if different from 'Nickname'. You may leave this blank to not change nickname when going away. +pref.bugKeyword.label = Bug Keywords +pref.bugKeyword.help = You can define multiple issue tracker keywords as a regular expression perhaps by separating them with "|" e.g. bug|issue|case|ticket pref.bugURL.label = Bugzilla URL pref.bugURL.help = The URL used for links to bugs. "%s" is replaced with the bug number or alias. The text "bug " followed by a number or "#" and a 1-20 letter word (bug alias) will get turned into a link using this URL. pref.bugURL.comment.label = Bugzilla URL for Comments pref.bugURL.comment.help = The URL or suffix used for links to specific comments within bugs. With a full URL, "%1$s" is replaced with the bug number or alias and "%2$s" with the comment number, respectively. With a suffix, "%s" is replaced with the comment number. The text "bug " followed by a number or "#" and a 1-20 letter word (bug alias) followed by " comment " followed by another number will get turned into a link using this URL or suffix. pref.charset.label = Character encoding pref.charset.help = For multiple clients to correctly read messages with non-ASCII characters on IRC, they need to use the same character encoding. pref.collapseMsgs.label = Collapse messages pref.collapseMsgs.help = Makes multiple messages from one person only show their nickname against the first, which can look cleaner than having the nickname repeated. diff --git a/xul/content/mungers.js b/xul/content/mungers.js --- a/xul/content/mungers.js +++ b/xul/content/mungers.js @@ -66,19 +66,19 @@ function initMunger() NORMAL_PRIORITY, NORMAL_PRIORITY); munger.addRule("link", client.linkRE, insertLink, NORMAL_PRIORITY, HIGH_PRIORITY); // This has a higher starting priority so as to get it to match before the // normal link, which won't know about mailto and then fail. munger.addRule(".mailto", /(?:\W|^)((mailto:)?[^:;\\<>\[\]()\'\"\s\u201d]+@[^.<>\[\]()\'\"\s\u201d]+\.[^<>\[\]()\'\"\s\u201d]+)/i, insertMailToLink, NORMAL_PRIORITY, HIGHER_PRIORITY, false); - munger.addRule("bugzilla-link", - /(?:\W|^)(bug\s+(?:#?\d+|#[^\s,]{1,20})(?:\s+comment\s+#?\d+)?)/i, - insertBugzillaLink, NORMAL_PRIORITY, NORMAL_PRIORITY); + + addBugzillaLinkMungerRule(client.prefs["bugKeyword"], NORMAL_PRIORITY, NORMAL_PRIORITY); + munger.addRule("channel-link", /(?:[^\w#]|^)[@%+]?(#[^<>,\[\](){}\"\s\u201d]*[^:,.<>\[\](){}\'\"\s\u201d])/i, insertChannelLink, NORMAL_PRIORITY, NORMAL_PRIORITY); munger.addRule("talkback-link", /(?:\W|^)(TB\d{8,}[A-Z]?)(?:\W|$)/, insertTalkbackLink, NORMAL_PRIORITY, NORMAL_PRIORITY); munger.addRule("face", /((^|\s)(?:[>]?[B8=:;(xX][~']?[-^v"]?(?:[)|(PpSs0oO\?\[\]\/\\]|D+)|>[-^v]?\)|[oO9][._][oO9])(\s|$))/, @@ -107,16 +107,24 @@ function initMunger() catch (ex) { // nada } } } } +function addBugzillaLinkMungerRule(keywords, priority, startPriority) +{ + client.munger.addRule("bugzilla-link", + new RegExp("(?:\\W|^)(("+keywords+")\\s+(?:#?\\d+|#[^\\s,]{1,20})(?:\\s+comment\\s+#?\\d+)?)","i"), + insertBugzillaLink, priority, startPriority); + +} + function insertLink(matchText, containerTag, data, mungerEntry) { var href; var linkText; var trailing; ary = matchText.match(/([.,?\)]+)$/); if (ary) @@ -314,36 +322,36 @@ function insertBugzillaLink (matchText, else if (eventData.network) prefs = eventData.network.prefs; var bugURL = prefs["bugURL"]; var bugURLcomment = prefs["bugURL.comment"]; if (bugURL.length > 0) { - var idOrAlias = matchText.match(/bug\s+#?(\d+|[^\s,]{1,20})/i)[1]; + var idOrAlias = matchText.match(new RegExp("(?:"+client.prefs["bugKeyword"]+")\\s+#?(\\d+|[^\\s,]{1,20})","i"))[1]; bugURL = bugURL.replace("%s", idOrAlias); - if (matchText.indexOf("comment") != -1) + var commentNum = matchText.match(/comment\s+#?(\d+)/i); + if (commentNum) { - var commentNum = matchText.match(/comment\s+#?(\d+)/i)[1]; /* If the comment is a complete URL, use only that, replacing %1$s * and %2$s with the bug number and comment number, respectively. * Otherwise, append the comment preference to the main one, * replacing just %s in each. */ if (bugURLcomment.match(/^\w+:/)) { bugURL = bugURLcomment; bugURL = bugURL.replace("%1$s", idOrAlias); - bugURL = bugURL.replace("%2$s", commentNum); + bugURL = bugURL.replace("%2$s", commentNum[1]); } else { - bugURL += bugURLcomment.replace("%s", commentNum); + bugURL += bugURLcomment.replace("%s", commentNum[1]); } } var anchor = document.createElementNS(XHTML_NS, "html:a"); anchor.setAttribute("href", bugURL); // Carry over formatting. var otherFormatting = calcClass(eventData); if (otherFormatting) diff --git a/xul/content/prefs.js b/xul/content/prefs.js --- a/xul/content/prefs.js +++ b/xul/content/prefs.js @@ -104,16 +104,17 @@ function initPrefs() ["autoperform.client", [], "lists.autoperform"], ["autoperform.network", [], "lists.autoperform"], ["autoperform.user", ["whois"], "lists.autoperform"], ["autoRejoin", false, ".connect"], ["away", "", "hidden"], ["awayIdleMsg", "", ".ident"], ["awayIdleTime", 0, ".ident"], ["awayNick", "", ".ident"], + ["bugKeyword", "bug", "appearance.misc"], ["bugURL", "https://bugzilla.mozilla.org/show_bug.cgi?id=%s", "appearance.misc"], ["bugURL.comment", "#c%s", "appearance.misc"], ["ceip.log.client", false, "hidden"], ["ceip.log.command", false, "hidden"], ["ceip.log.dialog", false, "hidden"], ["ceip.log.menu", false, "hidden"], ["ceip.uploadSize", 32 * 1024, "hidden"], @@ -657,16 +658,21 @@ function onPrefChanged(prefName, newValu switch (prefName) { case "awayIdleTime": uninitIdleAutoAway(oldValue); initIdleAutoAway(newValue); break; + case "bugKeyword": + client.munger.delRule("bugzilla-link"); + addBugzillaLinkMungerRule(newValue, 10, 10); + break; + case "channelMaxLines": CIRCChannel.prototype.MAX_MESSAGES = newValue; break; case "charset": client.charset = newValue; break;