[bugzilla-gnome-org-extensions] 4.4 migration: Add initial Config, Extension and Ops modules
- From: Krzesimir Nowak <krnowak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [bugzilla-gnome-org-extensions] 4.4 migration: Add initial Config, Extension and Ops modules
- Date: Thu, 20 Nov 2014 22:25:01 +0000 (UTC)
commit 1035a1a739c60d5602ea83c95f2a5c709715cf34
Author: Krzesimir Nowak <qdlacz gmail com>
Date: Mon Nov 17 22:34:20 2014 +0100
4.4 migration: Add initial Config, Extension and Ops modules
Config.pm | 33 ++++++++++++++++++++
Extension.pm | 78 +++++++++++++++++++++++++++++++++++++++++++++++
lib/Ops.pm | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 206 insertions(+), 0 deletions(-)
---
diff --git a/Config.pm b/Config.pm
new file mode 100644
index 0000000..6f72f37
--- /dev/null
+++ b/Config.pm
@@ -0,0 +1,33 @@
+# The contents of this file are subject to the Mozilla Public
+# License Version 1.1 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS
+# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# rights and limitations under the License.
+#
+# The Original Code is the Splinter Bugzilla Extension.
+#
+# The Initial Developer of the Original Code is Red Hat, Inc.
+# Portions created by Red Hat, Inc. are Copyright (C) 2009
+# Red Hat Inc. All Rights Reserved.
+#
+# Contributor(s):
+# Owen Taylor <otaylor fishsoup net>
+# Krzesimir Nowak <qdlacz gmail com>
+
+package Bugzilla::Extension::Splinter;
+use strict;
+use warnings;
+
+use constant NAME => 'Splinter';
+
+use constant REQUIRED_MODULES => [
+];
+
+use constant OPTIONAL_MODULES => [
+];
+
+__PACKAGE__->NAME;
diff --git a/Extension.pm b/Extension.pm
new file mode 100644
index 0000000..1e2bcc9
--- /dev/null
+++ b/Extension.pm
@@ -0,0 +1,78 @@
+# The contents of this file are subject to the Mozilla Public
+# License Version 1.1 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS
+# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# rights and limitations under the License.
+#
+# The Original Code is the Splinter Bugzilla Extension.
+#
+# The Initial Developer of the Original Code is Red Hat, Inc.
+# Portions created by Red Hat, Inc. are Copyright (C) 2009
+# Red Hat Inc. All Rights Reserved.
+#
+# Contributor(s):
+# Owen Taylor <otaylor fishsoup net>
+# Bradley Baetz <bbaetz acm org>
+# Krzesimir Nowak <qdlacz gmail com>
+
+package Bugzilla::Extension::Splinter;
+use strict;
+use warnings;
+use base qw(Bugzilla::Extension);
+
+# This code for this is in ./extensions/Splinter/lib/Util.pm
+use Bugzilla::Extension::Splinter::Ops;
+use Bugzilla::Extension::Splinter::SplinterUtil;
+
+our $VERSION = '0.01';
+
+# See the documentation of Bugzilla::Hook ("perldoc Bugzilla::Hook"
+# in the bugzilla directory) for a list of all available hooks.
+sub bug_format_comment {
+ my ($self, $args) = @_;
+ my $bug = $args->{'bug'};
+ my $regexes = $args->{'regexes'};
+ my $text = $args->{'text'};
+
+ format_the_comment($bug, $regexes, $text);
+}
+
+sub config_add_panels {
+ my ($self, $args) = @_;
+ my $modules = $args->{'panel_modules'};
+
+ add_panel($modules);
+}
+
+sub mailer_before_send {
+ my ($self, $args) = @_;
+ my $email = $args->{'email'};
+
+ # Post-process bug mail to add review links to bug mail.
+ # It would be nice to be able to hook in earlier in the
+ # process when the email body is being formatted in the
+ # style of the bug-format_comment link for HTML but this
+ # is the only hook available as of Bugzilla-4.4.
+ add_review_links_to_email($email);
+}
+
+sub page_before_template {
+ my ($self, $args) = @_;
+ my $page = $args->{'page_id'};
+ my $vars = $args->{'vars'};
+
+ maybe_get_statuses($page, $vars);
+}
+
+sub webservice {
+ my ($self, $args) = @_;
+ my $dispatches = $args->{'dispatch'};
+
+ add_dispatch($dispatches);
+}
+
+__PACKAGE__->NAME;
diff --git a/lib/Ops.pm b/lib/Ops.pm
new file mode 100644
index 0000000..7630c06
--- /dev/null
+++ b/lib/Ops.pm
@@ -0,0 +1,95 @@
+# The contents of this file are subject to the Mozilla Public
+# License Version 1.1 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS
+# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# rights and limitations under the License.
+#
+# The Original Code is the Splinter Bugzilla Extension.
+#
+# The Initial Developer of the Original Code is Red Hat, Inc.
+# Portions created by Red Hat, Inc. are Copyright (C) 2009
+# Red Hat Inc. All Rights Reserved.
+#
+# Contributor(s):
+# Owen Taylor <otaylor fishsoup net>
+# Bradley Baetz <bbaetz acm org>
+# Krzesimir Nowak <qdlacz gmail com>
+
+package Bugzilla::Extension::Splinter::Ops;
+use strict;
+use warnings;
+
+use base qw(Exporter);
+
+our @EXPORT = qw(
+ format_the_comment
+ add_panel
+ maybe_get_statuses
+ add_dispatch
+);
+
+use Bugzilla::Extension::Splinter::SplinterUtil;
+
+sub format_the_comment {
+ my ($bug, $regexes, $text) = @_;
+ # TODO: This is probably used in more places. Avoid redundancy.
+ my $REVIEW_RE = qr/Review\s+of\s+attachment\s+(\d+)\s*:/;
+
+ # Add [review] link to the end of "Created an attachment" comments
+ #
+ # We need to work around the way that the hook works, which is
+ # intended to avoid overlapping matches, since we *want* an
+ # overlapping match here (the normal handling of "Created an
+ # attachment"), so we add in dummy text and then replace in the
+ # regular expression we return from the hook.
+ ${$text} =~ s~((?:^Created\ an\ |\b)attachment\s*\(id=(\d+)\)(\s\[edit\])?)
+ ~(push(@$regexes, { match => qr/__REVIEW__$2/,
+ replace => get_review_link($bug, "$2", "[review]") })) &&
+ (attachment_id_is_patch($2) ? "$1 __REVIEW__$2" : $1)
+ ~egmx;
+
+ # And linkify "Review of attachment", this is less of a workaround since
+ # there is no issue with overlap; note that there is an assumption that
+ # there is only one match in the text we are linkifying, since they all
+ # get the same link.
+ if (${$text} =~ $REVIEW_RE) {
+ my $review_link = get_review_link($bug, $1, "Review");
+ my $attach_link = Bugzilla::Template::get_attachment_link($1, "attachment $1");
+
+ push(@$regexes, { 'match' => $REVIEW_RE,
+ 'replace' => "$review_link of $attach_link:"});
+ }
+}
+
+sub add_panel {
+ my ($modules) = @_;
+
+ $modules->{'Splinter'} = "Bugzilla::Extension::Splinter::Params";
+}
+
+sub maybe_get_statuses {
+ my ($page, $vars) = @_;
+
+ if ($page eq 'splinter.html') {
+ # We do this in a way that is safe if the Bugzilla instance doesn't
+ # have an attachments.status field (which is a bugzilla.gnome.org
+ # addition)
+ my $field_object = Bugzilla::Field->new({ name => 'attachments.status' });
+ my @statuses = ();
+
+ if ($field_object) {
+ @statuses = map { $_->name } @{ $field_object->legal_values };
+ }
+ $vars->{'attachment_statuses'} = \ statuses;
+ }
+}
+
+sub add_dispatch {
+ my ($dispatches) = @_;
+
+ $dispatches->{'Splinter'} = "Bugzilla::Extension::Splinter::WebService";
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]