Skip to content

Commit 679a1a1

Browse files
Oblomovgitster
authored andcommitted
gitweb: picon avatar provider
Simple implementation of picon that only relies on the indiana.edu database. Signed-off-by: Giuseppe Bilotta <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5a371b7 commit 679a1a1

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

gitweb/gitweb.perl

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -378,15 +378,18 @@ BEGIN
378378
# shortlog or commit will display an avatar associated with
379379
# the email of the committer(s) and/or author(s).
380380

381-
# Currently only the gravatar provider is available, and it
382-
# depends on Digest::MD5. If an unknown provider is specified,
383-
# the feature is disabled.
381+
# Currently available providers are gravatar and picon.
382+
# If an unknown provider is specified, the feature is disabled.
383+
384+
# Gravatar depends on Digest::MD5.
385+
# Picon currently relies on the indiana.edu database.
384386

385387
# To enable system wide have in $GITWEB_CONFIG
386-
# $feature{'avatar'}{'default'} = ['gravatar'];
388+
# $feature{'avatar'}{'default'} = ['<provider>'];
389+
# where <provider> is either gravatar or picon.
387390
# To have project specific config enable override in $GITWEB_CONFIG
388391
# $feature{'avatar'}{'override'} = 1;
389-
# and in project config gitweb.avatar = gravatar;
392+
# and in project config gitweb.avatar = <provider>;
390393
'avatar' => {
391394
'sub' => \&feature_avatar,
392395
'override' => 0,
@@ -853,6 +856,8 @@ sub evaluate_path_info {
853856
our ($git_avatar) = gitweb_get_feature('avatar');
854857
if ($git_avatar eq 'gravatar') {
855858
$git_avatar = '' unless (eval { require Digest::MD5; 1; });
859+
} elsif ($git_avatar eq 'picon') {
860+
# no dependencies
856861
} else {
857862
$git_avatar = '';
858863
}
@@ -1520,6 +1525,20 @@ sub format_subject_html {
15201525
# given page, there's no risk for cache conflicts.
15211526
our %avatar_cache = ();
15221527

1528+
# Compute the picon url for a given email, by using the picon search service over at
1529+
# http://www.cs.indiana.edu/picons/search.html
1530+
sub picon_url {
1531+
my $email = lc shift;
1532+
if (!$avatar_cache{$email}) {
1533+
my ($user, $domain) = split('@', $email);
1534+
$avatar_cache{$email} =
1535+
"http://www.cs.indiana.edu/cgi-pub/kinzler/piconsearch.cgi/" .
1536+
"$domain/$user/" .
1537+
"users+domains+unknown/up/single";
1538+
}
1539+
return $avatar_cache{$email};
1540+
}
1541+
15231542
# Compute the gravatar url for a given email, if it's not in the cache already.
15241543
# Gravatar stores only the part of the URL before the size, since that's the
15251544
# one computationally more expensive. This also allows reuse of the cache for
@@ -1544,9 +1563,10 @@ sub git_get_avatar {
15441563
my $url = "";
15451564
if ($git_avatar eq 'gravatar') {
15461565
$url = gravatar_url($email, $size);
1566+
} elsif ($git_avatar eq 'picon') {
1567+
$url = picon_url($email);
15471568
}
1548-
# Currently only gravatars are supported, but other forms such as
1549-
# picons can be added by putting an else up here and defining $url
1569+
# Other providers can be added by extending the if chain, defining $url
15501570
# as needed. If no variant puts something in $url, we assume avatars
15511571
# are completely disabled/unavailable.
15521572
if ($url) {

0 commit comments

Comments
 (0)