選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

GravatarProfilePage.java 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Copyright 2011 gitblit.com.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package com.gitblit.wicket.pages;
  17. import java.io.IOException;
  18. import java.text.MessageFormat;
  19. import org.apache.wicket.PageParameters;
  20. import org.apache.wicket.markup.html.basic.Label;
  21. import org.apache.wicket.markup.html.link.ExternalLink;
  22. import com.gitblit.models.GravatarProfile;
  23. import com.gitblit.utils.ActivityUtils;
  24. import com.gitblit.wicket.ExternalImage;
  25. import com.gitblit.wicket.WicketUtils;
  26. /**
  27. * Gravatar Profile Page shows the Gravatar information, if available.
  28. *
  29. * @author James Moger
  30. *
  31. */
  32. public class GravatarProfilePage extends RootPage {
  33. public GravatarProfilePage(PageParameters params) {
  34. super();
  35. setupPage("", "");
  36. String object = WicketUtils.getObject(params);
  37. GravatarProfile profile = null;
  38. try {
  39. if (object.indexOf('@') > -1) {
  40. profile = ActivityUtils.getGravatarProfileFromAddress(object);
  41. } else {
  42. profile = ActivityUtils.getGravatarProfile(object);
  43. }
  44. } catch (IOException e) {
  45. error(MessageFormat.format(getString("gb.failedToFindGravatarProfile"), object), e, true);
  46. }
  47. if (profile == null) {
  48. error(MessageFormat.format(getString("gb.failedToFindGravatarProfile"), object), true);
  49. }
  50. add(new Label("displayName", profile.displayName));
  51. add(new Label("username", profile.preferredUsername));
  52. add(new Label("location", profile.currentLocation));
  53. add(new Label("aboutMe", profile.aboutMe));
  54. ExternalImage image = new ExternalImage("profileImage", profile.thumbnailUrl + "?s=256&d=identicon");
  55. add(image);
  56. add(new ExternalLink("profileLink", profile.profileUrl));
  57. }
  58. }