As a security precaution, we have turned on the setting "Require API key authentication for API requests" for everyone. If this has broken something, please contact bugzilla-admin@mozilla.org
Last Comment Bug 406786 - bugzilla-linkify "bug X comment Y" to comment anchor
: bugzilla-linkify "bug X comment Y" to comment anchor
Status: VERIFIED FIXED
[cz-0.9.80]
:
Product: Other Applications
Classification: Client Software
Component: ChatZilla (show other bugs)
: Trunk
: All All
: -- enhancement (vote)
: ---
Assigned To: James Ross
:
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2007-12-04 08:04 PST by Tuukka Tolvanen (sp3000)
Modified: 2008-05-21 01:50 PDT (History)
3 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---


Attachments
Link bug XXX comment YYY (8.52 KB, patch)
2007-12-08 16:54 PST, James Ross
gijskruitbosch+bugs: review+
Details | Diff | Splinter Review

Description User image Tuukka Tolvanen (sp3000) 2007-12-04 08:04:50 PST
would be nice to linkify "bug X comment Y" to e.g. https://bugzilla.mozilla.org/show_bug.cgi?id=X#cY
Comment 1 User image :Gavin Sharp [email: gavin@gavinsharp.com] 2007-12-06 20:56:45 PST
Bugzilla trunk and b.m.o already do this...

https://landfill.bugzilla.org/bugzilla-tip/show_bug.cgi?id=422#c3

bug 406777 comment 0.
Comment 2 User image :Gavin Sharp [email: gavin@gavinsharp.com] 2007-12-06 20:57:42 PST
Wow, I completely ignored what product this was filed against and assumed it was Bugzilla. Ignore my previous comment!
Comment 3 User image James Ross 2007-12-08 16:54:11 PST
Created attachment 292261 [details] [diff] [review]
Link bug XXX comment YYY

I decided to be a little clever with this. Rather than always have a suffix or a completely separate URL for comments, it supports both. The preference bugURL.comment can be a full URL (with %1$s + %2$s) or a suffix (with %s) for the main bugURL preference. It defaults to the correct suffix for Bugzillas.
Comment 4 User image :Gijs 2007-12-09 02:28:10 PST
Comment on attachment 292261 [details] [diff] [review]
Link bug XXX comment YYY

>Index: locales/en-US/chrome/chatzilla.properties
>===================================================================
>-pref.bugURL.help                = The URL used for links to bugs, with "%s" replaced with the bug number. The text "bug " followed by a number will get turned into a link using this URL.
>+pref.bugURL.help                = The URL used for links to bugs. "%s" is replaced with the bug number. The text "bug " followed by a number 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" and "%2$s" are replaced with the bug and comment numbers, respectively. With a suffix, "%s" is replaced with the comment number. The text "bug " followed by a number followed by " comment " followed by another number will get turned into a link using this URL or suffix.

These help strings are no longer correct: bug #czpluginapi works too. Please make the help strings reflect that.



>Index: xul/content/mungers.js
>===================================================================
>RCS file: /cvsroot/mozilla/extensions/irc/xul/content/mungers.js,v
>retrieving revision 1.10
>diff -d -p -u -6 -r1.10 mungers.js
>--- xul/content/mungers.js	4 Sep 2007 08:52:24 -0000	1.10
>+++ xul/content/mungers.js	9 Dec 2007 00:50:00 -0000
>@@ -96,13 +96,13 @@ function initMunger()
>     // 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",
>        /(?:\s|\W|^)((mailto:)?[^:;\\<>\[\]()\'\"\s\u201d]+@[^.<>\[\]()\'\"\s\u201d]+\.[^<>\[\]()\'\"\s\u201d]+)/i,
>                    insertMailToLink, NORMAL_PRIORITY, HIGHER_PRIORITY, false);
>     munger.addRule("bugzilla-link",
>-                   /(?:\s|\W|^)(bug\s+(?:#?\d+|#[^\s,]{1,20}))/i,
>+                   /(?:\s|\W|^)(bug\s+(?:#?\d+|#[^\s,]{1,20})(\s+comment\s+(?:#?\d+|#[^\s,]{1,5}))?)/i,

You're allowing a named comment here? Does bugzilla do that, or some other bug tracking system? Can you give an example?

>@@ -343,26 +343,57 @@ function insertBugzillaLink (matchText, 
>         client.munger.munge(matchText, containerTag, eventData);
>         mungerEntry.enabled = true;
>         return;
>     }
> 
>     var bugURL;
>+    var bugURLcomment;
>     if (eventData.channel)
>+    {
>         bugURL = eventData.channel.prefs["bugURL"];
>+        bugURLcomment = eventData.channel.prefs["bugURL.comment"];
>+    }
>     else if (eventData.network)
>+    {
>         bugURL = eventData.network.prefs["bugURL"];
>+        bugURLcomment = eventData.network.prefs["bugURL.comment"];
>+    }
>     else
>+    {
>         bugURL = client.prefs["bugURL"];
>+        bugURLcomment = client.prefs["bugURL.comment"];
>+    }

This could be more elegant by setting an interim variable to the right prefs object, eliminating the need for braces, and then setting bugURL and bugURLcomment just once, from the right prefs object.



> 
>     if (bugURL.length > 0)
>     {
>         var idOrAlias = matchText.match(/bug\s+#?(\d+|[^\s,]{1,20})/i)[1];
>+        bugURL = bugURL.replace("%s", idOrAlias);
>+
>+        if (matchText.indexOf("comment") != -1)
>+        {
>+            var commentNum = matchText.match(/comment\s+#?(\d+|[^\s,]{1,5})/i)[1];

If you go and remove support for named comments, please remember to update this regex as well.

> <snip>


r=me with the above fixed and/or explained. :-)
Comment 5 User image James Ross 2007-12-12 08:37:46 PST
Checked in with fixes --> FIXED.
Comment 6 User image Tuukka Tolvanen (sp3000) 2008-05-21 01:50:14 PDT
v ChatZilla 0.9.82.1-rdmsoft

Note You need to log in before you can comment on or make changes to this bug.