From eb21c917e3b651629e3740d541b1e41795527563 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Wed, 10 Sep 2014 15:38:11 +0400 Subject: [PATCH] Gravatar support. Avatars may be disabled via params or user preference. FIXME: Remove hardcoded Mozilla skin name (used to choose avatar position) --- Bugzilla/Config/Integration.pm | 6 + Bugzilla/Install.pm | 4 +- Bugzilla/Language/en.pm | 1 + Bugzilla/User.pm | 14 ++ images/noavatar40.png | Bin 0 -> 1007 bytes skins/contrib/Mozilla/global.css | 1 - skins/standard/comments.css | 1 + .../admin/params/integration.html.tmpl | 6 +- template/en/default/bug/comments.html.tmpl | 183 ++++++++++-------- 9 files changed, 132 insertions(+), 84 deletions(-) create mode 100644 images/noavatar40.png diff --git a/Bugzilla/Config/Integration.pm b/Bugzilla/Config/Integration.pm index d19a9b98b..7ded78412 100644 --- a/Bugzilla/Config/Integration.pm +++ b/Bugzilla/Config/Integration.pm @@ -11,6 +11,12 @@ our $sortkey = 910; sub get_param_list { return ( + { + name => 'gravatar_url', + type => 't', + default => 'http://www.gravatar.com/avatar/$MD5', + }, + { name => 'wiki_url', type => 't', diff --git a/Bugzilla/Install.pm b/Bugzilla/Install.pm index 87286c875..2635253da 100644 --- a/Bugzilla/Install.pm +++ b/Bugzilla/Install.pm @@ -77,11 +77,13 @@ use constant SETTINGS => { # CustIS Bug 87696 - Setting to change comments which are allowed to be marked as collapsed by default ("worktime-only") showhide_comments => { options => ['none', 'worktime', 'all'], default => 'worktime' }, # CustIS Bug 125374 - Select whether to show comments in full page width - comment_width => { options => ['off', 'on'], default => 'off' }, + comment_width => { options => ['off', 'on'], default => 'on' }, # CustIS Bug 138596 - Choose whether to hide long comments by default preview_long_comments => { options => ['off', 'on'], default => 'off' }, # Clear all flag requests when changing bug status to 'closed_bug_status' parameter clear_requests_on_close => { options => ['off', 'on'], default => 'off' }, + # Select whether to show avatar + show_gravatars => { options => ['off', 'on'], default => 'on' }, }; # Initial system groups. diff --git a/Bugzilla/Language/en.pm b/Bugzilla/Language/en.pm index fba6c7182..276ec7a04 100644 --- a/Bugzilla/Language/en.pm +++ b/Bugzilla/Language/en.pm @@ -210,6 +210,7 @@ $Bugzilla::messages->{en} = { 'comment_width' => 'Show comments in the full screen width', 'preview_long_comments' => 'Fold long comments', 'clear_requests_on_close' => 'Clear flag requests when closing bugs', + 'show_gravatars' => 'Show avatar images (Gravatars)', }, system_groups => { admin => 'Administrator group. Usually allows to access all administrative functions.', diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm index 9853d3ae1..08c520aec 100644 --- a/Bugzilla/User.pm +++ b/Bugzilla/User.pm @@ -49,6 +49,7 @@ use Bugzilla::Field; use Bugzilla::Group; use Bugzilla::Status; +use Digest::MD5 qw(md5_hex); use POSIX; use DateTime::TimeZone; use Scalar::Util qw(blessed); @@ -316,6 +317,19 @@ sub cryptpassword return $pw; } +sub gravatar_url +{ + my ($self, $params) = @_; + my $url = Bugzilla->params->{gravatar_url} or return ''; + $url =~ s/\$MD5/md5_hex(lc $self->email)/e or $url =~ s/\$EMAIL/url_quote(lc $self->email)/e; + if ($params) + { + $url .= $url =~ /\?/ ? '&' : '?'; + $url .= $params; + } + return $url; +} + sub set_authorizer { my ($self, $authorizer) = @_; diff --git a/images/noavatar40.png b/images/noavatar40.png new file mode 100644 index 0000000000000000000000000000000000000000..f142a392e4d166f6a7e03496e27180b10c9a3898 GIT binary patch literal 1007 zcmVLomiR0?eZgjg0~SdsJ^M<4|Dd9LxK2DaAQ=&V{ET0{7vG zjIsHAet&;oRaG3v)>@_1{{H^a(b1~Rv9c@!w;E$EFE8u5ZnatffE+mI>bh1+ot>R^ zyWMbj?gECj));ese(s!$75DYv(`{l$iqkn^glI-O1k;X(KK?d?qnfy90%b;cL~j7B3N#5%7N z=lo~QQ^|3%9$?yoM_X$t4&DadCHd7w7A#@nkajE=6lC1pxr# z@fZMtYWJ(|Ip?$4%ufQrmQ}_%9}b6{^R->4G)9~9dafQQC7Fx?f3ghlK7rwjKK(S7-No)kFzXmRN-4y|9nA- z%%UjDvYbw*%btZKx7+Q0zyJC98FFB#sr1)-SZI7Xjo`0IMwTXHe%H^{#T(l7a%GX{Y9e2$KY3_Itrx#XPV z+Yoq{LNmtJ?&amBEKA?0F=+I%!C+8TRX8@Q>-yJ3rIb=it+llle^FeB&AlOnD2gJ_ zb2QGMfXNe<@vODu@mNZ^SS$cQYmGLkwf5fzgoOWwF$Ms#EX%U2-EJ$TzKq~&;3$fu zl#h>(NHUU%x#A$lCebm*gb+BvU#<1d&d$lnNs=VX2F@^iU%l_|@7LGY7&w&>!Hh9T za-+;BH~gjdm@eVr;bBn}jkl6F7*#WHR|5yMD&6udj{o0KdAVvc@+A@zLO)CODK* d^r}Wt^at|&6|pFk*8%_l002ovPDHLkV1ke)=BNMw literal 0 HcmV?d00001 diff --git a/skins/contrib/Mozilla/global.css b/skins/contrib/Mozilla/global.css index b3d3e8eac..fbc532679 100644 --- a/skins/contrib/Mozilla/global.css +++ b/skins/contrib/Mozilla/global.css @@ -538,7 +538,6 @@ input.required, select.required, span.required_explanation { .bz_first_comment_head, .bz_comment_head, .bz_comment_wthead { font-weight: normal; - line-height: 32px; padding-bottom: 2px; padding-left: 0px; margin-left: -5px; diff --git a/skins/standard/comments.css b/skins/standard/comments.css index eccd83971..3ccfa53cf 100644 --- a/skins/standard/comments.css +++ b/skins/standard/comments.css @@ -5,6 +5,7 @@ .bz_comment_user, .bz_comment_time, .bz_comment_number, .bz_private_checkbox, .bz_comment_actions { margin: 0 .5em; white-space: nowrap; } +.bz_comment_avatar { display: block; float: right; margin: -8px 8px 0; } .bz_comment_user, .bz_comment_time, .bz_comment_user_images, .bz_comment_worktime, .bz_comment_unmark_wtonly { float: left; } diff --git a/template/en/default/admin/params/integration.html.tmpl b/template/en/default/admin/params/integration.html.tmpl index c0a582d3c..747cab1e2 100644 --- a/template/en/default/admin/params/integration.html.tmpl +++ b/template/en/default/admin/params/integration.html.tmpl @@ -12,7 +12,11 @@ "

Perl regular expressions for checking 'See Also' field. Only values that match one of these regexes are allowed. Format:

" _ "
# Lines that start with # are treated as comments\n<REGEX>   <REPLACEMENT>
", - + gravatar_url => + "URL template for Gravatar-like avatars. You can use either \$MD5 or \$EMAIL in it to get avatar picture by user email." + _ " \$EMAIL will be replaced by cleartext user email, so you should only never use it in public networks;" + _ " \$MD5 will be replaced by MD5 hash of user email, just like it is required by real Gravatar service." + _ " You can also disable avatar display by clearing this parameter.", viewvc_url => "ViewVC query URL for browsing bug code", wiki_url => "Default MediaWiki URL for bug links", mediawiki_urls => diff --git a/template/en/default/bug/comments.html.tmpl b/template/en/default/bug/comments.html.tmpl index 5c227db7c..9efd2c17f 100644 --- a/template/en/default/bug/comments.html.tmpl +++ b/template/en/default/bug/comments.html.tmpl @@ -40,6 +40,9 @@ [% END %] +[% show_avatars = Param('gravatar_url') && user.settings.show_gravatars.value == 'on' %] +[% show_avatars = show_avatars ? (user.settings.skin.value == 'Mozilla' ? 1 : 2) : 0 %] + [% FOREACH comment = comments %] [% PROCESS a_comment %] [% END %] @@ -76,95 +79,113 @@ && (wt_wt && (has_worktime || wt_only) || wt_all) && (comment.who == user.id || user.in_group('worktimeadmin')) %] -
- [% IF comment.count == 0 %] - [% class_name = "bz_first_comment_head" %] - [% comment_label = "Description" %] - [% ELSE %] - [% class_name = wt_only ? "bz_comment_wthead" : "bz_comment_head" %] - [% comment_label = "Comment " _ comment.count %] +
+ [% IF comment.count == 0 %] + [% class_name = "bz_first_comment_head" %] + [% comment_label = "Description" %] + [% ELSE %] + [% class_name = wt_only ? "bz_comment_wthead" : "bz_comment_head" %] + [% comment_label = "Comment " _ comment.count %] + [% END %] + +
+ + + [% IF wt_btn %] + [% wt_only ? 'Comment is worktime-only' : 'Comment is not worktime-only' %] + [% END %] + -
- - - [% IF wt_btn %] - [% wt_only ? 'Comment is worktime-only' : 'Comment is not worktime-only' %] - - [% END %] - - - [% IF mode == "edit" && user.is_insider %] -
- - - -
- [% END %] - - - [% IF NOT wt_only %] - - [% IF (comment.author.id == user.id || !comment.count) && collision != 1 %] - [Edit] - [% END %] - - [%- comment_label FILTER html %] - - [% END %] - - - [% INCLUDE global/user.html.tmpl who = comment.author %] - - - - [% FOREACH group = comment.author.direct_group_membership %] - [% NEXT UNLESS group.icon_url %] - [% group.name FILTER html %] - [% END %] - - - - [%+ comment.creation_ts FILTER time %] - - - [% IF wt_only && has_worktime %] -
- [% PROCESS formattimeunit time_unit=comment.work_time %]h + [% IF mode == "edit" && user.is_insider %] +
+ + +
+ [% END %] + + + [% IF NOT wt_only %] + + [% IF (comment.author.id == user.id || !comment.count) && collision != 1 %] + [Edit] [% END %] + + [%- comment_label FILTER html %] + + [% END %] -
-
+ [%# FIXME: Mozilla skin is hardcoded :-( %] + [% IF show_avatars == 1 %] + + + + + + [% END %] - [% IF !wt_only && has_worktime %] -
- Additional hours worked: [%+ PROCESS formattimeunit time_unit=comment.work_time %] + + [% INCLUDE global/user.html.tmpl who = comment.author %] + + + + [% FOREACH group = comment.author.direct_group_membership %] + [% NEXT UNLESS group.icon_url %] + [% group.name FILTER html %] + [% END %] + + + + [%+ comment.creation_ts FILTER time %] + + + [% IF wt_only && has_worktime %] +
+ [% PROCESS formattimeunit time_unit=comment.work_time %]h
[% END %] -[%# Don't indent the
 block, since then the spaces are displayed in the
-  # generated HTML
-  #%]
-
- [%- comment.body_full({ wrap => 1, wo_preview => (user.settings.preview_long_comments.value == 'off') }) -%] -
+
+ + [% IF !wt_only && has_worktime %] +
+ Additional hours worked: [%+ PROCESS formattimeunit time_unit=comment.work_time %] +
+ [% END %] + +
+ [%# FIXME: Mozilla skin is hardcoded :-( %] + [% IF show_avatars == 2 %] + + + + + + [% END %] + [%- comment.body_full({ wrap => 1, wo_preview => (user.settings.preview_long_comments.value == 'off') }) -%] +
+ [% IF !wt_only && Param('gravatar_url') && user.settings.skin.value != 'Mozilla' %] +
+ [% END %] +
[% END %]