Skip Menu |

This queue is for tickets about the RT-BugTracker CPAN distribution.

Report information
The Basics
Id: 79499
Status: resolved
Priority: 0/
Queue: RT-BugTracker

People
Owner: Nobody in particular
Requestors: IDN [...] cpan.org
Cc: rt-cpan [...] trout.me.uk
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



CC: mst [...] cpan.org
Subject: Addition of external bug tracker support to rt.cpan.org
Hi Guys, This is a patch to add an "DistributionBugtracker" attribute to RT queues as used on rt.cpan.org along with associated UI support. Discussion with mst & jibsheet: http://agaton.scsys.co.uk/~matthewt/rt The patch provides a CSS yellow box at the top of queue pages and ticket creation along with a management element for the maintainer to update this information. This is the first stage in pulling the bug tracking information from MetaCPAN. Please let me know if you have any queries or issues with the supplied patch and I'll try my best to get changes made to be more in line with your wishes. Thanks, Ian.
Subject: rt-bugtracker-external-bugtracker.patch

Message body is not shown because it is too large.

Subject: Re: [rt.cpan.org #79499] Addition of external bug tracker support to rt.cpan.org
Date: Fri, 07 Sep 2012 13:48:41 -0700
To: bug-RT-BugTracker [...] rt.cpan.org
From: Thomas Sibley <trs [...] bestpractical.com>
On 09/07/2012 07:30 AM, Ian Norton via RT wrote: Show quoted text
> This is a patch to add an "DistributionBugtracker" attribute to RT > queues as used on rt.cpan.org along with associated UI support. > > Discussion with mst & jibsheet: http://agaton.scsys.co.uk/~matthewt/rt
I'm glad you're working on this. :) Show quoted text
> The patch provides a CSS yellow box at the top of queue pages and ticket > creation along with a management element for the maintainer to update > this information.
I'm not sure we want authors to modify this info directly on rt.cpan.org. Isn't the idea that META.yml (by way of metacpan now) is the authoritative source, and if you want to change your published bug tracker, you should change it there? Allowing people to update the bug tracker on rt.cpan.org itself is asking for stale, out of sync with reality information. If authors have additional info they want to add about their custom bug tracker, it can always go in the distribution notes that are already available. Show quoted text
> This is the first stage in pulling the bug tracking information from > MetaCPAN.
I wonder if it'd be easier to just use JS and the MetaCPAN API to do the display (without the editing of course, as discussed above). Untested, but something like... <script> function showAlternateBugTracker(data) { if (!data || !data.resources || !data.resources.bugtracker) return; var bugs = data.resources.bugtracker; var rtcpan = /rt\.cpan\.org/i; if (bugs.web.match(rtcpan) || bugs.mailto.match(rtcpan)) return; // Great, we have an alternate bugtracker, now inject // some HTML to display it. } </script> <script src="https://api.metacpan.org/release/Moose?callback=showAlternateBugTracker"></script> Show quoted text
> Please let me know if you have any queries or issues with the supplied > patch and I'll try my best to get changes made to be more in line with > your wishes.
My first glance notes on the diff: * It's a diff and not a git patch. It looks like you generated it from two git checkouts though. If you could use git format-patch or even a pull request, that'd be awesome. We like well written commit messages too. :) (This also means files like Makefile.OLD won't be included in the patch.) * It's only against RT-BugTracker, which means it only touches the PAUSE author side of rt.cpan.org, not the public view (where many bugs are viewed/reported). RT-BugTracker-Public is the dist for that. Thomas
Hi Thomas, Attempt number 2! Commit message: This patch adds support for displaying the information added by cpan2rt in rt.cpan.org ticket #80020, it also fixes an inconsistency in display of distribution notes on the ticket modification page. Whilst we don't prevent creation of tickets in a queue with an external bug tracker set, we strongly suggest that they might want to look at the alternative tracking solution indicated. Should this be unavailable, this still enables creation of tickets within rt.cpan.org as a last resort. Please let me know if you require any further information or changes. This work has been sponsored by Shadowcat Systems. Thanks, Ian.
Subject: rt-bugtracker-external.patch
diff --git a/html/Callbacks/BugTracker/Elements/Header/Head b/html/Callbacks/BugTracker/Elements/Header/Head new file mode 100644 index 0000000..8638838 --- /dev/null +++ b/html/Callbacks/BugTracker/Elements/Header/Head @@ -0,0 +1 @@ +<link rel="stylesheet" href="<%RT->Config->Get('WebPath')%>/NoAuth/BugTracker/css/bugtracker.css" type="text/css" media="all" /> diff --git a/html/Callbacks/BugTracker/Ticket/Create.html/FormStart b/html/Callbacks/BugTracker/Ticket/Create.html/FormStart index e8073a5..f68d289 100644 --- a/html/Callbacks/BugTracker/Ticket/Create.html/FormStart +++ b/html/Callbacks/BugTracker/Ticket/Create.html/FormStart @@ -2,5 +2,7 @@ $QueueObj </%ARGS> +<& /Dist/Elements/ShowBugtracker, Queue => $QueueObj &> + <& /Dist/Elements/ShowNotes, Queue => $QueueObj &> diff --git a/html/Callbacks/BugTracker/Ticket/Display.html/BeforeActionList b/html/Callbacks/BugTracker/Ticket/Display.html/BeforeActionList new file mode 100644 index 0000000..8b8d82f --- /dev/null +++ b/html/Callbacks/BugTracker/Ticket/Display.html/BeforeActionList @@ -0,0 +1,8 @@ +<%ARGS> +$Ticket +</%ARGS> + +<& /Dist/Elements/ShowBugtracker, Queue => $Ticket->QueueObj &> + +<& /Dist/Elements/ShowNotes, Queue => $Ticket->QueueObj &> + diff --git a/html/Callbacks/BugTracker/Ticket/Modify.html/BeforeActionList b/html/Callbacks/BugTracker/Ticket/Modify.html/BeforeActionList new file mode 100644 index 0000000..8b8d82f --- /dev/null +++ b/html/Callbacks/BugTracker/Ticket/Modify.html/BeforeActionList @@ -0,0 +1,8 @@ +<%ARGS> +$Ticket +</%ARGS> + +<& /Dist/Elements/ShowBugtracker, Queue => $Ticket->QueueObj &> + +<& /Dist/Elements/ShowNotes, Queue => $Ticket->QueueObj &> + diff --git a/html/Callbacks/BugTracker/Ticket/Update.html/BeforeActionList b/html/Callbacks/BugTracker/Ticket/Update.html/BeforeActionList new file mode 100644 index 0000000..51854cc --- /dev/null +++ b/html/Callbacks/BugTracker/Ticket/Update.html/BeforeActionList @@ -0,0 +1,6 @@ +<%ARGS> +$Ticket +</%ARGS> + +<& /Dist/Elements/ShowBugtracker, Queue => $Ticket->QueueObj &> + diff --git a/html/Dist/Display.html b/html/Dist/Display.html index 0e4c329..9107dc9 100755 --- a/html/Dist/Display.html +++ b/html/Dist/Display.html @@ -57,6 +57,8 @@ Title => $title, &> +<& /Dist/Elements/ShowBugtracker, Queue => $QueueObj &> + <& /Dist/Elements/ShowNotes, Queue => $QueueObj &> <& /Dist/Elements/ShowMaintainers, Queue => $QueueObj &> diff --git a/html/Dist/Elements/ShowBugtracker b/html/Dist/Elements/ShowBugtracker new file mode 100644 index 0000000..61ad41b --- /dev/null +++ b/html/Dist/Elements/ShowBugtracker @@ -0,0 +1,14 @@ +% if ( defined $bugtracker && length $bugtracker ) { +<div id="external_bugtracker"> +<h3><% loc("Alternative bug tracker") %></h3> + +<p><% $bugtracker |n %></p> +</div> +% } + +<%ARGS> +$Queue +</%ARGS> +<%INIT> +my $bugtracker = $Queue->DistributionBugtracker; +</%INIT> diff --git a/html/NoAuth/BugTracker/autohandler b/html/NoAuth/BugTracker/autohandler new file mode 100644 index 0000000..dabe704 --- /dev/null +++ b/html/NoAuth/BugTracker/autohandler @@ -0,0 +1,60 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +%# <sales@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# LICENSE: +%# +%# This work is made available to you under the terms of Version 2 of +%# the GNU General Public License. A copy of that license should have +%# been provided with this software, but in any event can be snarfed +%# from www.gnu.org. +%# +%# This work 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. See the GNU +%# General Public License for more details. +%# +%# You should have received a copy of the GNU General Public License +%# along with this program; if not, write to the Free Software +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. +%# +%# +%# CONTRIBUTION SUBMISSION POLICY: +%# +%# (The following paragraph is not intended to limit the rights granted +%# to you to modify and distribute this software under the terms of +%# the GNU General Public License and is only of importance to you if +%# you choose to contribute your changes and enhancements to the +%# community by submitting them to Best Practical Solutions, LLC.) +%# +%# By intentionally submitting any modifications, corrections or +%# derivatives to this work, or any other work intended for use with +%# Request Tracker, to Best Practical Solutions, LLC, you confirm that +%# you are the copyright holder for those contributions and you grant +%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +%# royalty-free, perpetual, license to use, copy, create derivative +%# works based on those contributions, and sublicense and distribute +%# those contributions and any derivatives thereof. +%# +%# END BPS TAGGED BLOCK }}} +<%init> +my $file = $m->base_comp->source_file; + +if ($file =~ /\.(gif|png|jpe?g)$/i) { + my $relfile = $m->base_comp->path; + RT::Interface::Web->SendStaticFile( File => $file, RelativeFile => $relfile ); +} else { + RT::Interface::Web::StaticFileHeaders(); + $r->content_type('text/css') ; + $m->call_next(); + return(); +} +</%init> diff --git a/html/NoAuth/BugTracker/css/bugtracker.css b/html/NoAuth/BugTracker/css/bugtracker.css new file mode 100644 index 0000000..3aea179 --- /dev/null +++ b/html/NoAuth/BugTracker/css/bugtracker.css @@ -0,0 +1,12 @@ +#external_bugtracker { + width: 50%; + border: 1px solid #666; + background: #ffffaa url(<%RT->Config->Get('WebPath')%>/NoAuth/BugTracker/images/warn.png) 8px 15px no-repeat; + padding: 0px 10px 10px 60px; + margin: 20px auto; + min-height: 30px; + -webkit-box-shadow: inset 2px 2px 2px 2px #999; + box-shadow: inset 2px 2px 2px 2px #999; + -webkit-border-radius: 10px; + border-radius: 10px; +} diff --git a/html/NoAuth/BugTracker/images/dhandler b/html/NoAuth/BugTracker/images/dhandler new file mode 100644 index 0000000..6ec9dea --- /dev/null +++ b/html/NoAuth/BugTracker/images/dhandler @@ -0,0 +1,8 @@ +<%INIT> +use File::Basename; +my $arg = $m->dhandler_arg; +my $file = dirname($m->current_comp->source_file) . '/source/'. $arg; +RT::Interface::Web->SendStaticFile( File => $file ); + +$m->abort; +</%INIT> diff --git a/html/NoAuth/BugTracker/images/source/warn.png b/html/NoAuth/BugTracker/images/source/warn.png new file mode 100644 index 0000000..db0529d Binary files /dev/null and b/html/NoAuth/BugTracker/images/source/warn.png differ diff --git a/lib/RT/BugTracker.pm b/lib/RT/BugTracker.pm index 7ce1781..892b19c 100644 --- a/lib/RT/BugTracker.pm +++ b/lib/RT/BugTracker.pm @@ -85,6 +85,18 @@ overriden. We currently in sync with RT 3.6.6. require RT::Queue; package RT::Queue; +sub DistributionBugtracker { + return (shift)->_AttributeBasedField( + DistributionBugtracker => @_ + ); +} + +sub SetDistributionBugtracker { + return (shift)->_SetAttributeBasedField( + DistributionBugtracker => @_ + ); +} + sub DistributionNotes { return (shift)->_AttributeBasedField( DistributionNotes => @_
Third time lucky, right?! ;)
Subject: rt-bugtracker-external.patch
diff --git a/html/Callbacks/BugTracker/Elements/Header/Head b/html/Callbacks/BugTracker/Elements/Header/Head new file mode 100644 index 0000000..8638838 --- /dev/null +++ b/html/Callbacks/BugTracker/Elements/Header/Head @@ -0,0 +1 @@ +<link rel="stylesheet" href="<%RT->Config->Get('WebPath')%>/NoAuth/BugTracker/css/bugtracker.css" type="text/css" media="all" /> diff --git a/html/Callbacks/BugTracker/Ticket/Create.html/FormStart b/html/Callbacks/BugTracker/Ticket/Create.html/FormStart index e8073a5..f68d289 100644 --- a/html/Callbacks/BugTracker/Ticket/Create.html/FormStart +++ b/html/Callbacks/BugTracker/Ticket/Create.html/FormStart @@ -2,5 +2,7 @@ $QueueObj </%ARGS> +<& /Dist/Elements/ShowBugtracker, Queue => $QueueObj &> + <& /Dist/Elements/ShowNotes, Queue => $QueueObj &> diff --git a/html/Callbacks/BugTracker/Ticket/Display.html/BeforeActionList b/html/Callbacks/BugTracker/Ticket/Display.html/BeforeActionList new file mode 100644 index 0000000..8b8d82f --- /dev/null +++ b/html/Callbacks/BugTracker/Ticket/Display.html/BeforeActionList @@ -0,0 +1,8 @@ +<%ARGS> +$Ticket +</%ARGS> + +<& /Dist/Elements/ShowBugtracker, Queue => $Ticket->QueueObj &> + +<& /Dist/Elements/ShowNotes, Queue => $Ticket->QueueObj &> + diff --git a/html/Callbacks/BugTracker/Ticket/Modify.html/BeforeActionList b/html/Callbacks/BugTracker/Ticket/Modify.html/BeforeActionList new file mode 100644 index 0000000..8b8d82f --- /dev/null +++ b/html/Callbacks/BugTracker/Ticket/Modify.html/BeforeActionList @@ -0,0 +1,8 @@ +<%ARGS> +$Ticket +</%ARGS> + +<& /Dist/Elements/ShowBugtracker, Queue => $Ticket->QueueObj &> + +<& /Dist/Elements/ShowNotes, Queue => $Ticket->QueueObj &> + diff --git a/html/Callbacks/BugTracker/Ticket/Update.html/BeforeActionList b/html/Callbacks/BugTracker/Ticket/Update.html/BeforeActionList new file mode 100644 index 0000000..51854cc --- /dev/null +++ b/html/Callbacks/BugTracker/Ticket/Update.html/BeforeActionList @@ -0,0 +1,6 @@ +<%ARGS> +$Ticket +</%ARGS> + +<& /Dist/Elements/ShowBugtracker, Queue => $Ticket->QueueObj &> + diff --git a/html/Dist/Display.html b/html/Dist/Display.html index 0e4c329..9107dc9 100755 --- a/html/Dist/Display.html +++ b/html/Dist/Display.html @@ -57,6 +57,8 @@ Title => $title, &> +<& /Dist/Elements/ShowBugtracker, Queue => $QueueObj &> + <& /Dist/Elements/ShowNotes, Queue => $QueueObj &> <& /Dist/Elements/ShowMaintainers, Queue => $QueueObj &> diff --git a/html/Dist/Elements/ShowBugtracker b/html/Dist/Elements/ShowBugtracker new file mode 100644 index 0000000..bfe407b --- /dev/null +++ b/html/Dist/Elements/ShowBugtracker @@ -0,0 +1,24 @@ +% if ( defined $bugtracker ) { +<div id="external_bugtracker"> +<h3><% loc("Alternative bug tracker") %></h3> +% +% if ( defined $bugtracker->{mailto} ) { +<p> +<div>Please email the <a href="mailto:<% $bugtracker->{mailto} |n %>">alternative bug tracker</a> to report your issue.</div> +</p> +% } +% +% if ( defined $bugtracker->{web} ) { +<p> +<div>Please visit the <a href="<% $bugtracker->{web} |n %>">alternative bug tracker</a> to report your issue.</div> +</p> +% } +</div> +% } +% +<%ARGS> +$Queue +</%ARGS> +<%INIT> +my $bugtracker = $Queue->DistributionBugtracker; +</%INIT> diff --git a/html/NoAuth/BugTracker/autohandler b/html/NoAuth/BugTracker/autohandler new file mode 100644 index 0000000..dabe704 --- /dev/null +++ b/html/NoAuth/BugTracker/autohandler @@ -0,0 +1,60 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +%# <sales@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# LICENSE: +%# +%# This work is made available to you under the terms of Version 2 of +%# the GNU General Public License. A copy of that license should have +%# been provided with this software, but in any event can be snarfed +%# from www.gnu.org. +%# +%# This work 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. See the GNU +%# General Public License for more details. +%# +%# You should have received a copy of the GNU General Public License +%# along with this program; if not, write to the Free Software +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. +%# +%# +%# CONTRIBUTION SUBMISSION POLICY: +%# +%# (The following paragraph is not intended to limit the rights granted +%# to you to modify and distribute this software under the terms of +%# the GNU General Public License and is only of importance to you if +%# you choose to contribute your changes and enhancements to the +%# community by submitting them to Best Practical Solutions, LLC.) +%# +%# By intentionally submitting any modifications, corrections or +%# derivatives to this work, or any other work intended for use with +%# Request Tracker, to Best Practical Solutions, LLC, you confirm that +%# you are the copyright holder for those contributions and you grant +%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +%# royalty-free, perpetual, license to use, copy, create derivative +%# works based on those contributions, and sublicense and distribute +%# those contributions and any derivatives thereof. +%# +%# END BPS TAGGED BLOCK }}} +<%init> +my $file = $m->base_comp->source_file; + +if ($file =~ /\.(gif|png|jpe?g)$/i) { + my $relfile = $m->base_comp->path; + RT::Interface::Web->SendStaticFile( File => $file, RelativeFile => $relfile ); +} else { + RT::Interface::Web::StaticFileHeaders(); + $r->content_type('text/css') ; + $m->call_next(); + return(); +} +</%init> diff --git a/html/NoAuth/BugTracker/css/bugtracker.css b/html/NoAuth/BugTracker/css/bugtracker.css new file mode 100644 index 0000000..3aea179 --- /dev/null +++ b/html/NoAuth/BugTracker/css/bugtracker.css @@ -0,0 +1,12 @@ +#external_bugtracker { + width: 50%; + border: 1px solid #666; + background: #ffffaa url(<%RT->Config->Get('WebPath')%>/NoAuth/BugTracker/images/warn.png) 8px 15px no-repeat; + padding: 0px 10px 10px 60px; + margin: 20px auto; + min-height: 30px; + -webkit-box-shadow: inset 2px 2px 2px 2px #999; + box-shadow: inset 2px 2px 2px 2px #999; + -webkit-border-radius: 10px; + border-radius: 10px; +} diff --git a/html/NoAuth/BugTracker/images/dhandler b/html/NoAuth/BugTracker/images/dhandler new file mode 100644 index 0000000..6ec9dea --- /dev/null +++ b/html/NoAuth/BugTracker/images/dhandler @@ -0,0 +1,8 @@ +<%INIT> +use File::Basename; +my $arg = $m->dhandler_arg; +my $file = dirname($m->current_comp->source_file) . '/source/'. $arg; +RT::Interface::Web->SendStaticFile( File => $file ); + +$m->abort; +</%INIT> diff --git a/html/NoAuth/BugTracker/images/source/warn.png b/html/NoAuth/BugTracker/images/source/warn.png new file mode 100644 index 0000000..db0529d Binary files /dev/null and b/html/NoAuth/BugTracker/images/source/warn.png differ diff --git a/lib/RT/BugTracker.pm b/lib/RT/BugTracker.pm index 7ce1781..356232f 100644 --- a/lib/RT/BugTracker.pm +++ b/lib/RT/BugTracker.pm @@ -85,6 +85,44 @@ overriden. We currently in sync with RT 3.6.6. require RT::Queue; package RT::Queue; +sub DistributionBugtracker { + return (shift)->_AttributeBasedField( + DistributionBugtracker => @_ + ); +} + + +sub SetDistributionBugtracker { + my ($self, $value) = (shift, shift); + + my $bugtracker = {}; + my $update = 0; + + # Validate and set the mail to - we don't care if this is rt.cpan.org + if(defined($value->{mailto}) && !($value->{mailto} =~ m/rt\.cpan\.org/)) { + if(Email::Address->parse($value->{mailto})) { + $bugtracker->{mailto} = $value->{mailto}; + $update = 1; + } + } + + # Validate and set the web - we don't care if this is rt.cpan.org + if(defined($value->{web}) && !($value->{web} =~ m/rt\.cpan\.org/)) { + if(URI->new($value->{web})) { + $bugtracker->{web} = $value->{web}; + $update = 1; + } + } + + if($update) { + return $self->_SetAttributeBasedField( DistributionBugtracker => $bugtracker ); + } + + else { + return $self->_SetAttributeBasedField( DistributionBugtracker => undef ); + } +} + sub DistributionNotes { return (shift)->_AttributeBasedField( DistributionNotes => @_
Show quoted text
> at display time you're including the "|n" > flag when interpolating the web/mailto URLs. This tells Mason to not > apply it's default HTML escaping, which would allow third-party HTML > injection into rt.cpan.org. Removing the |n is sufficient for that.
Ah, guilty of cargo culting that one. Not familiar with Mason. New patch attached with the change requested. Ian.
Subject: rt-bugtracker-external.patch
diff --git a/html/Callbacks/BugTracker/Elements/Header/Head b/html/Callbacks/BugTracker/Elements/Header/Head new file mode 100644 index 0000000..8638838 --- /dev/null +++ b/html/Callbacks/BugTracker/Elements/Header/Head @@ -0,0 +1 @@ +<link rel="stylesheet" href="<%RT->Config->Get('WebPath')%>/NoAuth/BugTracker/css/bugtracker.css" type="text/css" media="all" /> diff --git a/html/Callbacks/BugTracker/Ticket/Create.html/FormStart b/html/Callbacks/BugTracker/Ticket/Create.html/FormStart index e8073a5..f68d289 100644 --- a/html/Callbacks/BugTracker/Ticket/Create.html/FormStart +++ b/html/Callbacks/BugTracker/Ticket/Create.html/FormStart @@ -2,5 +2,7 @@ $QueueObj </%ARGS> +<& /Dist/Elements/ShowBugtracker, Queue => $QueueObj &> + <& /Dist/Elements/ShowNotes, Queue => $QueueObj &> diff --git a/html/Callbacks/BugTracker/Ticket/Display.html/BeforeActionList b/html/Callbacks/BugTracker/Ticket/Display.html/BeforeActionList new file mode 100644 index 0000000..8b8d82f --- /dev/null +++ b/html/Callbacks/BugTracker/Ticket/Display.html/BeforeActionList @@ -0,0 +1,8 @@ +<%ARGS> +$Ticket +</%ARGS> + +<& /Dist/Elements/ShowBugtracker, Queue => $Ticket->QueueObj &> + +<& /Dist/Elements/ShowNotes, Queue => $Ticket->QueueObj &> + diff --git a/html/Callbacks/BugTracker/Ticket/Modify.html/BeforeActionList b/html/Callbacks/BugTracker/Ticket/Modify.html/BeforeActionList new file mode 100644 index 0000000..8b8d82f --- /dev/null +++ b/html/Callbacks/BugTracker/Ticket/Modify.html/BeforeActionList @@ -0,0 +1,8 @@ +<%ARGS> +$Ticket +</%ARGS> + +<& /Dist/Elements/ShowBugtracker, Queue => $Ticket->QueueObj &> + +<& /Dist/Elements/ShowNotes, Queue => $Ticket->QueueObj &> + diff --git a/html/Callbacks/BugTracker/Ticket/Update.html/BeforeActionList b/html/Callbacks/BugTracker/Ticket/Update.html/BeforeActionList new file mode 100644 index 0000000..51854cc --- /dev/null +++ b/html/Callbacks/BugTracker/Ticket/Update.html/BeforeActionList @@ -0,0 +1,6 @@ +<%ARGS> +$Ticket +</%ARGS> + +<& /Dist/Elements/ShowBugtracker, Queue => $Ticket->QueueObj &> + diff --git a/html/Dist/Display.html b/html/Dist/Display.html index 0e4c329..9107dc9 100755 --- a/html/Dist/Display.html +++ b/html/Dist/Display.html @@ -57,6 +57,8 @@ Title => $title, &> +<& /Dist/Elements/ShowBugtracker, Queue => $QueueObj &> + <& /Dist/Elements/ShowNotes, Queue => $QueueObj &> <& /Dist/Elements/ShowMaintainers, Queue => $QueueObj &> diff --git a/html/Dist/Elements/ShowBugtracker b/html/Dist/Elements/ShowBugtracker new file mode 100644 index 0000000..1c9a434 --- /dev/null +++ b/html/Dist/Elements/ShowBugtracker @@ -0,0 +1,24 @@ +% if ( defined $bugtracker ) { +<div id="external_bugtracker"> +<h3><% loc("Alternative bug tracker") %></h3> +% +% if ( defined $bugtracker->{mailto} ) { +<p> +<div>Please email the <a href="mailto:<% $bugtracker->{mailto} %>">alternative bug tracker</a> to report your issue.</div> +</p> +% } +% +% if ( defined $bugtracker->{web} ) { +<p> +<div>Please visit the <a href="<% $bugtracker->{web} %>">alternative bug tracker</a> to report your issue.</div> +</p> +% } +</div> +% } +% +<%ARGS> +$Queue +</%ARGS> +<%INIT> +my $bugtracker = $Queue->DistributionBugtracker; +</%INIT> diff --git a/html/NoAuth/BugTracker/autohandler b/html/NoAuth/BugTracker/autohandler new file mode 100644 index 0000000..dabe704 --- /dev/null +++ b/html/NoAuth/BugTracker/autohandler @@ -0,0 +1,60 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +%# <sales@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# LICENSE: +%# +%# This work is made available to you under the terms of Version 2 of +%# the GNU General Public License. A copy of that license should have +%# been provided with this software, but in any event can be snarfed +%# from www.gnu.org. +%# +%# This work 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. See the GNU +%# General Public License for more details. +%# +%# You should have received a copy of the GNU General Public License +%# along with this program; if not, write to the Free Software +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. +%# +%# +%# CONTRIBUTION SUBMISSION POLICY: +%# +%# (The following paragraph is not intended to limit the rights granted +%# to you to modify and distribute this software under the terms of +%# the GNU General Public License and is only of importance to you if +%# you choose to contribute your changes and enhancements to the +%# community by submitting them to Best Practical Solutions, LLC.) +%# +%# By intentionally submitting any modifications, corrections or +%# derivatives to this work, or any other work intended for use with +%# Request Tracker, to Best Practical Solutions, LLC, you confirm that +%# you are the copyright holder for those contributions and you grant +%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +%# royalty-free, perpetual, license to use, copy, create derivative +%# works based on those contributions, and sublicense and distribute +%# those contributions and any derivatives thereof. +%# +%# END BPS TAGGED BLOCK }}} +<%init> +my $file = $m->base_comp->source_file; + +if ($file =~ /\.(gif|png|jpe?g)$/i) { + my $relfile = $m->base_comp->path; + RT::Interface::Web->SendStaticFile( File => $file, RelativeFile => $relfile ); +} else { + RT::Interface::Web::StaticFileHeaders(); + $r->content_type('text/css') ; + $m->call_next(); + return(); +} +</%init> diff --git a/html/NoAuth/BugTracker/css/bugtracker.css b/html/NoAuth/BugTracker/css/bugtracker.css new file mode 100644 index 0000000..3aea179 --- /dev/null +++ b/html/NoAuth/BugTracker/css/bugtracker.css @@ -0,0 +1,12 @@ +#external_bugtracker { + width: 50%; + border: 1px solid #666; + background: #ffffaa url(<%RT->Config->Get('WebPath')%>/NoAuth/BugTracker/images/warn.png) 8px 15px no-repeat; + padding: 0px 10px 10px 60px; + margin: 20px auto; + min-height: 30px; + -webkit-box-shadow: inset 2px 2px 2px 2px #999; + box-shadow: inset 2px 2px 2px 2px #999; + -webkit-border-radius: 10px; + border-radius: 10px; +} diff --git a/html/NoAuth/BugTracker/images/dhandler b/html/NoAuth/BugTracker/images/dhandler new file mode 100644 index 0000000..6ec9dea --- /dev/null +++ b/html/NoAuth/BugTracker/images/dhandler @@ -0,0 +1,8 @@ +<%INIT> +use File::Basename; +my $arg = $m->dhandler_arg; +my $file = dirname($m->current_comp->source_file) . '/source/'. $arg; +RT::Interface::Web->SendStaticFile( File => $file ); + +$m->abort; +</%INIT> diff --git a/html/NoAuth/BugTracker/images/source/warn.png b/html/NoAuth/BugTracker/images/source/warn.png new file mode 100644 index 0000000..db0529d Binary files /dev/null and b/html/NoAuth/BugTracker/images/source/warn.png differ diff --git a/lib/RT/BugTracker.pm b/lib/RT/BugTracker.pm index 7ce1781..356232f 100644 --- a/lib/RT/BugTracker.pm +++ b/lib/RT/BugTracker.pm @@ -85,6 +85,44 @@ overriden. We currently in sync with RT 3.6.6. require RT::Queue; package RT::Queue; +sub DistributionBugtracker { + return (shift)->_AttributeBasedField( + DistributionBugtracker => @_ + ); +} + + +sub SetDistributionBugtracker { + my ($self, $value) = (shift, shift); + + my $bugtracker = {}; + my $update = 0; + + # Validate and set the mail to - we don't care if this is rt.cpan.org + if(defined($value->{mailto}) && !($value->{mailto} =~ m/rt\.cpan\.org/)) { + if(Email::Address->parse($value->{mailto})) { + $bugtracker->{mailto} = $value->{mailto}; + $update = 1; + } + } + + # Validate and set the web - we don't care if this is rt.cpan.org + if(defined($value->{web}) && !($value->{web} =~ m/rt\.cpan\.org/)) { + if(URI->new($value->{web})) { + $bugtracker->{web} = $value->{web}; + $update = 1; + } + } + + if($update) { + return $self->_SetAttributeBasedField( DistributionBugtracker => $bugtracker ); + } + + else { + return $self->_SetAttributeBasedField( DistributionBugtracker => undef ); + } +} + sub DistributionNotes { return (shift)->_AttributeBasedField( DistributionNotes => @_
Whoops. The other one is in this module too. Show quoted text
> However, beyond just checking if .web parses with URI, we also need to > check that it's only a http or https URI. Otherwise you can use other > schemes with security problems for a website (data:, javascript:).
Added scheme validation code. Seems like supported_schemes should be defined somewhere else but not sure where. Anyways, new one attached. Cheers! Ian.
Subject: rt-bugtracker-external.patch
diff --git a/html/Callbacks/BugTracker/Elements/Header/Head b/html/Callbacks/BugTracker/Elements/Header/Head new file mode 100644 index 0000000..8638838 --- /dev/null +++ b/html/Callbacks/BugTracker/Elements/Header/Head @@ -0,0 +1 @@ +<link rel="stylesheet" href="<%RT->Config->Get('WebPath')%>/NoAuth/BugTracker/css/bugtracker.css" type="text/css" media="all" /> diff --git a/html/Callbacks/BugTracker/Ticket/Create.html/FormStart b/html/Callbacks/BugTracker/Ticket/Create.html/FormStart index e8073a5..f68d289 100644 --- a/html/Callbacks/BugTracker/Ticket/Create.html/FormStart +++ b/html/Callbacks/BugTracker/Ticket/Create.html/FormStart @@ -2,5 +2,7 @@ $QueueObj </%ARGS> +<& /Dist/Elements/ShowBugtracker, Queue => $QueueObj &> + <& /Dist/Elements/ShowNotes, Queue => $QueueObj &> diff --git a/html/Callbacks/BugTracker/Ticket/Display.html/BeforeActionList b/html/Callbacks/BugTracker/Ticket/Display.html/BeforeActionList new file mode 100644 index 0000000..8b8d82f --- /dev/null +++ b/html/Callbacks/BugTracker/Ticket/Display.html/BeforeActionList @@ -0,0 +1,8 @@ +<%ARGS> +$Ticket +</%ARGS> + +<& /Dist/Elements/ShowBugtracker, Queue => $Ticket->QueueObj &> + +<& /Dist/Elements/ShowNotes, Queue => $Ticket->QueueObj &> + diff --git a/html/Callbacks/BugTracker/Ticket/Modify.html/BeforeActionList b/html/Callbacks/BugTracker/Ticket/Modify.html/BeforeActionList new file mode 100644 index 0000000..8b8d82f --- /dev/null +++ b/html/Callbacks/BugTracker/Ticket/Modify.html/BeforeActionList @@ -0,0 +1,8 @@ +<%ARGS> +$Ticket +</%ARGS> + +<& /Dist/Elements/ShowBugtracker, Queue => $Ticket->QueueObj &> + +<& /Dist/Elements/ShowNotes, Queue => $Ticket->QueueObj &> + diff --git a/html/Callbacks/BugTracker/Ticket/Update.html/BeforeActionList b/html/Callbacks/BugTracker/Ticket/Update.html/BeforeActionList new file mode 100644 index 0000000..51854cc --- /dev/null +++ b/html/Callbacks/BugTracker/Ticket/Update.html/BeforeActionList @@ -0,0 +1,6 @@ +<%ARGS> +$Ticket +</%ARGS> + +<& /Dist/Elements/ShowBugtracker, Queue => $Ticket->QueueObj &> + diff --git a/html/Dist/Display.html b/html/Dist/Display.html index 0e4c329..9107dc9 100755 --- a/html/Dist/Display.html +++ b/html/Dist/Display.html @@ -57,6 +57,8 @@ Title => $title, &> +<& /Dist/Elements/ShowBugtracker, Queue => $QueueObj &> + <& /Dist/Elements/ShowNotes, Queue => $QueueObj &> <& /Dist/Elements/ShowMaintainers, Queue => $QueueObj &> diff --git a/html/Dist/Elements/ShowBugtracker b/html/Dist/Elements/ShowBugtracker new file mode 100644 index 0000000..1c9a434 --- /dev/null +++ b/html/Dist/Elements/ShowBugtracker @@ -0,0 +1,24 @@ +% if ( defined $bugtracker ) { +<div id="external_bugtracker"> +<h3><% loc("Alternative bug tracker") %></h3> +% +% if ( defined $bugtracker->{mailto} ) { +<p> +<div>Please email the <a href="mailto:<% $bugtracker->{mailto} %>">alternative bug tracker</a> to report your issue.</div> +</p> +% } +% +% if ( defined $bugtracker->{web} ) { +<p> +<div>Please visit the <a href="<% $bugtracker->{web} %>">alternative bug tracker</a> to report your issue.</div> +</p> +% } +</div> +% } +% +<%ARGS> +$Queue +</%ARGS> +<%INIT> +my $bugtracker = $Queue->DistributionBugtracker; +</%INIT> diff --git a/html/NoAuth/BugTracker/autohandler b/html/NoAuth/BugTracker/autohandler new file mode 100644 index 0000000..dabe704 --- /dev/null +++ b/html/NoAuth/BugTracker/autohandler @@ -0,0 +1,60 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +%# <sales@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# LICENSE: +%# +%# This work is made available to you under the terms of Version 2 of +%# the GNU General Public License. A copy of that license should have +%# been provided with this software, but in any event can be snarfed +%# from www.gnu.org. +%# +%# This work 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. See the GNU +%# General Public License for more details. +%# +%# You should have received a copy of the GNU General Public License +%# along with this program; if not, write to the Free Software +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. +%# +%# +%# CONTRIBUTION SUBMISSION POLICY: +%# +%# (The following paragraph is not intended to limit the rights granted +%# to you to modify and distribute this software under the terms of +%# the GNU General Public License and is only of importance to you if +%# you choose to contribute your changes and enhancements to the +%# community by submitting them to Best Practical Solutions, LLC.) +%# +%# By intentionally submitting any modifications, corrections or +%# derivatives to this work, or any other work intended for use with +%# Request Tracker, to Best Practical Solutions, LLC, you confirm that +%# you are the copyright holder for those contributions and you grant +%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +%# royalty-free, perpetual, license to use, copy, create derivative +%# works based on those contributions, and sublicense and distribute +%# those contributions and any derivatives thereof. +%# +%# END BPS TAGGED BLOCK }}} +<%init> +my $file = $m->base_comp->source_file; + +if ($file =~ /\.(gif|png|jpe?g)$/i) { + my $relfile = $m->base_comp->path; + RT::Interface::Web->SendStaticFile( File => $file, RelativeFile => $relfile ); +} else { + RT::Interface::Web::StaticFileHeaders(); + $r->content_type('text/css') ; + $m->call_next(); + return(); +} +</%init> diff --git a/html/NoAuth/BugTracker/css/bugtracker.css b/html/NoAuth/BugTracker/css/bugtracker.css new file mode 100644 index 0000000..3aea179 --- /dev/null +++ b/html/NoAuth/BugTracker/css/bugtracker.css @@ -0,0 +1,12 @@ +#external_bugtracker { + width: 50%; + border: 1px solid #666; + background: #ffffaa url(<%RT->Config->Get('WebPath')%>/NoAuth/BugTracker/images/warn.png) 8px 15px no-repeat; + padding: 0px 10px 10px 60px; + margin: 20px auto; + min-height: 30px; + -webkit-box-shadow: inset 2px 2px 2px 2px #999; + box-shadow: inset 2px 2px 2px 2px #999; + -webkit-border-radius: 10px; + border-radius: 10px; +} diff --git a/html/NoAuth/BugTracker/images/dhandler b/html/NoAuth/BugTracker/images/dhandler new file mode 100644 index 0000000..6ec9dea --- /dev/null +++ b/html/NoAuth/BugTracker/images/dhandler @@ -0,0 +1,8 @@ +<%INIT> +use File::Basename; +my $arg = $m->dhandler_arg; +my $file = dirname($m->current_comp->source_file) . '/source/'. $arg; +RT::Interface::Web->SendStaticFile( File => $file ); + +$m->abort; +</%INIT> diff --git a/html/NoAuth/BugTracker/images/source/warn.png b/html/NoAuth/BugTracker/images/source/warn.png new file mode 100644 index 0000000..db0529d Binary files /dev/null and b/html/NoAuth/BugTracker/images/source/warn.png differ diff --git a/lib/RT/BugTracker.pm b/lib/RT/BugTracker.pm index 7ce1781..a7ec89e 100644 --- a/lib/RT/BugTracker.pm +++ b/lib/RT/BugTracker.pm @@ -85,6 +85,67 @@ overriden. We currently in sync with RT 3.6.6. require RT::Queue; package RT::Queue; +sub DistributionBugtracker { + return (shift)->_AttributeBasedField( + DistributionBugtracker => @_ + ); +} + + +sub SetDistributionBugtracker { + my ($self, $value) = (shift, shift); + + my $bugtracker = {}; + my $update = 0; + + # Validate and set the mail to - we don't care if this is rt.cpan.org + if(defined($value->{mailto}) && !($value->{mailto} =~ m/rt\.cpan\.org/)) { + if(Email::Address->parse($value->{mailto})) { + $bugtracker->{mailto} = $value->{mailto}; + $update = 1; + } + } + + # Hash of supported URI schemes for validation + my $supported_schemes = { + http => 1, + https => 1, + }; + + # Validate and set the web - we don't care if this is rt.cpan.org + if(defined($value->{web}) && !($value->{web} =~ m/rt\.cpan\.org/)) { + if(my $uri = URI->new($value->{web})) { + + # Check that this is a supported scheme + if(defined($supported_schemes->{$uri->scheme()})) { + $bugtracker->{web} = $value->{web}; + $update = 1; + } + + else { + my $error_msg = "Failed to set external bugtracker website"; + $error_msg .= " on distribution (" . $self->Name() . ")."; + $error_msg .= " Unsupported scheme (" . $uri->scheme() . ")."; + $RT::Logger->error($error_msg); + } + } + else { + my $error_msg = "Failed to set external bugtracker website"; + $error_msg .= " on distribution (" . $self->Name() . ")"; + $error_msg .= " Unable to parse (" . $value->{web} . ") with URI."; + $RT::Logger->error($error_msg); + } + } + + if($update) { + return $self->_SetAttributeBasedField( DistributionBugtracker => $bugtracker ); + } + + else { + return $self->_SetAttributeBasedField( DistributionBugtracker => undef ); + } +} + sub DistributionNotes { return (shift)->_AttributeBasedField( DistributionNotes => @_
Resolving. These branches are merged into the rt4 branch, which will be deployed on rt.cpan.org during the RT upgrade. The RT upgrade is currently in beta testing. Thanks for your work, Ian!