git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Chris West (Faux)" <git@goeswhere.com>
To: git@vger.kernel.org
Subject: [PATCH] gitweb: Add support for gravatar-ssl
Date: Thu, 9 Aug 2012 19:42:10 +0100	[thread overview]
Message-ID: <20120809184210.GA27795@goeswhere.com> (raw)

Teach gitweb to allow 'avatar' to be set to 'gravatar-ssl', switching
to the https://secure.gravatar.com url form, to avoid mixed content
warnings when serving gitweb over https, with gravatar enabled.
---

I'd alternatively propose always using the https:// form of the URL,
but it seems significantly slower, so it's probably best to let people
pick to continue using the insecure version.

 gitweb/gitweb.perl |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 3d6a705..d70e8b8 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -482,7 +482,7 @@ our %feature = (
 
 	# To enable system wide have in $GITWEB_CONFIG
 	# $feature{'avatar'}{'default'} = ['<provider>'];
-	# where <provider> is either gravatar or picon.
+	# where <provider> is either gravatar, gravatar-ssl or picon.
 	# To have project specific config enable override in $GITWEB_CONFIG
 	# $feature{'avatar'}{'override'} = 1;
 	# and in project config gitweb.avatar = <provider>;
@@ -1117,7 +1117,7 @@ sub configure_gitweb_features {
 	# if the provider name is invalid or the dependencies are not met,
 	# reset $git_avatar to the empty string.
 	our ($git_avatar) = gitweb_get_feature('avatar');
-	if ($git_avatar eq 'gravatar') {
+	if ($git_avatar eq 'gravatar' || $git_avatar eq 'gravatar-ssl') {
 		$git_avatar = '' unless (eval { require Digest::MD5; 1; });
 	} elsif ($git_avatar eq 'picon') {
 		# no dependencies
@@ -2079,7 +2079,10 @@ sub gravatar_url {
 	my $email = lc shift;
 	my $size = shift;
 	$avatar_cache{$email} ||=
-		"http://www.gravatar.com/avatar/" .
+		($git_avatar eq 'gravatar-ssl' ?
+			"https://secure" :
+			"http://www")
+		. ".gravatar.com/avatar/" .
 			Digest::MD5::md5_hex($email) . "?s=";
 	return $avatar_cache{$email} . $size;
 }
@@ -2093,7 +2096,7 @@ sub git_get_avatar {
 	$opts{-size} ||= 'default';
 	my $size = $avatar_size{$opts{-size}} || $avatar_size{'default'};
 	my $url = "";
-	if ($git_avatar eq 'gravatar') {
+	if ($git_avatar eq 'gravatar' || $git_avatar eq 'gravatar-ssl') {
 		$url = gravatar_url($email, $size);
 	} elsif ($git_avatar eq 'picon') {
 		$url = picon_url($email);
-- 
1.7.10

             reply	other threads:[~2012-08-09 18:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-09 18:42 Chris West (Faux) [this message]
2012-08-09 19:36 ` [PATCH] gitweb: Add support for gravatar-ssl Giuseppe Bilotta
2012-08-09 19:53   ` git

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120809184210.GA27795@goeswhere.com \
    --to=git@goeswhere.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).