Support multiple "look for bug in" URLs

classes
Vitaliy Filippov 2016-02-29 00:40:22 +03:00
parent 0bc3e2599c
commit 003913e3fc
5 changed files with 25 additions and 29 deletions

View File

@ -26,14 +26,8 @@ sub get_param_list
}, },
{ {
name => 'viewvc_url', name => 'look_in_urls',
type => 't', type => 'l',
default => '',
},
{
name => 'git_url',
type => 't',
default => '', default => '',
}, },

View File

@ -156,6 +156,8 @@ $vars->{comment_indexes} = sub
return [ map { [ $_->{count}, $_->{comment_id}, $_->{type} != CMT_WORKTIME && $_->{type} != CMT_BACKDATED_WORKTIME ? 1 : 0 ] } @$comments ]; return [ map { [ $_->{count}, $_->{comment_id}, $_->{type} != CMT_WORKTIME && $_->{type} != CMT_BACKDATED_WORKTIME ? 1 : 0 ] } @$comments ];
}; };
$vars->{look_in_urls} = [ map { [ split /:/, $_, 2 ] } grep { /^(?!\s*(#|$))/so } split /\n/, Bugzilla->params->{look_in_urls} ];
Bugzilla->cgi->send_header($format->{ctype}); Bugzilla->cgi->send_header($format->{ctype});
$template->process($format->{template}, $vars) $template->process($format->{template}, $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());

View File

@ -59,3 +59,11 @@ dd {
padding: .5em; padding: .5em;
font-size: small; font-size: small;
} }
pre.cfg_example {
margin: 8px 0;
padding: 4px;
background: white;
float: left;
border: 1px solid gray;
}

View File

@ -18,18 +18,15 @@
_ " \$EMAIL will be replaced by cleartext user email, so you should only never use it in public networks;" _ " \$EMAIL will be replaced by cleartext user email, so you should only never use it in public networks;"
_ " \$MD5 will be replaced by MD5 hash of user email, just like it is required by real Gravatar service." _ " \$MD5 will be replaced by MD5 hash of user email, just like it is required by real Gravatar service."
_ " You can also disable avatar display by clearing this parameter.", _ " You can also disable avatar display by clearing this parameter.",
viewvc_url => look_in_urls =>
"ViewVC query URL for browsing bug-related commits. Bugzilla4Intranet links to ViewVC search page with full-text query 'bugXXX XXX'" "<p style='margin: 0'>VCS/Wiki/whatever query URLs for 'Look for bug in ...' links, one per line, separated by ':'.</p>" _
_ " which allows to show commits with the bug number in the commit message (like 'Bug XXX' or 'BugXXX').", "<pre class='cfg_example'>CVS/SVN: http://viewvc.local/?view=query&comment=bug\$BUG+\$BUG&comment_match=fulltext&querysort=date&date=all</pre>" _
git_url => "<p style='margin: 0; clear: both'>$BUG will be replaced with bug ID in these URLs.</p>",
"Git (GitBlit or other web UI) full-text query URL for browsing bug-related commits. '$q' in URL will be replaced by 'bugXXX XXX'"
_ " which allows to show commits with the bug number in the commit message (like 'Bug XXX' or 'BugXXX').",
wiki_url => wiki_url =>
"Default MediaWiki URL for bug links. Bugzilla4Intranet links to <tt>&lt;wiki_url&gt;/Bug_XXX</tt> pages when this is non-empty.", "Default MediaWiki URL for bug links. Bugzilla4Intranet links to <tt>&lt;wiki_url&gt;/Bug_XXX</tt> pages when this is non-empty.",
mediawiki_urls => mediawiki_urls =>
"<p style='margin: 0'>Known MediaWiki URLs to be quoted in bug comments, one per line. Example:</p>" "<p style='margin: 0'>Known MediaWiki URLs to be quoted in bug comments, one per line. Example:</p>"
_ "<pre style='margin: 8px 0; padding: 4px; background: white; float: left;" _ "<pre class='cfg_example'>wikipedia http://en.wikipedia.org/wiki/</pre>"
_ " border: 1px solid gray;'>wikipedia http://en.wikipedia.org/wiki/</pre>"
_ "<p style='margin: 0; clear: both'>Links like <b><tt>wikipedia:Article_name#Section</tt></b>" _ "<p style='margin: 0; clear: both'>Links like <b><tt>wikipedia:Article_name#Section</tt></b>"
_ " and <b><tt>wikipedia:[[Article name#Section]]</tt></b><br /> will be quoted" _ " and <b><tt>wikipedia:[[Article name#Section]]</tt></b><br /> will be quoted"
_ " and lead to <b>Section</b> (optional) of <b>Article name</b> page in the Wikipedia.</p>", _ " and lead to <b>Section</b> (optional) of <b>Article name</b> page in the Wikipedia.</p>",

View File

@ -1008,22 +1008,17 @@ document.changeform = document.[% cfname %];
[% BLOCK commit_button %] [% BLOCK commit_button %]
[% IF user.id %] [% IF user.id %]
[% w = BLOCK %] [% w = BLOCK %]
[% look_in_viewvc = Param('viewvc_url') %]
[% look_in_git = Param('git_url') %]
[% look_in_wiki = bug.component_obj.wiki_url || bug.product_obj.wiki_url || Param('wiki_url') %] [% look_in_wiki = bug.component_obj.wiki_url || bug.product_obj.wiki_url || Param('wiki_url') %]
[% IF look_in_viewvc || look_in_git || look_in_wiki %] [% IF look_in_wiki %]
[% look_in_wiki = look_in_wiki _ 'Bug_$BUG' %]
[% look_in_urls.push([ 'Wiki', look_in_wiki ]) %]
[% END %]
[% IF look_in_urls %]
Look for [% terms.Bug %] in: Look for [% terms.Bug %] in:
[% IF look_in_viewvc %] [% FOREACH link = look_in_urls %]
<a href="[% look_in_viewvc | html %]?view=query&amp;comment=bug[% bug.bug_id %]+[% bug.bug_id %]&amp;comment_match=fulltext&amp;querysort=date&amp;date=all">CVS&amp;SVN</a> [% IF !loop.first %], [% END %]
[% IF look_in_git || look_in_wiki %] / [% END -%] <a href="[% link.1.replace('\\$BUG', bug.bug_id) | html %]">[% link.0 | html %]</a>
[% END %] [% END %]
[% IF look_in_git %]
<a href="[% look_in_git.replace('\\$q', 'bug' _ bug.bug_id _ '+' _ bug.bug_id) | html %]">Git</a>
[% IF look_in_wiki %] / [% END %]
[% END %]
[% IF look_in_wiki %]
<a href="[% look_in_wiki | html %][% terms.Bug %]_[% bug.bug_id %]">Wiki</a>
[%- END -%]
[% END %] [% END %]
[% END %] [% END %]
<div class="knob-buttons"> <div class="knob-buttons">