summaryrefslogtreecommitdiffstats
path: root/extensions/Gravatar
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/Gravatar')
-rw-r--r--extensions/Gravatar/Config.pm16
-rw-r--r--extensions/Gravatar/Extension.pm43
-rw-r--r--extensions/Gravatar/template/en/default/hook/bug/comments-user-image.html.tmpl19
-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.tmpl12
-rw-r--r--extensions/Gravatar/web/default.jpgbin0 -> 1163 bytes
6 files changed, 101 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..050a0c27d
--- /dev/null
+++ b/extensions/Gravatar/Extension.pm
@@ -0,0 +1,43 @@
+# 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);
+
+use constant DEFAULT_URL => 'extensions/Gravatar/web/default.jpg';
+
+BEGIN {
+ *Bugzilla::User::gravatar = \&_user_gravatar;
+}
+
+sub _user_gravatar {
+ my ($self, $size) = @_;
+ if ($self->setting('show_my_gravatar') eq 'Off') {
+ return DEFAULT_URL;
+ }
+ if (!$self->{gravatar}) {
+ $self->{gravatar} = 'https://secure.gravatar.com/avatar/' .
+ md5_hex(lc($self->email)) . '?d=mm';
+ }
+ $size ||= 64;
+ return $self->{gravatar} . "&size=$size";
+}
+
+sub install_before_final_checks {
+ my ($self, $args) = @_;
+ add_setting('show_gravatars', ['On', 'Off'], 'Off');
+ add_setting('show_my_gravatar', ['On', 'Off'], 'On');
+}
+
+__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..66714748b
--- /dev/null
+++ b/extensions/Gravatar/template/en/default/hook/bug/comments-user-image.html.tmpl
@@ -0,0 +1,19 @@
+[%# 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' %]
+ [% IF who.last_activity_ts %]
+ [% IF user.id %]
+ <a href="user_profile?login=[% who.login FILTER uri %]">
+ [% ELSE %]
+ <a href="user_profile?user_id=[% who.id FILTER uri %]">
+ [% END %]
+ [% END %]
+ <img align="middle" src="[% who.gravatar FILTER none %]" width="32" height="32" border="0">
+ [% "</a>" IF who.last_activity_ts %]
+[% 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..697cfef99
--- /dev/null
+++ b/extensions/Gravatar/template/en/default/hook/global/setting-descs-settings.none.tmpl
@@ -0,0 +1,12 @@
+[%# 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"
+ setting_descs.show_my_gravatar = "Show my gravatar image to other users"
+%]
diff --git a/extensions/Gravatar/web/default.jpg b/extensions/Gravatar/web/default.jpg
new file mode 100644
index 000000000..98dc1fa87
--- /dev/null
+++ b/extensions/Gravatar/web/default.jpg
Binary files differ