Configurable avatar type
Avatar type can be configured in gerrit.config file.
Avatar types can be found at http://gravatar.com/site/implement/images/
Documentation added.
Change-Id: I43b0962ec20f1d3351de6926a8df9435dc5d1595
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 efc1834..81aeb25 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
@@ -15,9 +15,11 @@
package com.googlesource.gerrit.plugins.avatars.gravatar;
import com.google.gerrit.extensions.annotations.Listen;
+import com.google.gerrit.extensions.annotations.PluginName;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.avatar.AvatarProvider;
import com.google.gerrit.server.config.CanonicalWebUrl;
+import com.google.gerrit.server.config.PluginConfigFactory;
import com.google.inject.Inject;
import com.google.inject.Singleton;
@@ -41,10 +43,15 @@
}
private final boolean ssl;
+ private final String avatarType;
@Inject
- GravatarAvatarProvider(@CanonicalWebUrl String canonicalUrl) {
+ GravatarAvatarProvider(@CanonicalWebUrl String canonicalUrl,
+ @PluginName String pluginName,
+ PluginConfigFactory cfgFactory) {
ssl = canonicalUrl.startsWith("https://");
+ this.avatarType = cfgFactory.getFromGerritConfig(pluginName)
+ .getString("type", "identicon");
}
@Override
@@ -75,7 +82,7 @@
url.append(".jpg");
// TODO: currently we force the default icon to identicon and the rating
// to PG. It'd be nice to have these be admin-configurable.
- url.append("?d=identicon&r=pg");
+ url.append("?d=" + avatarType + "&r=pg");
if (imageSize > 0) {
url.append("&s=").append(imageSize);
}
diff --git a/src/main/resources/Documentation/about.md b/src/main/resources/Documentation/about.md
new file mode 100644
index 0000000..23112e8
--- /dev/null
+++ b/src/main/resources/Documentation/about.md
@@ -0,0 +1 @@
+Provides the ability to show the avatar from http://www.gravatar.com service.
diff --git a/src/main/resources/Documentation/config.md b/src/main/resources/Documentation/config.md
new file mode 100644
index 0000000..5fbd3fe
--- /dev/null
+++ b/src/main/resources/Documentation/config.md
@@ -0,0 +1,19 @@
+Configuration
+=============
+
+The configuration of the @PLUGIN@ plugin is done in the `gerrit.config`
+file.
+
+```
+ [plugin "@PLUGIN@"]
+ type = identicon
+```
+
+<a id="type">
+`plugin.@PLUGIN@.type`
+: Avatar type in www.gravatar.com service.
+
+ Can be any type supported by the service
+ (404, mm, identicon, monsterid, wavatar, retro, blank, ...).
+
+ Default: identicon