Skip to content

Commit

Permalink
Showcase Twitter friends and followers
Browse files Browse the repository at this point in the history
  • Loading branch information
habuma committed Apr 23, 2011
1 parent 2ce7ce7 commit 3431555
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 14 deletions.
@@ -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";
}

}
Expand Up @@ -6,6 +6,8 @@
<ul class="menu">
<li><a href="<c:url value="/twitter"/>">User Profile</a></li>
<li><a href="<c:url value="/twitter/timeline"/>">Timeline</a></li>
<li><a href="<c:url value="/twitter/friends"/>">Friends</a></li>
<li><a href="<c:url value="/twitter/followers"/>">Followers</a></li>
<li><a href="<c:url value="/twitter/messages"/>">Messages</a></li>
</ul>

Expand Down
@@ -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>
Expand Up @@ -29,13 +29,13 @@


<div class="feed">
<ul class="feedList">
<ul class="imagedList">
<c:forEach items="${directMessages}" var="dm">
<li class="post">
<div class="postImage">
<li class="imagedItem">
<div class="image">
<c:if test="${not empty dm.sender.profileImageUrl}"><img src="<c:out value="${dm.sender.profileImageUrl}"/>" align="left"/></c:if>
</div>
<div class="postContent">
<div class="content">
<strong><a href="http://twitter.com/<c:out value="${dm.sender.screenName}" />"><c:out value="${dm.sender.screenName}" /></a></strong><br/>
<span class="dmRecipient">to <c:out value="${dm.recipient.screenName}"/></span><br/>
<c:out value="${dm.text}" /><br/>
Expand Down
Expand Up @@ -11,6 +11,10 @@
<put-attribute name="content" value="/WEB-INF/views/twitter/timeline.jsp" />
</definition>

<definition name="twitter/friends" extends="page">
<put-attribute name="content" value="/WEB-INF/views/twitter/friends.jsp" />
</definition>

<definition name="twitter/messages" extends="page">
<put-attribute name="content" value="/WEB-INF/views/twitter/messages.jsp" />
</definition>
Expand Down
Expand Up @@ -29,13 +29,13 @@
</ul>

<div class="feed">
<ul class="feedList">
<ul class="imagedList">
<c:forEach items="${timeline}" var="tweet">
<li class="post">
<div class="postImage">
<li class="imagedItem">
<div class="image">
<c:if test="${not empty tweet.profileImageUrl}"><img src="<c:out value="${tweet.profileImageUrl}"/>" align="left"/></c:if>
</div>
<div class="postContent">
<div class="content">
<strong><a href="http://twitter.com/<c:out value="${tweet.fromUser}" />"><c:out value="${tweet.fromUser}" /></a></strong><br/>
<c:out value="${tweet.text}" /><br/>
<span class="postTime"><c:out value="${tweet.createdAt}"/></span>
Expand Down
12 changes: 6 additions & 6 deletions spring-social-showcase/src/main/webapp/resources/page.css
Expand Up @@ -39,31 +39,31 @@ div.feed {
width: 600px;
}

ul.feedList li {
ul.imagedList li {
padding-top:10px;
padding-bottom:10px;
list-style: none;
border-top: 1px dotted lightgrey;
}

ul.feedList li:first-child {
ul.imagedlist li:first-child {
border-top: none;
}

li.post div.postImage {
li.imagedItem div.image {
float: left;
}

li.post div.postContent {
li.imagedItem div.content {
font-size: 11pt;
margin-left: 70px;
}

li.post div.postContent a {
li.imagedItem div.content a {
text-decoration: none;
}

li.post div.postContent a:hover {
li.imagedItem div.content a:hover {
text-decoration: underline;
}

Expand Down

0 comments on commit 3431555

Please sign in to comment.