diff options
author | 2014-01-27 06:21:29 +0700 | |
---|---|---|
committer | 2014-01-27 06:21:29 +0700 | |
commit | 36c8ec33c09fbfd0f82a5a4121ef63ed1ec77457 (patch) | |
tree | b6f33bc1a14a2ab8dbde89a2908a1243d741cc76 /src/java/com/juick/http/www/Home.java | |
parent | f1e3d22f610640c9096ad182503ebb3a9f850f2b (diff) |
Popular on the main page
Diffstat (limited to 'src/java/com/juick/http/www/Home.java')
-rw-r--r-- | src/java/com/juick/http/www/Home.java | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/src/java/com/juick/http/www/Home.java b/src/java/com/juick/http/www/Home.java index 029f76ad..5ef43858 100644 --- a/src/java/com/juick/http/www/Home.java +++ b/src/java/com/juick/http/www/Home.java @@ -17,10 +17,8 @@ */ package com.juick.http.www; -import com.juick.json.Users; import com.juick.server.AdsQueries; import com.juick.server.MessagesQueries; -import com.juick.server.PMQueries; import java.io.IOException; import java.io.PrintWriter; import java.net.URLEncoder; @@ -63,24 +61,28 @@ public class Home { if (paramSearch != null) { title = rb.getString("Search") + ": " + Utils.encodeHTML(paramSearch); mids = MessagesQueries.getSearch(sql, sqlSearch, Utils.encodeSphinx(paramSearch), paramBefore); - } else if (paramShow == null || paramShow.equals("my")) { + } else if (paramShow == null || paramShow.equals("top")) { + title = rb.getString("Popular"); + mids = MessagesQueries.getPopular(sql, paramBefore); + } else if (paramShow.equals("my") && visitor != null) { title = rb.getString("My feed"); mids = MessagesQueries.getMyFeed(sql, visitor.UID, paramBefore); - } else if (paramShow.equals("private")) { + } else if (paramShow.equals("private") && visitor != null) { title = rb.getString("Private"); mids = MessagesQueries.getPrivate(sql, visitor.UID, paramBefore); - } else if (paramShow.equals("discuss")) { + } else if (paramShow.equals("discuss") && visitor != null) { title = rb.getString("Discussions"); mids = MessagesQueries.getDiscussions(sql, visitor.UID, paramBefore); - } else if (paramShow.equals("recommended")) { + } else if (paramShow.equals("recommended") && visitor != null) { title = rb.getString("Recommended"); mids = MessagesQueries.getRecommended(sql, visitor.UID, paramBefore); - } else if (paramShow.equals("top")) { - title = rb.getString("Popular"); - mids = MessagesQueries.getPopular(sql, paramBefore); } else if (paramShow.equals("all")) { title = rb.getString("Last messages"); - mids = MessagesQueries.getAll(sql, visitor.UID, paramBefore); + if (visitor != null) { + mids = MessagesQueries.getAll(sql, visitor.UID, paramBefore); + } else { + mids = MessagesQueries.getAll(sql, 0, paramBefore); + } } else { response.sendError(404); return; @@ -92,16 +94,6 @@ public class Home { PageTemplates.pageHead(out, title, null); PageTemplates.pageNavigation(out, locale, visitor, null); - ArrayList<com.juick.User> lastconv = PMQueries.getPMLastConversationsUsers(sql, visitor.UID, 10); - String lastConvJSON = Users.arrayToString(lastconv); - - out.println("<script type=\"text/javascript\">"); - out.println("var hash='" + Utils.getCookie(request, "hash") + "';"); - out.println("var user_id=" + visitor.UID + ";"); - out.println("var user_name='" + visitor.UName + "';"); - out.println("var lastConversations=" + lastConvJSON + ";"); - out.println("</script>"); - out.println("<div id=\"topwrapper\">"); out.println("<div id=\"wrapper\">"); out.println("<div id=\"content\">"); @@ -112,7 +104,7 @@ public class Home { if (mids.size() > 0) { int ad_mid = 0; - if (paramShow == null || paramShow.equals("top") || paramShow.equals("all")) { + if (visitor != null && (paramShow == null || paramShow.equals("top") || paramShow.equals("all"))) { ad_mid = AdsQueries.getAdMID(sql, visitor.UID); if (ad_mid > 0 && mids.indexOf(ad_mid) == -1) { |