Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Item2197: Port BugzillaLinkPlugin
- Loading branch information
Showing
13 changed files
with
187 additions
and
190 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
# See bottom of file for default license and copyright information | ||
# ========================= | ||
# | ||
|
||
# ========================= | ||
package Foswiki::Plugins::BugzillaLinkPlugin; # change the package name!!! | ||
|
||
use strict; | ||
use warnings; | ||
|
||
our $VERSION = '1.400'; | ||
our $RELEASE = '1 Mar 2017'; | ||
our $SHORTDESCRIPTION = 'Render links to Bugzilla repositories.'; | ||
our $NO_PREFS_IN_TOPIC = 1; | ||
|
||
my $bugUrl; | ||
my $bugImgUrl; | ||
my $bugListUrl; | ||
my $bugText; | ||
my $milestoneBugListText; | ||
my $keywordsBugListText; | ||
my $myBugListText; | ||
my $debug; | ||
|
||
# ========================= | ||
sub initPlugin { | ||
my ( $topic, $web, $user, $installWeb ) = @_; | ||
|
||
# check for Plugins.pm versions | ||
if ( $Foswiki::Plugins::VERSION < 1 ) { | ||
&Foswiki::Func::writeWarning( | ||
"Version mismatch between BugzillaLinkPlugin and Plugins.pm"); | ||
return 0; | ||
} | ||
|
||
# Get plugin preferences | ||
|
||
$bugUrl = &Foswiki::Func::getPreferencesValue("BUGZILLALINKPLUGIN_BUGURL") | ||
|| "http://localhost/bugzilla/show_bug.cgi?id="; | ||
$bugImgUrl = | ||
&Foswiki::Func::getPreferencesValue("BUGZILLALINKPLUGIN_BUGIMGURL") | ||
|| '%PUBURLPATH{topic="%SYSTEMWEB%.BugzillaLinkPlugin" "bug.gif"}%'; | ||
$bugListUrl = | ||
&Foswiki::Func::getPreferencesValue("BUGZILLALINKPLUGIN_BUGLISTURL") | ||
|| "http://localhost/bugzilla/buglist.cgi?"; | ||
$bugText = &Foswiki::Func::getPreferencesValue("BUGZILLALINKPLUGIN_BUGTEXT") | ||
|| "Bug #"; | ||
$milestoneBugListText = &Foswiki::Func::getPreferencesValue( | ||
"BUGZILLALINKPLUGIN_MILESTONEBUGLISTTEXT") | ||
|| "Buglist for Milestone "; | ||
$keywordsBugListText = | ||
&Foswiki::Func::getPreferencesValue( | ||
"BUGZILLALINKPLUGIN_KEYWORDBUGLISTTEXT") | ||
|| "Buglist for keyword(s) "; | ||
$myBugListText = | ||
&Foswiki::Func::getPreferencesValue("BUGZILLALINKPLUGIN_MYBUGLISTTEXT") | ||
|| "Buglist for user "; | ||
|
||
# Get plugin debug flag | ||
$debug = &Foswiki::Func::getPreferencesFlag("BUGZILLAPLUGIN_DEBUG"); | ||
$debug = 1; | ||
|
||
# Plugin correctly initialized | ||
&Foswiki::Func::writeDebug( | ||
"- Foswiki::Plugins::BugzillaLinkPlugin::initPlugin( $web.$topic ) is OK" | ||
) if $debug; | ||
return 1; | ||
} | ||
|
||
# ========================= | ||
sub commonTagsHandler { | ||
### my ( $text, $topic, $web ) = @_; # do not uncomment, use $_[0], $_[1]... instead | ||
|
||
&Foswiki::Func::writeDebug( | ||
"- BugzillaLinkePlugin::commonTagsHandler( $_[2].$_[1] )") | ||
if $debug; | ||
|
||
# This is the place to define customized tags and variables | ||
# Called by sub handleCommonTags, after %INCLUDE:"..."% | ||
$_[0] =~ s/%BUG\{([0-9]+)\}%/&BugzillaShowBug($1)/geo; | ||
$_[0] =~ s/%BUGLISTMS\{(.+)\}%/&BugzillaShowMilestoneBugList($1)/geo; | ||
$_[0] =~ s/%BUGLISTKEY\{(.+)\}%/&BugzillaShowKeywordsBugList($1)/geo; | ||
$_[0] =~ s/%MYBUGS\{(.+)\}%/&BugzillaShowMyBugList($1)/geo; | ||
} | ||
|
||
sub BugzillaShowBug { | ||
my ($bugID) = @_; | ||
## display a bug img and the bugzilla url | ||
$bugID =~ s/\s*(\S*)\s*/$1/; | ||
return | ||
"<img src='$bugImgUrl' alt='bug' /> [[$bugUrl$bugID][$bugText$bugID]]"; | ||
} | ||
|
||
sub BugzillaShowMilestoneBugList { | ||
my ($mID) = @_; | ||
## display a bug img and a bugzilla milesteone bug list | ||
$mID =~ s/\s*(\S*)\s*/$1/; | ||
return | ||
"<img src='$bugImgUrl' alt='bug' /> [[$bugListUrl" | ||
. "target_milestone=" | ||
. $mID | ||
. "b&target_milestone=$mID][$milestoneBugListText $mID]]"; | ||
} | ||
|
||
sub BugzillaShowKeywordsBugList { | ||
my ($keyWords) = @_; | ||
|
||
# Determine if AND-type or OR-type search | ||
my $type = "allwords"; | ||
$keyWords =~ s/\s*(\S*)\s*/$1/; | ||
my $keyWordsUse = $keyWords; | ||
if ( $_[0] =~ m/\w+,\w+/ ) { | ||
$type = "anywords"; | ||
$keyWordsUse =~ s/,/+/; | ||
} | ||
return "<img src='$bugImgUrl' alt='bug' /> [[$bugListUrl" | ||
. "keywords_type=$type&keywords=$keyWordsUse][$keywordsBugListText \"$keyWords\"]]"; | ||
} | ||
|
||
sub BugzillaShowMyBugList { | ||
my ($mID) = @_; | ||
## display a bug img and a bugzilla milesteone bug list | ||
return "<img src='$bugImgUrl' alt='bug' /> [[$bugListUrl" | ||
. "bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&email1=$mID&emailtype1=exact&emailassigned_to1=1&emailreporter1=1][$myBugListText $mID]]"; | ||
} | ||
1; | ||
|
||
__END__ | ||
Foswiki - The Free and Open Source Wiki, http://foswiki.org/ | ||
Copyright (C) 2008-2013 Foswiki Contributors. Foswiki Contributors | ||
are listed in the AUTHORS file in the root of this distribution. | ||
NOTE: Please extend that file, not this notice. | ||
# Copyright (C) 2000-2001 Andrea Sterbini, a.sterbini@flashnet.it | ||
# Copyright (C) 2001 Peter Thoeny, Peter@Thoeny.com | ||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU General Public License | ||
as published by the Free Software Foundation; either version 2 | ||
of the License, or (at your option) any later version. For | ||
more details read LICENSE in the root of this distribution. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
As per the GPL, removal of this notice is prohibited. | ||
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
data/System/BugzillaLinkPlugin.txt 0664 | ||
lib/Foswiki/Plugins/BugzillaLinkPlugin.pm 0664 | ||
pub/System/BugzillaLinkPlugin/bug.gif 0664 | ||
pub/System/BugzillaLinkPlugin/bug_small.gif 0664 | ||
pub/System/BugzillaLinkPlugin/bug_small.png 0664 | ||
pub/System/BugzillaLinkPlugin/bug_small_white.png 0664 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/perl -w | ||
# | ||
# Build for BugzillaLinkPlugin | ||
# | ||
BEGIN { | ||
foreach my $pc (split(/:/, $ENV{FOSWIKI_LIBS})) { | ||
unshift @INC, $pc; | ||
} | ||
} | ||
|
||
use Foswiki::Contrib::Build; | ||
|
||
# Create the build object | ||
$build = new Foswiki::Contrib::Build( 'BugzillaLinkPlugin' ); | ||
|
||
# Build the target on the command line, or the default target | ||
$build->build($build->{target}); | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.