Hallo,

if anyone is interested in, at least in my mind, an easy way to get
linkification for SCMBug comments in Bugzilla, here's a suggestion
with just changing one template.

Besides changing the Bugzilla function quoteUrls in Bugzilla::Template
like suggested, I got the linkification working by just changing the
template for presenting comments. I created a copy of
comments.html.tmpl in
Bugzilla/template/de/custom/bug/comments.html.tmpl and changed the
last lines for printing the pre-tag to the following:

<pre[% ' id="comment_text_' _ count _ '"' IF mode == "edit" %]>
[%#     Following links SCMBug-style comments to our WebSVN for sourcecode.
  #
  #     First, the original Bugzilla-style comment is saved and a regexp used
  #     to replace the produced text by SCMBug with the appropiate links to
  #     WebSVN. Version numbers, the -->-diff, product name, path and filename
  #     are replaced with links. If no filename is present, e.g. because of
  #     adding a directory, an empty link for filename is generated, which is
  #     not displayed to the user, though. Because I want to be able to blame
  #     the file, after the first replacement I replace every empty link for
  #     the filename and the corresponding "Blame" with nothing.
  #
  #     Replacement needs the ability to capture some information from the 
source
  #     string, like versin numbers etc., and therefore we must use a function
  #     not only accepts a regexp for the source string to replace, but also for
  #     the replacement string to use captured parts of the source string. This
  #     seems only to be the case for the replace-method of the VMethod of 
Template
  #     Toolkit, NOT for the replace-method of the String-Plugin of TT. At 
least I
  #     didn't get it working and found some statements in the web, too.
  #
  #     http://template-toolkit.org/docs/manual/VMethods.html#method_replace
  #
  #     "The repeat filter makes copies of the source material. remove takes a 
Perl
  #     regular expression, deleting the matching occurrences. replace takes a
  #     regular expression and replacement string, but alas, cannot use 
references
  #     such as $1 and $2 in the replacement."
  #
  #     http://www.stonehenge.com/merlyn/LinuxMag/col61.html
  #%]
[%- text = wrapped_comment FILTER quoteUrls(bug.bug_id) -%]
[%- text = 
text.replace('([0-9]+|NONE)\s+--&gt;\s+([0-9]+|NONE)\s+([^:]+):((.+)/([^/\n]+)?)',
 '<a href="http://quellen.potsdam.am-soft.de/wsvn/$3/$4?rev=$1";>$1</a> <a
href="http://quellen.potsdam.am-soft.de/wsvn/$3/$4?op=diff&rev=$2";>--&gt;</a> 
<a href="http://quellen.potsdam.am-soft.de/wsvn/$3/$4?rev=$2";>$2</a> <a
href="http://quellen.potsdam.am-soft.de/wsvn/$3/";>$3</a>:<a 
href="http://quellen.potsdam.am-soft.de/wsvn/$3/$5/#path_$5";>$5</a>/<a 
href="http://quellen.potsdam.am-soft.de/wsvn/$3/$4";>$6</a> (<a
href="http://quellen.potsdam.am-soft.de/wsvn/$3/$4?op=blame";>Blame</a>)') -%]
[%- text.replace('/<a href="http://quellen.potsdam.am-soft.de/wsvn/.+";></a> 
\(<a href="http://quellen.potsdam.am-soft.de/wsvn/.+";>Blame</a>\)', '/') -%]
</pre>

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning
AM-SoFT IT-Systeme - Hameln | Potsdam | Leipzig
 
Telefon: Potsdam: 0331-743881-0
E-Mail:  [email protected]
Web:     http://www.am-soft.de

AM-SoFT GmbH IT-Systeme, Konsumhof 1-5, 14482 Potsdam
Amtsgericht Potsdam HRB 21278 P, Geschäftsführer: Andreas Muchow

_______________________________________________
scmbug-users mailing list
[email protected]
http://lists.mkgnu.net/cgi-bin/mailman/listinfo/scmbug-users

Reply via email to