summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorByron Jones <bjones@mozilla.com>2013-08-14 08:59:17 +0200
committerByron Jones <bjones@mozilla.com>2013-08-14 08:59:17 +0200
commit99719077aeeac9b6a449b657893e4ee29511132c (patch)
treef714060a120614d8673649d755e66642eb6f3c0a
parent14102c9968496f9341994ea92b24c9490331a2d2 (diff)
downloadbugzilla-99719077aeeac9b6a449b657893e4ee29511132c.tar.gz
bugzilla-99719077aeeac9b6a449b657893e4ee29511132c.tar.xz
Bug 903955: add gravatar support
-rw-r--r--extensions/Gravatar/Config.pm16
-rw-r--r--extensions/Gravatar/Extension.pm36
-rw-r--r--extensions/Gravatar/template/en/default/hook/bug/comments-user-image.html.tmpl11
-rw-r--r--extensions/Gravatar/template/en/default/hook/bug/show-header-end.html.tmpl11
-rw-r--r--extensions/Gravatar/template/en/default/hook/global/setting-descs-settings.none.tmpl11
-rw-r--r--extensions/InlineHistory/template/en/default/hook/bug/comments-aftercomments.html.tmpl5
-rw-r--r--template/en/default/bug/comments.html.tmpl2
7 files changed, 92 insertions, 0 deletions
diff --git a/extensions/Gravatar/Config.pm b/extensions/Gravatar/Config.pm
new file mode 100644
index 000000000..e15a41ee8
--- /dev/null
+++ b/extensions/Gravatar/Config.pm
@@ -0,0 +1,16 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
+
+package Bugzilla::Extension::Gravatar;
+
+use strict;
+
+use constant NAME => 'Gravatar';
+use constant REQUIRED_MODULES => [];
+use constant OPTIONAL_MODULES => [];
+
+__PACKAGE__->NAME;
diff --git a/extensions/Gravatar/Extension.pm b/extensions/Gravatar/Extension.pm
new file mode 100644
index 000000000..dc6ae5aaf
--- /dev/null
+++ b/extensions/Gravatar/Extension.pm
@@ -0,0 +1,36 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
+
+package Bugzilla::Extension::Gravatar;
+
+use strict;
+use warnings;
+
+use base qw(Bugzilla::Extension);
+
+use Bugzilla::User::Setting;
+use Digest::MD5 qw(md5_hex);
+
+BEGIN {
+ *Bugzilla::User::gravatar = \&_user_gravatar;
+}
+
+sub _user_gravatar {
+ my ($self) = @_;
+ if (!$self->{gravatar}) {
+ (my $email = $self->email) =~ s/\+(.*?)\@/@/;
+ $self->{gravatar} = 'https://secure.gravatar.com/avatar/' . md5_hex($email) . "?size=32&d=mm";
+ }
+ return $self->{gravatar};
+}
+
+sub install_before_final_checks {
+ my ($self, $args) = @_;
+ add_setting('show_gravatars', ['On', 'Off'], 'Off');
+}
+
+__PACKAGE__->NAME;
diff --git a/extensions/Gravatar/template/en/default/hook/bug/comments-user-image.html.tmpl b/extensions/Gravatar/template/en/default/hook/bug/comments-user-image.html.tmpl
new file mode 100644
index 000000000..14adfd055
--- /dev/null
+++ b/extensions/Gravatar/template/en/default/hook/bug/comments-user-image.html.tmpl
@@ -0,0 +1,11 @@
+[%# This Source Code Form is subject to the terms of the Mozilla Public
+ # License, v. 2.0. If a copy of the MPL was not distributed with this
+ # file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ #
+ # This Source Code Form is "Incompatible With Secondary Licenses", as
+ # defined by the Mozilla Public License, v. 2.0.
+ #%]
+
+[% IF user.settings.show_gravatars.value == 'On' %]
+ <img align="middle" src="[% who.gravatar FILTER none %]" width="32" height="32">
+[% END %]
diff --git a/extensions/Gravatar/template/en/default/hook/bug/show-header-end.html.tmpl b/extensions/Gravatar/template/en/default/hook/bug/show-header-end.html.tmpl
new file mode 100644
index 000000000..0f1130976
--- /dev/null
+++ b/extensions/Gravatar/template/en/default/hook/bug/show-header-end.html.tmpl
@@ -0,0 +1,11 @@
+[%# This Source Code Form is subject to the terms of the Mozilla Public
+ # License, v. 2.0. If a copy of the MPL was not distributed with this
+ # file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ #
+ # This Source Code Form is "Incompatible With Secondary Licenses", as
+ # defined by the Mozilla Public License, v. 2.0.
+ #%]
+
+[% IF user.settings.show_gravatars.value == 'On' %]
+ [% bodyclasses.push('bz_gravatar') %]
+[% END %]
diff --git a/extensions/Gravatar/template/en/default/hook/global/setting-descs-settings.none.tmpl b/extensions/Gravatar/template/en/default/hook/global/setting-descs-settings.none.tmpl
new file mode 100644
index 000000000..482503990
--- /dev/null
+++ b/extensions/Gravatar/template/en/default/hook/global/setting-descs-settings.none.tmpl
@@ -0,0 +1,11 @@
+[%# This Source Code Form is subject to the terms of the Mozilla Public
+ # License, v. 2.0. If a copy of the MPL was not distributed with this
+ # file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ #
+ # This Source Code Form is "Incompatible With Secondary Licenses", as
+ # defined by the Mozilla Public License, v. 2.0.
+ #%]
+
+[%
+ setting_descs.show_gravatars = "Show gravatar images when viewing $terms.bugs"
+%]
diff --git a/extensions/InlineHistory/template/en/default/hook/bug/comments-aftercomments.html.tmpl b/extensions/InlineHistory/template/en/default/hook/bug/comments-aftercomments.html.tmpl
index 1c47fd21c..6debea594 100644
--- a/extensions/InlineHistory/template/en/default/hook/bug/comments-aftercomments.html.tmpl
+++ b/extensions/InlineHistory/template/en/default/hook/bug/comments-aftercomments.html.tmpl
@@ -102,12 +102,17 @@
[% END %]
[% END %]
+ var user_image = '
+ [%~ who = operation.who %]
+ [% Hook.process('user-image', 'bug/comments.html.tmpl') FILTER js %]';
+
var item = new Array(7);
item[0] = '[% changer_login FILTER js %]';
item[1] = '[% change_date FILTER js %]';
item[2] = html;
item[3] = '<div class="bz_comment_head">'
+ '<span class="bz_comment_user">'
+ + user_image
+ '[% user_cache.$changer_id FILTER js %]'
+ '</span>'
+ '<span class="bz_comment_time"> ' + item[1] + ' </span>'
diff --git a/template/en/default/bug/comments.html.tmpl b/template/en/default/bug/comments.html.tmpl
index a876fb081..773e6a485 100644
--- a/template/en/default/bug/comments.html.tmpl
+++ b/template/en/default/bug/comments.html.tmpl
@@ -203,6 +203,8 @@
</span>
<span class="bz_comment_user">
+ [% who = comment.author %]
+ [% Hook.process('user-image', 'bug/comments.html.tmpl') %]
[%# No need to recreate the exact same template if we already have it. %]
[% commenter_id = comment.author.id %]
[% UNLESS user_cache.$commenter_id %]