James Moger
2013-05-10 8d44aaddf906a9a08fbd53b48332140a66d94b11
commit | author | age
797322 1 /*
JM 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
18 import java.io.IOException;
19 import java.text.MessageFormat;
20
21 import org.apache.wicket.PageParameters;
22 import org.apache.wicket.markup.html.basic.Label;
23 import org.apache.wicket.markup.html.link.ExternalLink;
24
25 import com.gitblit.models.GravatarProfile;
26 import com.gitblit.utils.ActivityUtils;
d9afa9 27 import com.gitblit.wicket.ExternalImage;
797322 28 import com.gitblit.wicket.WicketUtils;
JM 29
30 /**
31  * Gravatar Profile Page shows the Gravatar information, if available.
32  * 
33  * @author James Moger
34  * 
35  */
36 public class GravatarProfilePage extends RootPage {
37
38     public GravatarProfilePage(PageParameters params) {
39         super();
40         setupPage("", "");
41         String object = WicketUtils.getObject(params);
42         GravatarProfile profile = null;
43         try {
44             if (object.indexOf('@') > -1) {
45                 profile = ActivityUtils.getGravatarProfileFromAddress(object);
46             } else {
47                 profile = ActivityUtils.getGravatarProfile(object);
48             }
49         } catch (IOException e) {
6caa93 50             error(MessageFormat.format(getString("gb.failedToFindGravatarProfile"), object), e, true);
797322 51         }
d17f43 52         
JM 53         if (profile == null) {
6caa93 54             error(MessageFormat.format(getString("gb.failedToFindGravatarProfile"), object), true);
d17f43 55         }
797322 56         add(new Label("displayName", profile.displayName));
JM 57         add(new Label("username", profile.preferredUsername));
58         add(new Label("location", profile.currentLocation));
59         add(new Label("aboutMe", profile.aboutMe));
d9afa9 60         ExternalImage image = new ExternalImage("profileImage", profile.thumbnailUrl + "?s=256&d=identicon");
797322 61         add(image);
JM 62         add(new ExternalLink("profileLink", profile.profileUrl));
63     }
64 }