diff options
author | Ugnich Anton | 2014-01-27 06:21:29 +0700 |
---|---|---|
committer | Ugnich Anton | 2014-01-27 06:21:29 +0700 |
commit | 36c8ec33c09fbfd0f82a5a4121ef63ed1ec77457 (patch) | |
tree | b6f33bc1a14a2ab8dbde89a2908a1243d741cc76 /src/java/com | |
parent | f1e3d22f610640c9096ad182503ebb3a9f850f2b (diff) |
Popular on the main page
Diffstat (limited to 'src/java/com')
-rw-r--r-- | src/java/com/juick/http/www/Home.java | 34 | ||||
-rw-r--r-- | src/java/com/juick/http/www/Main.java | 12 | ||||
-rw-r--r-- | src/java/com/juick/http/www/PageTemplates.java | 8 |
3 files changed, 21 insertions, 33 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) { diff --git a/src/java/com/juick/http/www/Main.java b/src/java/com/juick/http/www/Main.java index 998fb4f3..59065341 100644 --- a/src/java/com/juick/http/www/Main.java +++ b/src/java/com/juick/http/www/Main.java @@ -143,28 +143,24 @@ public class Main extends HttpServlet implements Stream.StreamListener { if (uri.equals("/")) { com.juick.User visitor = Utils.getVisitorUser(sql, request, response); - if (visitor == null) { - login.doGetLoginForm(sql, request, response); - } else { - home.doGet(sql, sqlSearch, request, response, visitor); - } + home.doGet(sql, sqlSearch, request, response, visitor); } else if (uri.equals("/post")) { com.juick.User visitor = Utils.getVisitorUser(sql, request, response); if (visitor != null) { pagesNewMessage.doGetNewMessage(sql, request, response, visitor); } else { - Utils.sendTemporaryRedirect(response, "/"); + Utils.sendTemporaryRedirect(response, "/login"); } } else if (uri.equals("/login")) { if (request.getQueryString() == null) { - Utils.sendPermanentRedirect(response, "/"); + login.doGetLoginForm(sql, request, response); } else { login.doGetLogin(sql, request, response); } } else if (uri.startsWith("/pm/")) { com.juick.User visitor = Utils.getVisitorUser(sql, request, response); if (visitor == null) { - login.doGetLoginForm(sql, request, response); + Utils.sendTemporaryRedirect(response, "/login"); } else { if (uri.equals("/pm/inbox")) { pm.doGetInbox(sql, request, response, visitor); diff --git a/src/java/com/juick/http/www/PageTemplates.java b/src/java/com/juick/http/www/PageTemplates.java index 73910321..16a00d24 100644 --- a/src/java/com/juick/http/www/PageTemplates.java +++ b/src/java/com/juick/http/www/PageTemplates.java @@ -74,7 +74,7 @@ public class PageTemplates { out.println("<div id=\"hwrapper\">"); out.println("<ul id=\"header\">"); if (user != null) { - out.println(" <li><a href=\"/\"><div class=\"head-ico\" id=\"hi-home\"></div><label>" + rb.getString("Home") + "</label></a></li>"); + out.println(" <li><a href=\"/?show=my\"><div class=\"head-ico\" id=\"hi-home\"></div><label>" + rb.getString("Home") + "</label></a></li>"); } else { out.println(" <li><a href=\"/\"><div class=\"head-ico\" id=\"hi-logo\"></div></a></li>"); } @@ -91,7 +91,7 @@ public class PageTemplates { out.println(" <li class=\"right\"><a href=\"/" + user.UName + "\" class=\"wide\"><img src=\"//i.juick.com/as/" + user.UID + ".png\" alt=\"" + user.UName + "\"/><label>" + user.UName + "</label></a></li>"); out.println(" <li class=\"right\"><a href=\"/post\" class=\"wide\"><div class=\"head-ico\" id=\"hi-post\"></div><label>" + rb.getString("Post") + "</label></a></li>"); } else { - out.println(" <li class=\"right\"><a href=\"/\" class=\"wide\" rel=\"nofollow\">" + rb.getString("Login") + "</a></li>"); + out.println(" <li class=\"right\"><a href=\"/login\" class=\"wide\" rel=\"nofollow\">" + rb.getString("Login") + "</a></li>"); } out.println("</ul>"); out.println("</div>"); @@ -180,12 +180,12 @@ public class PageTemplates { out.println("<div id=\"column\" class=\"abs\">"); out.println(" <ul>"); if (visitor != null) { - out.println(" <li><a href=\"/\">" + rb.getString("My feed") + "</a></li>"); + out.println(" <li><a href=\"/?show=my\">" + rb.getString("My feed") + "</a></li>"); out.println(" <li><a href=\"/pm/inbox\">" + rb.getString("Private") + "</a> ยท <a href=\"/pm/sent\">" + rb.getString("Private sent") + "</a></li>"); out.println(" <li><a href=\"/?show=discuss\">" + rb.getString("Discussions") + "</a></li>"); out.println(" <li><a href=\"/?show=recommended\">" + rb.getString("Recommended") + "</a></li>"); } - out.println(" <li class=\"margtop\"><a href=\"/?show=top\">" + rb.getString("Popular") + "</a></li>"); + out.println(" <li class=\"margtop\"><a href=\"/\">" + rb.getString("Popular") + "</a></li>"); out.println(" <li><a href=\"/?show=all\">" + rb.getString("All messages") + "</a></li>"); out.println(" </ul>"); out.println(" <hr/>"); |