Merged #258 "Create an avatar provider that defaults to Gravatar"
2 files renamed
4 files added
17 files modified
| | |
| | | # SINCE 0.8.0 |
| | | web.allowGravatar = true |
| | | |
| | | # Define which class will generate the avatar URL. |
| | | # |
| | | # SINCE 1.7.0 |
| | | web.avatarClass = com.gitblit.GravatarGenerator |
| | | |
| | | # Allow dynamic zip downloads. |
| | | # |
| | | # SINCE 0.5.0 |
New file |
| | |
| | | /* |
| | | * Copyright 2015 gitblit.com. |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package com.gitblit; |
| | | |
| | | public interface AvatarGenerator { |
| | | |
| | | String getURL(String username, String emailaddress, boolean identicon, int width); |
| | | |
| | | } |
New file |
| | |
| | | /* |
| | | * Copyright 2015 gitblit.com. |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package com.gitblit; |
| | | |
| | | 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); |
| | | } |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | /* |
| | | * Copyright 2015 gitblit.com. |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package com.gitblit.guice; |
| | | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | | import com.gitblit.AvatarGenerator; |
| | | import com.gitblit.GravatarGenerator; |
| | | import com.gitblit.IStoredSettings; |
| | | import com.gitblit.Keys; |
| | | import com.gitblit.manager.IRuntimeManager; |
| | | import com.gitblit.utils.StringUtils; |
| | | import com.google.inject.Inject; |
| | | import com.google.inject.Provider; |
| | | import com.google.inject.Singleton; |
| | | |
| | | /** |
| | | * Provides a lazily-instantiated AvatarGenerator configured from IStoredSettings. |
| | | * |
| | | * @author James Moger |
| | | * |
| | | */ |
| | | @Singleton |
| | | public class AvatarGeneratorProvider implements Provider<AvatarGenerator> { |
| | | |
| | | private final Logger logger = LoggerFactory.getLogger(getClass()); |
| | | |
| | | private final IRuntimeManager runtimeManager; |
| | | |
| | | private volatile AvatarGenerator avatarGenerator; |
| | | |
| | | @Inject |
| | | public AvatarGeneratorProvider(IRuntimeManager runtimeManager) { |
| | | this.runtimeManager = runtimeManager; |
| | | } |
| | | |
| | | @Override |
| | | public synchronized AvatarGenerator get() { |
| | | if (avatarGenerator != null) { |
| | | return avatarGenerator; |
| | | } |
| | | |
| | | IStoredSettings settings = runtimeManager.getSettings(); |
| | | String clazz = settings.getString(Keys.web.avatarClass, GravatarGenerator.class.getName()); |
| | | if (StringUtils.isEmpty(clazz)) { |
| | | clazz = GravatarGenerator.class.getName(); |
| | | } |
| | | try { |
| | | Class<? extends AvatarGenerator> generatorClass = (Class<? extends AvatarGenerator>) Class.forName(clazz); |
| | | avatarGenerator = runtimeManager.getInjector().getInstance(generatorClass); |
| | | } catch (Exception e) { |
| | | logger.error("failed to create avatar generator", e); |
| | | avatarGenerator = new GravatarGenerator(); |
| | | } |
| | | return avatarGenerator; |
| | | } |
| | | } |
| | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | import com.gitblit.AvatarGenerator; |
| | | import com.gitblit.Constants; |
| | | import com.gitblit.servlet.AccessDeniedServlet; |
| | | import com.gitblit.servlet.BranchGraphServlet; |
| | |
| | | |
| | | @Override |
| | | protected void configureServlets() { |
| | | |
| | | // bind web component providers |
| | | bind(AvatarGenerator.class).toProvider(AvatarGeneratorProvider.class); |
| | | |
| | | // servlets |
| | | serve(fuzzy(Constants.R_PATH), fuzzy(Constants.GIT_PATH)).with(GitServlet.class); |
| | | serve(fuzzy(Constants.RAW_PATH)).with(RawServlet.class); |
| | |
| | | if (width <= 0) {
|
| | | width = 50;
|
| | | }
|
| | | String emailHash = StringUtils.getMD5(email);
|
| | | String emailHash = StringUtils.getMD5(email.toLowerCase());
|
| | | String url = MessageFormat.format(
|
| | | "https://www.gravatar.com/avatar/{0}?s={1,number,0}&d=identicon", emailHash, width);
|
| | | return url;
|
| | |
| | | if (width <= 0) {
|
| | | width = 50;
|
| | | }
|
| | | String emailHash = StringUtils.getMD5(email);
|
| | | String emailHash = StringUtils.getMD5(email.toLowerCase());
|
| | | String url = MessageFormat.format(
|
| | | "https://www.gravatar.com/avatar/{0}?s={1,number,0}&d=mm", emailHash, width);
|
| | | return url;
|
| | |
| | | import com.gitblit.wicket.panels.CommitHeaderPanel; |
| | | import com.gitblit.wicket.panels.CommitLegendPanel; |
| | | import com.gitblit.wicket.panels.DiffStatPanel; |
| | | import com.gitblit.wicket.panels.GravatarImage; |
| | | import com.gitblit.wicket.panels.AvatarImage; |
| | | import com.gitblit.wicket.panels.LinkPanel; |
| | | import com.gitblit.wicket.panels.RefsPanel; |
| | | |
| | |
| | | item.add(new RefsPanel("refName", repositoryName, Arrays.asList(entry.notesRef))); |
| | | item.add(createPersonPanel("authorName", entry.notesRef.getAuthorIdent(), |
| | | Constants.SearchType.AUTHOR)); |
| | | item.add(new GravatarImage("noteAuthorAvatar", entry.notesRef.getAuthorIdent())); |
| | | item.add(new AvatarImage("noteAuthorAvatar", entry.notesRef.getAuthorIdent())); |
| | | item.add(WicketUtils.createTimestampLabel("authorDate", entry.notesRef |
| | | .getAuthorIdent().getWhen(), getTimeZone(), getTimeUtils())); |
| | | item.add(new Label("noteContent", bugtraqProcessor().processPlainCommitMessage(getRepository(), repositoryName, |
| | |
| | | import com.gitblit.wicket.panels.CommitLegendPanel;
|
| | | import com.gitblit.wicket.panels.CompressedDownloadsPanel;
|
| | | import com.gitblit.wicket.panels.DiffStatPanel;
|
| | | import com.gitblit.wicket.panels.GravatarImage;
|
| | | import com.gitblit.wicket.panels.AvatarImage;
|
| | | import com.gitblit.wicket.panels.LinkPanel;
|
| | | import com.gitblit.wicket.panels.RefsPanel;
|
| | |
|
| | |
| | | item.add(new RefsPanel("refName", repositoryName, Arrays.asList(entry.notesRef)));
|
| | | item.add(createPersonPanel("authorName", entry.notesRef.getAuthorIdent(),
|
| | | Constants.SearchType.AUTHOR));
|
| | | item.add(new GravatarImage("noteAuthorAvatar", entry.notesRef.getAuthorIdent()));
|
| | | item.add(new AvatarImage("noteAuthorAvatar", entry.notesRef.getAuthorIdent()));
|
| | | item.add(WicketUtils.createTimestampLabel("authorDate", entry.notesRef
|
| | | .getAuthorIdent().getWhen(), getTimeZone(), getTimeUtils()));
|
| | | item.add(new Label("noteContent", bugtraqProcessor().processPlainCommitMessage(getRepository(), repositoryName,
|
| | |
| | | import com.gitblit.utils.StringUtils;
|
| | | import com.gitblit.wicket.GitBlitWebSession;
|
| | | import com.gitblit.wicket.WicketUtils;
|
| | | import com.gitblit.wicket.panels.GravatarImage;
|
| | | import com.gitblit.wicket.panels.AvatarImage;
|
| | | import com.gitblit.wicket.panels.LinkPanel;
|
| | |
|
| | | public class ForksPage extends RepositoryPage {
|
| | |
| | | user = new UserModel(repository.projectPath.substring(1));
|
| | | }
|
| | | PersonIdent ident = new PersonIdent(user.getDisplayName(), user.emailAddress == null ? user.getDisplayName() : user.emailAddress);
|
| | | item.add(new GravatarImage("anAvatar", ident, 20));
|
| | | item.add(new AvatarImage("anAvatar", ident, 20));
|
| | | if (pageRepository.equals(repository)) {
|
| | | // do not link to self
|
| | | item.add(new Label("aProject", user.getDisplayName()));
|
| | |
| | | import com.gitblit.wicket.GitBlitWebSession; |
| | | import com.gitblit.wicket.SessionlessForm; |
| | | import com.gitblit.wicket.WicketUtils; |
| | | import com.gitblit.wicket.panels.GravatarImage; |
| | | import com.gitblit.wicket.panels.AvatarImage; |
| | | import com.gitblit.wicket.panels.LinkPanel; |
| | | import com.gitblit.wicket.panels.NavigationPanel; |
| | | |
| | |
| | | boolean standardLogin = authenticationType.isStandard(); |
| | | |
| | | if (app().settings().getBoolean(Keys.web.allowGravatar, true)) { |
| | | add(new GravatarImage("username", user, "navbarGravatar", 20, false)); |
| | | add(new AvatarImage("username", user, "navbarGravatar", 20, false)); |
| | | } else { |
| | | add(new Label("username", user.getDisplayName())); |
| | | } |
| | |
| | | import com.gitblit.wicket.CacheControl;
|
| | | import com.gitblit.wicket.CacheControl.LastModified;
|
| | | import com.gitblit.wicket.WicketUtils;
|
| | | import com.gitblit.wicket.panels.GravatarImage;
|
| | | import com.gitblit.wicket.panels.AvatarImage;
|
| | | import com.gitblit.wicket.panels.LinkPanel;
|
| | | import com.gitblit.wicket.panels.RefsPanel;
|
| | |
|
| | |
| | | linkClass = CommitPage.class;
|
| | | break;
|
| | | }
|
| | | add(new GravatarImage("taggerAvatar", tagRef.getAuthorIdent()));
|
| | | add(new AvatarImage("taggerAvatar", tagRef.getAuthorIdent()));
|
| | |
|
| | | add(new RefsPanel("tagName", repositoryName, Arrays.asList(tagRef)));
|
| | | add(new Label("tagId", tagRef.getObjectId().getName()));
|
| | |
| | | import com.gitblit.wicket.panels.BasePanel.JavascriptTextPrompt;
|
| | | import com.gitblit.wicket.panels.CommentPanel;
|
| | | import com.gitblit.wicket.panels.DiffStatPanel;
|
| | | import com.gitblit.wicket.panels.GravatarImage;
|
| | | import com.gitblit.wicket.panels.AvatarImage;
|
| | | import com.gitblit.wicket.panels.IconAjaxLink;
|
| | | import com.gitblit.wicket.panels.LinkPanel;
|
| | | import com.gitblit.wicket.panels.ShockWaveComponent;
|
| | |
| | | if (user == null) {
|
| | | user = new UserModel(username);
|
| | | }
|
| | | item.add(new GravatarImage("participant", user.getDisplayName(),
|
| | | item.add(new AvatarImage("participant", user.getDisplayName(),
|
| | | user.emailAddress, null, 25, true));
|
| | | }
|
| | | };
|
| | |
| | | } else {
|
| | | // permit user to comment
|
| | | Fragment newComment = new Fragment("newComment", "newCommentFragment", this);
|
| | | GravatarImage img = new GravatarImage("newCommentAvatar", user.username, user.emailAddress,
|
| | | AvatarImage img = new AvatarImage("newCommentAvatar", user.username, user.emailAddress,
|
| | | "gravatar-round", avatarWidth, true);
|
| | | newComment.add(img);
|
| | | CommentPanel commentPanel = new CommentPanel("commentPanel", user, ticket, null, TicketsPage.class);
|
| | |
| | | public void populateItem(final Item<RevCommit> item) {
|
| | | RevCommit commit = item.getModelObject();
|
| | | PersonIdent author = commit.getAuthorIdent();
|
| | | item.add(new GravatarImage("authorAvatar", author.getName(), author.getEmailAddress(), null, 16, false));
|
| | | item.add(new AvatarImage("authorAvatar", author.getName(), author.getEmailAddress(), null, 16, false));
|
| | | item.add(new Label("author", commit.getAuthorIdent().getName()));
|
| | | item.add(new LinkPanel("commitId", null, getShortObjectId(commit.getName()),
|
| | | CommitPage.class, WicketUtils.newObjectParameter(repositoryName, commit.getName()), true));
|
| | |
| | | UserModel commenter = app().users().getUserModel(entry.author);
|
| | | if (commenter == null) {
|
| | | // unknown user
|
| | | container.add(new GravatarImage("changeAvatar", entry.author,
|
| | | container.add(new AvatarImage("changeAvatar", entry.author,
|
| | | entry.author, null, avatarSize, false).setVisible(avatarSize > 0));
|
| | | container.add(new Label("changeAuthor", entry.author.toLowerCase()));
|
| | | } else {
|
| | | // known user
|
| | | container.add(new GravatarImage("changeAvatar", commenter.getDisplayName(),
|
| | | container.add(new AvatarImage("changeAvatar", commenter.getDisplayName(),
|
| | | commenter.emailAddress, avatarSize > 24 ? "gravatar-round" : null,
|
| | | avatarSize, true).setVisible(avatarSize > 0));
|
| | | container.add(new LinkPanel("changeAuthor", null, commenter.getDisplayName(),
|
| | |
| | | .getWhen(), getTimeZone(), getTimeUtils()));
|
| | |
|
| | | // avatar
|
| | | commitItem.add(new GravatarImage("avatar", commit.getAuthorIdent(), 40));
|
| | | commitItem.add(new AvatarImage("avatar", commit.getAuthorIdent(), 40));
|
| | |
|
| | | // merge icon
|
| | | if (commit.getParentCount() > 1) {
|
File was renamed from src/main/java/com/gitblit/wicket/panels/GravatarImage.java |
| | |
| | | |
| | | import org.eclipse.jgit.lib.PersonIdent; |
| | | |
| | | import com.gitblit.AvatarGenerator; |
| | | import com.gitblit.Keys; |
| | | import com.gitblit.models.UserModel; |
| | | import com.gitblit.utils.ActivityUtils; |
| | | import com.gitblit.wicket.ExternalImage; |
| | | import com.gitblit.wicket.WicketUtils; |
| | | |
| | |
| | | * @author James Moger |
| | | * |
| | | */ |
| | | public class GravatarImage extends BasePanel { |
| | | public class AvatarImage extends BasePanel { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | public GravatarImage(String id, PersonIdent person) { |
| | | public AvatarImage(String id, PersonIdent person) { |
| | | this(id, person, 0); |
| | | } |
| | | |
| | | public GravatarImage(String id, PersonIdent person, int width) { |
| | | public AvatarImage(String id, PersonIdent person, int width) { |
| | | this(id, person.getName(), person.getEmailAddress(), "gravatar", width, true); |
| | | } |
| | | |
| | | public GravatarImage(String id, PersonIdent person, String cssClass, int width, boolean identicon) { |
| | | public AvatarImage(String id, PersonIdent person, String cssClass, int width, boolean identicon) { |
| | | this(id, person.getName(), person.getEmailAddress(), cssClass, width, identicon); |
| | | } |
| | | |
| | | public GravatarImage(String id, UserModel user, String cssClass, int width, boolean identicon) { |
| | | public AvatarImage(String id, UserModel user, String cssClass, int width, boolean identicon) { |
| | | this(id, user.getDisplayName(), user.emailAddress, cssClass, width, identicon); |
| | | } |
| | | |
| | | public GravatarImage(String id, String username, String emailaddress, String cssClass, int width, boolean identicon) { |
| | | public AvatarImage(String id, String username, String emailaddress, String cssClass, int width, boolean identicon) { |
| | | super(id); |
| | | |
| | | String email = emailaddress == null ? username.toLowerCase() : emailaddress.toLowerCase(); |
| | | String url; |
| | | if (identicon) { |
| | | url = ActivityUtils.getGravatarIdenticonUrl(email, width); |
| | | } else { |
| | | url = ActivityUtils.getGravatarThumbnailUrl(email, width); |
| | | } |
| | | AvatarGenerator avatarGenerator = app().runtime().getInjector().getInstance(AvatarGenerator.class); |
| | | String url = avatarGenerator.getURL(username, emailaddress, identicon, width); |
| | | ExternalImage image = new ExternalImage("image", url); |
| | | if (cssClass != null) { |
| | | WicketUtils.setCssClass(image, cssClass); |
| | |
| | | add(new Label("commitid", c.getName()));
|
| | | add(new Label("author", c.getAuthorIdent().getName()));
|
| | | add(WicketUtils.createDateLabel("date", c.getAuthorIdent().getWhen(), getTimeZone(), getTimeUtils()));
|
| | | add(new GravatarImage("authorAvatar", c.getAuthorIdent()));
|
| | | add(new AvatarImage("authorAvatar", c.getAuthorIdent()));
|
| | | }
|
| | | } |
| | |
| | | final RepositoryCommit commit = commitItem.getModelObject(); |
| | | |
| | | // author gravatar |
| | | commitItem.add(new GravatarImage("commitAuthor", commit.getAuthorIdent(), null, 16, false)); |
| | | commitItem.add(new AvatarImage("commitAuthor", commit.getAuthorIdent(), null, 16, false)); |
| | | |
| | | // merge icon |
| | | if (commit.getParentCount() > 1) { |
| | |
| | | final RepositoryCommit commit = commitItem.getModelObject(); |
| | | |
| | | // author gravatar |
| | | commitItem.add(new GravatarImage("commitAuthor", commit.getAuthorIdent(), null, 16, false)); |
| | | commitItem.add(new AvatarImage("commitAuthor", commit.getAuthorIdent(), null, 16, false)); |
| | | |
| | | // merge icon |
| | | if (commit.getParentCount() > 1) { |
| | |
| | | } |
| | | |
| | | Fragment userFragment = new Fragment("registrant", "userRegistrant", RegistrantPermissionsPanel.this); |
| | | userFragment.add(new GravatarImage("userAvatar", ident, 20)); |
| | | userFragment.add(new AvatarImage("userAvatar", ident, 20)); |
| | | userFragment.add(new Label("userName", entry.registrant)); |
| | | item.add(userFragment); |
| | | } else { |
| | |
| | | if (responsible == null) { |
| | | responsible = new UserModel(ticket.responsible); |
| | | } |
| | | GravatarImage avatar = new GravatarImage("responsible", responsible.getDisplayName(), |
| | | AvatarImage avatar = new AvatarImage("responsible", responsible.getDisplayName(), |
| | | responsible.emailAddress, null, 16, true); |
| | | avatar.setTooltip(getString("gb.responsible") + ": " + responsible.getDisplayName()); |
| | | item.add(avatar); |
| | |
| | |
|
| | | public UserTitlePanel(String wicketId, UserModel user, String title) {
|
| | | super(wicketId);
|
| | | add(new GravatarImage("userGravatar", user, "gravatar", 36, false));
|
| | | add(new AvatarImage("userGravatar", user, "gravatar", 36, false));
|
| | | add(new Label("userDisplayName", user.getDisplayName()));
|
| | | add(new Label("userTitle", title));
|
| | | }
|
| | |
| | | FanoutServiceTest.class, Issue0259Test.class, Issue0271Test.class, HtpasswdAuthenticationTest.class,
|
| | | ModelUtilsTest.class, JnaUtilsTest.class, LdapSyncServiceTest.class, FileTicketServiceTest.class,
|
| | | BranchTicketServiceTest.class, RedisTicketServiceTest.class, AuthenticationManagerTest.class,
|
| | | SshKeysDispatcherTest.class, UITicketTest.class, PathUtilsTest.class, SshKerberosAuthenticationTest.class })
|
| | | SshKeysDispatcherTest.class, UITicketTest.class, PathUtilsTest.class, SshKerberosAuthenticationTest.class,
|
| | | GravatarTest.class })
|
| | | public class GitBlitSuite {
|
| | |
|
| | | public static final File BASEFOLDER = new File("data");
|
New file |
| | |
| | | package com.gitblit.tests; |
| | | |
| | | import org.junit.Test; |
| | | |
| | | import com.gitblit.AvatarGenerator; |
| | | import com.gitblit.GravatarGenerator; |
| | | import com.gitblit.IStoredSettings; |
| | | import com.gitblit.Keys; |
| | | import com.gitblit.guice.AvatarGeneratorProvider; |
| | | import com.gitblit.manager.IRuntimeManager; |
| | | import com.gitblit.manager.RuntimeManager; |
| | | import com.gitblit.tests.mock.MemorySettings; |
| | | import com.gitblit.utils.ActivityUtils; |
| | | import com.gitblit.utils.XssFilter; |
| | | import com.gitblit.utils.XssFilter.AllowXssFilter; |
| | | import com.google.inject.AbstractModule; |
| | | import com.google.inject.Guice; |
| | | import com.google.inject.Injector; |
| | | |
| | | public class GravatarTest extends GitblitUnitTest { |
| | | |
| | | public static class AvatarModule extends AbstractModule { |
| | | private final IStoredSettings settings; |
| | | |
| | | AvatarModule(IStoredSettings settings) { |
| | | this.settings = settings; |
| | | } |
| | | |
| | | @Override |
| | | protected void configure() { |
| | | bind(IStoredSettings.class).toInstance(settings); |
| | | bind(XssFilter.class).to(AllowXssFilter.class); |
| | | bind(IRuntimeManager.class).to(RuntimeManager.class); |
| | | bind(AvatarGenerator.class).toProvider(AvatarGeneratorProvider.class); |
| | | } |
| | | } |
| | | |
| | | @Test |
| | | public void gravatarIdenticonTest() { |
| | | IStoredSettings settings = new MemorySettings(); |
| | | settings.overrideSetting(Keys.web.avatarClass, GravatarGenerator.class.getName()); |
| | | |
| | | Injector injector = Guice.createInjector(new AvatarModule(settings)); |
| | | AvatarGenerator avatarGenerator = injector.getInstance(AvatarGenerator.class); |
| | | |
| | | String username = "username"; |
| | | String emailAddress = "emailAddress"; |
| | | int width = 10; |
| | | |
| | | String url = avatarGenerator.getURL(username, emailAddress, true, width); |
| | | assertNotNull(url); |
| | | |
| | | assertEquals(ActivityUtils.getGravatarIdenticonUrl(emailAddress, width), url); |
| | | } |
| | | |
| | | @Test |
| | | public void gravatarThumbnailTest() { |
| | | IStoredSettings settings = new MemorySettings(); |
| | | settings.overrideSetting(Keys.web.avatarClass, GravatarGenerator.class.getName()); |
| | | |
| | | Injector injector = Guice.createInjector(new AvatarModule(settings)); |
| | | AvatarGenerator avatarGenerator = injector.getInstance(AvatarGenerator.class); |
| | | |
| | | String username = "username"; |
| | | String emailAddress = "emailAddress"; |
| | | int width = 10; |
| | | |
| | | String url = avatarGenerator.getURL(username, emailAddress, false, width); |
| | | assertNotNull(url); |
| | | |
| | | assertEquals(ActivityUtils.getGravatarThumbnailUrl(emailAddress, width), url); |
| | | } |
| | | |
| | | } |