Configurable gravatar service url
URL of the gravatar service and change URL can be configured in
gerrit.config file. Documentation added.
Change-Id: I670d9fcf7185d44a5ca9825221d13e7e4d9e4e82
diff --git a/src/main/java/com/googlesource/gerrit/plugins/avatars/gravatar/GravatarAvatarProvider.java b/src/main/java/com/googlesource/gerrit/plugins/avatars/gravatar/GravatarAvatarProvider.java
index 81aeb25..f4bd5b0 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/avatars/gravatar/GravatarAvatarProvider.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/avatars/gravatar/GravatarAvatarProvider.java
@@ -44,6 +44,8 @@
private final boolean ssl;
private final String avatarType;
+ private final String gravatarUrl;
+ private final String changeAvatarUrl;
@Inject
GravatarAvatarProvider(@CanonicalWebUrl String canonicalUrl,
@@ -52,6 +54,10 @@
ssl = canonicalUrl.startsWith("https://");
this.avatarType = cfgFactory.getFromGerritConfig(pluginName)
.getString("type", "identicon");
+ this.gravatarUrl = cfgFactory.getFromGerritConfig(pluginName)
+ .getString("gravatarUrl", "www.gravatar.com/avatar/");
+ this.changeAvatarUrl = cfgFactory.getFromGerritConfig(pluginName)
+ .getString("changeAvatarUrl", "http://www.gravatar.com");
}
@Override
@@ -77,7 +83,7 @@
} else {
url.append("http://");
}
- url.append("www.gravatar.com/avatar/");
+ url.append(gravatarUrl);
url.append(hex(emailMd5));
url.append(".jpg");
// TODO: currently we force the default icon to identicon and the rating
@@ -91,6 +97,6 @@
@Override
public String getChangeAvatarUrl(IdentifiedUser forUser) {
- return "http://www.gravatar.com";
+ return changeAvatarUrl;
}
}
diff --git a/src/main/resources/Documentation/about.md b/src/main/resources/Documentation/about.md
index 23112e8..fbf259e 100644
--- a/src/main/resources/Documentation/about.md
+++ b/src/main/resources/Documentation/about.md
@@ -1 +1,2 @@
-Provides the ability to show the avatar from http://www.gravatar.com service.
+Provides the ability to show the avatar from http://www.gravatar.com service or
+other services that provide the Gravatar API.
diff --git a/src/main/resources/Documentation/config.md b/src/main/resources/Documentation/config.md
index 5fbd3fe..3768093 100644
--- a/src/main/resources/Documentation/config.md
+++ b/src/main/resources/Documentation/config.md
@@ -17,3 +17,17 @@
(404, mm, identicon, monsterid, wavatar, retro, blank, ...).
Default: identicon
+
+<a id="gravatarUrl">
+`plugin.@PLUGIN@.gravatarUrl`
+: URL that provides the Gravatar API.
+
+ Uses the same protocol (http, https) as gerrit.canonicalWebUrl.
+
+ Default: www.gravatar.com/avatar/
+
+<a id="changeAvatarUrl">
+`plugin.@PLUGIN@.changeAvatarUrl`
+: Link to where the avatar can be changed as displayed in the profile settings.
+
+ Default: http://www.gravatar.com