forked from spring-attic/spring-social-samples
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showcase Twitter friends and followers
- Loading branch information
Showing
7 changed files
with
94 additions
and
14 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
...e/src/main/java/org/springframework/social/showcase/twitter/TwitterFriendsController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright 2011 the original author or authors. | ||
* | ||
* 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 org.springframework.social.showcase.twitter; | ||
|
||
import javax.inject.Inject; | ||
|
||
import org.springframework.social.twitter.api.TwitterApi; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.ui.Model; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
|
||
@Controller | ||
public class TwitterFriendsController { | ||
|
||
private final TwitterApi twitterApi; | ||
|
||
@Inject | ||
public TwitterFriendsController(TwitterApi twitterApi) { | ||
this.twitterApi = twitterApi; | ||
} | ||
|
||
@RequestMapping(value="/twitter/friends", method=RequestMethod.GET) | ||
public String friends(Model model) { | ||
model.addAttribute("profiles", twitterApi.friendOperations().getFriends()); | ||
return "twitter/friends"; | ||
} | ||
|
||
@RequestMapping(value="/twitter/followers", method=RequestMethod.GET) | ||
public String followers(Model model) { | ||
model.addAttribute("profiles", twitterApi.friendOperations().getFollowers()); | ||
return "twitter/friends"; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
spring-social-showcase/src/main/webapp/WEB-INF/views/twitter/friends.jsp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> | ||
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> | ||
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="sf" %> | ||
<%@ page session="false" %> | ||
|
||
<script src="http://platform.twitter.com/anywhere.js?id=7yWLgCOuQhIpPyffm0o2Vg&v=1" type="text/javascript"></script> | ||
<script type="text/javascript"> | ||
twttr.anywhere(function (T) { | ||
T(".feed").linkifyUsers(); | ||
}); | ||
</script> | ||
|
||
<h3>Your Twitter Friends</h3> | ||
|
||
<ul class="imagedList"> | ||
<c:forEach items="${profiles}" var="profile"> | ||
<li class="imagedItem"> | ||
<div class="image"> | ||
<c:if test="${not empty profile.profileImageUrl}"><img src="<c:out value="${profile.profileImageUrl}"/>" width="48" height="48" align="left"/></c:if> | ||
</div> | ||
<div class="content"> | ||
<p><a href="http://twitter.com/<c:out value="${profile.screenName}" />"><c:out value="${profile.screenName}"/></a></p> | ||
</div> | ||
</li> | ||
</c:forEach> | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters