r7062 - in dumbhippo/trunk/server/src/com/dumbhippo: persistence server/impl server/views



Author: marinaz
Date: 2007-12-14 16:26:04 -0600 (Fri, 14 Dec 2007)
New Revision: 7062

Modified:
   dumbhippo/trunk/server/src/com/dumbhippo/persistence/ExternalAccount.java
   dumbhippo/trunk/server/src/com/dumbhippo/server/impl/FacebookTrackerBean.java
   dumbhippo/trunk/server/src/com/dumbhippo/server/views/PersonView.java
Log:
Display an accounts ribbon in the Facebook profile page box.

Modified: dumbhippo/trunk/server/src/com/dumbhippo/persistence/ExternalAccount.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/persistence/ExternalAccount.java	2007-12-14 21:42:54 UTC (rev 7061)
+++ dumbhippo/trunk/server/src/com/dumbhippo/persistence/ExternalAccount.java	2007-12-14 22:26:04 UTC (rev 7062)
@@ -273,4 +273,24 @@
 	public boolean hasAccountInfo() {
 		return accountType.getHasAccountInfo(handle, extra);
 	}
+	
+	public static int compare(ExternalAccount first, ExternalAccount second) {
+		// Equality should be impossible, someone should not have two of the same account.
+		// But we'll put it here in case the java sort algorithm somehow needs it (tough to imagine)
+		if (first.getAccountType() == second.getAccountType())
+			return 0;
+		
+		// We want "my website" first, "blog" second, then everything alphabetized by the human-readable name.
+		
+		if (first.getAccountType() == ExternalAccountType.WEBSITE)
+			return -1;
+		if (second.getAccountType() == ExternalAccountType.WEBSITE)
+			return 1;
+		if (first.getAccountType() == ExternalAccountType.BLOG)
+			return -1;
+		if (second.getAccountType() == ExternalAccountType.BLOG)
+			return 1;				
+		
+		return String.CASE_INSENSITIVE_ORDER.compare(first.getSiteName(), second.getSiteName());
+	}
 }

Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/impl/FacebookTrackerBean.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/impl/FacebookTrackerBean.java	2007-12-14 21:42:54 UTC (rev 7061)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/impl/FacebookTrackerBean.java	2007-12-14 22:26:04 UTC (rev 7062)
@@ -1,6 +1,8 @@
 package com.dumbhippo.server.impl;
 
 import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.Date;
 import java.util.HashSet;
 import java.util.List;
@@ -49,6 +51,7 @@
 import com.dumbhippo.server.blocks.BlockView;
 import com.dumbhippo.server.util.EJBUtil;
 import com.dumbhippo.server.views.AnonymousViewpoint;
+import com.dumbhippo.server.views.ExternalAccountView;
 import com.dumbhippo.server.views.SystemViewpoint;
 import com.dumbhippo.server.views.UserViewpoint;
 import com.dumbhippo.services.FacebookPhotoDataView;
@@ -592,10 +595,43 @@
 	
 	private String createFbmlForUser(Account account) {
 		User user = account.getOwner();
+		UserViewpoint viewpoint = new UserViewpoint(user, Site.MUGSHOT);
 		StringBuilder fbmlSb = new StringBuilder("");
 		fbmlSb.append("<fb:visible-to-owner><fb:subtitle>" +
 		              "<a href='http://apps.facebook.com/mugshot'>Edit Accounts</a>" +
 		              "</fb:subtitle></fb:visible-to-owner>");
+		
+		// add the accounts ribbon
+		Set<ExternalAccountView> allAccounts = externalAccounts.getExternalAccountViews(viewpoint, user);
+        externalAccounts.loadThumbnails(viewpoint, allAccounts);
+        List<ExternalAccountView> lovedAccounts = new ArrayList<ExternalAccountView>();
+		for (ExternalAccountView a : allAccounts) {
+			// This will include the Website account which there is no way to specify
+			// on the Facebook application page, but that's ok.
+			// Let's exclude Facebook account itself, since it would take the user to the page
+			// they are already viewing!
+			if (a.getExternalAccount().isLovedAndEnabled() && !a.getExternalAccountType().equals(ExternalAccountType.FACEBOOK))
+				lovedAccounts.add(a);
+		}
+	
+		Collections.sort(lovedAccounts, new Comparator<ExternalAccountView>() {
+			public int compare(ExternalAccountView first, ExternalAccountView second) {
+				return ExternalAccount.compare(first.getExternalAccount(), second.getExternalAccount());	
+			}			
+		});
+		
+		fbmlSb.append("<div>");
+		for (ExternalAccountView a : lovedAccounts) {
+            String imageTitle = a.getExternalAccount().getSiteName();
+            if (a.getExternalAccount().getLinkText().length() >0 )
+            	imageTitle = imageTitle + ": " + a.getExternalAccount().getLinkText();
+          			
+			fbmlSb.append("<a target='_blank' href='" + a.getLink() + "'>" +
+					    "<img src='http://mugshot.org/images3/"; + a.getIconName() + "' title='" + imageTitle + "' style='width: 16; height: 16; border: none; margin-right: 3px;'/>" +
+					    "</a>");
+		}		
+		fbmlSb.append("</div>");
+
 		Pageable<BlockView> pageableMugshot = new Pageable<BlockView>("mugshot");
 		pageableMugshot.setPosition(0);
 		pageableMugshot.setInitialPerPage(INITIAL_BLOCKS_PER_PAGE);
@@ -613,7 +649,7 @@
 		}
 		// display a note if there was no activity
 		if (pageableMugshot.getResults().size() == 0) {
-			fbmlSb.append("<div>Once there are new updates, they will show up here.</div>");
+			fbmlSb.append("<div style='margin-bottom:10px;'>Once there are new updates, they will show up here.</div>");
 		}
 		if (account.getHasAcceptedTerms()) {
 		    fbmlSb.append("<a target='_blank' style='font-size: 12px; font-weight: bold; margin-top: 10px;' href='" + getAbsoluteUrl("/person?who=" + user.getId().toString()) + "'>" +

Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/views/PersonView.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/views/PersonView.java	2007-12-14 21:42:54 UTC (rev 7061)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/views/PersonView.java	2007-12-14 22:26:04 UTC (rev 7062)
@@ -23,7 +23,7 @@
 import com.dumbhippo.persistence.AimResource;
 import com.dumbhippo.persistence.Contact;
 import com.dumbhippo.persistence.EmailResource;
-import com.dumbhippo.persistence.ExternalAccountType;
+import com.dumbhippo.persistence.ExternalAccount;
 import com.dumbhippo.persistence.FacebookResource;
 import com.dumbhippo.persistence.Resource;
 import com.dumbhippo.persistence.Sentiment;
@@ -338,27 +338,9 @@
 			}			
 		}
 		Collections.sort(list, new Comparator<ExternalAccountView>() {
-
 			public int compare(ExternalAccountView first, ExternalAccountView second) {
-				// Equality should be impossible, someone should not have two of the same account.
-				// But we'll put it here in case the java sort algorithm somehow needs it (tough to imagine)
-				if (first.getExternalAccount().getAccountType() == second.getExternalAccount().getAccountType())
-					return 0;
-				
-				// We want "my website" first, "blog" second, then everything alphabetized by the human-readable name.
-				
-				if (first.getExternalAccount().getAccountType() == ExternalAccountType.WEBSITE)
-					return -1;
-				if (second.getExternalAccount().getAccountType() == ExternalAccountType.WEBSITE)
-					return 1;
-				if (first.getExternalAccount().getAccountType() == ExternalAccountType.BLOG)
-					return -1;
-				if (second.getExternalAccount().getAccountType() == ExternalAccountType.BLOG)
-					return 1;				
-				
-				return String.CASE_INSENSITIVE_ORDER.compare(first.getExternalAccount().getSiteName(), second.getExternalAccount().getSiteName());
-			}
-			
+				return ExternalAccount.compare(first.getExternalAccount(), second.getExternalAccount());	
+			}			
 		});
 		return new ListBean<ExternalAccountView>(list);
 	}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]