Open gitblit opened 9 years ago
We also would love to integrate Gitblit with Jira/Confluence Avatars. Atlassian provides Plugins for Jira/Confluence to act as avatar server. It should be easy to change the URL for requesting Avatars in utils/ActivityUtils.java URL for Jira https://your-jira/rest/avatar/1.0/server/
We are a non-profit company in Berlin with 250+ users and highly satisfied with GitBlit.
Kind Regads, aco
Hi @acoberlin. Gitblit 1.7+ does support a pluggable avatar source. You will have to create an implementation of AvatarGenerator
.
The current implementation looks like this:
import com.gitblit.utils.ActivityUtils;
import com.google.inject.Singleton;
@Singleton
public class GravatarGenerator implements AvatarGenerator {
@Override
public String getURL(String username, String emailaddress, boolean identicon, int width) {
String email = emailaddress == null ? username : emailaddress;
if (identicon) {
return ActivityUtils.getGravatarIdenticonUrl(email, width);
} else {
return ActivityUtils.getGravatarThumbnailUrl(email, width);
}
}
}
And then in your gitblit.properties
file you will have to instruct Gitblit to use your avatar source:
web.avatarClass = com.gitblit.GravatarGenerator
If you'd like to contribute a JIRA-based implementation in a pull request then @paulsputer and I would be happy to review.
I think I have found a quite simple solution:
public static String getGravatarIdenticonUrl(String email, int width) {
if (width <= 0) {
width = 50;
}
IStoredSettings settings = GitBlitWebApp.get().settings();
String keyurl = settings.getString(Keys.web.avatarUrl, "https://www.gravatar.com/avatar");
String emailHash = StringUtils.getMD5(email.toLowerCase());
String url = MessageFormat.format(
keyurl + "/{0}?s={1,number,0}&d=identicon", emailHash, width);
return url;
}
and getGravatarThubnailUrl
likewise
defaults.properties
contains now a new Key
# Define Custom Avatar Server URL
# empty Url sets the use of the Gravatar Server
# Example for Jira https://yourjiraserver/rest/avatar/1.0/server
# SINCE 1.7.2
web.avatarUrl =
The only unfortunate thing now is, that the Junit Test fails because GitBlitWebApp.get().settings()
is only available during runtime. I have not yet figured out a way to access the settings more elegantly.
Hope this helps :)
Originally reported on Google Code with ID 520
Reported by
friesenschrauber
on 2014-10-29 17:11:47