From f723832791490ad342c7ab1190d1f16dce84ade9 Mon Sep 17 00:00:00 2001 From: Ugnich Anton Date: Mon, 21 Oct 2013 04:23:40 +0700 Subject: New main page --- src/java/com/juick/http/www/Blogs.java | 3 +- src/java/com/juick/http/www/Login.java | 168 +++++++++++++++++++++---- src/java/com/juick/http/www/Main.java | 21 +++- src/java/com/juick/http/www/PageTemplates.java | 2 +- 4 files changed, 162 insertions(+), 32 deletions(-) (limited to 'src/java/com') diff --git a/src/java/com/juick/http/www/Blogs.java b/src/java/com/juick/http/www/Blogs.java index 89113def..cf58ed4f 100644 --- a/src/java/com/juick/http/www/Blogs.java +++ b/src/java/com/juick/http/www/Blogs.java @@ -42,7 +42,7 @@ import javax.servlet.http.HttpServletResponse; */ public class Blogs { - protected void doGet(Connection sql, Connection sqlSearch, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + protected void doGet(Connection sql, Connection sqlSearch, HttpServletRequest request, HttpServletResponse response, com.juick.User visitor) throws ServletException, IOException { String paramTagStrQuery = request.getParameter("tag"); if (paramTagStrQuery != null) { String url = "/tag/" + URLEncoder.encode(paramTagStrQuery, "UTF-8"); @@ -53,7 +53,6 @@ public class Blogs { Utils.sendPermanentRedirect(response, url); } - com.juick.User visitor = Utils.getVisitorUser(sql, request); Locale locale = request.getLocale(); ResourceBundle rb = ResourceBundle.getBundle("Blogs", locale); diff --git a/src/java/com/juick/http/www/Login.java b/src/java/com/juick/http/www/Login.java index f693b97c..329cb767 100644 --- a/src/java/com/juick/http/www/Login.java +++ b/src/java/com/juick/http/www/Login.java @@ -44,37 +44,157 @@ public class Login { Locale locale = request.getLocale(); ResourceBundle rb = ResourceBundle.getBundle("Login", locale); + ResourceBundle rbg = ResourceBundle.getBundle("Global", locale); response.setContentType("text/html; charset=UTF-8"); PrintWriter out = response.getWriter(); try { - PageTemplates.pageHead(out, rb.getString("Login"), ""); - PageTemplates.pageNavigation(out, locale, visitor, null); - - out.println("
"); - out.println("
"); - out.println("
"); - out.println("

\"Facebook\"/" + rb.getString("Login Facebook") + "

"); - out.println("

\"Connect

"); - out.println("
"); - out.println("

\"VK\"/" + rb.getString("Login VK") + "

"); - out.println("

" + rb.getString("Login VK text") + "

"); - out.println("
"); - out.println("

\"XMPP\"/" + rb.getString("Login XMPP") + "

"); - out.println("

" + rb.getString("XMPP instructions") + "

"); - out.println("
"); - out.println("

" + rb.getString("Have Juick") + "

"); - out.println("
"); - out.println("

" + rb.getString("Username") + ":

"); - out.println("

" + rb.getString("Password") + ":

"); - out.println("

"); - out.println("
"); + out.println(""); + out.println(""); + out.println(""); + out.println("Juick"); + out.println(""); + out.println(""); + out.println(""); + out.println(""); + + out.println(""); + + out.println(""); + + out.println(""); + + if (PageTemplates.sape != null) { + String links = PageTemplates.sape.getPageLinks(request.getRequestURI(), request.getCookies()).render(); + if (links != null && !links.isEmpty()) { + out.println("
" + rbg.getString("Sponsored by") + ": " + links + "
"); + } + } + + out.println("
"); + out.println(" " + rb.getString("SignUp") + ":"); + out.println(" "); + out.println(" "); + out.println("
XMPP"); + out.println("
" + rb.getString("XMPPLogin") + " juick@juick.com
"); + out.println("
"); out.println("
"); + out.println("
" + rb.getString("HaveAccount") + ""); + out.println("
"); + out.println(""); + out.println(""); + out.println(""); + out.println("
"); out.println("
"); - out.println("
"); // topwrapper - PageTemplates.pageFooter(request, out, locale, visitor, false); - PageTemplates.pageEnd(out); + out.println(""); + out.println(""); } finally { out.close(); } diff --git a/src/java/com/juick/http/www/Main.java b/src/java/com/juick/http/www/Main.java index 07796fda..4c6e310b 100644 --- a/src/java/com/juick/http/www/Main.java +++ b/src/java/com/juick/http/www/Main.java @@ -110,17 +110,26 @@ public class Main extends HttpServlet { String uri = request.getRequestURI(); if (uri.equals("/")) { - blogs.doGet(sql, sqlSearch, request, response); + com.juick.User visitor = Utils.getVisitorUser(sql, request); + if (request.getQueryString() == null) { + if (visitor == null) { + login.doGetLoginForm(sql, request, response); + } else { + blogs.doGet(sql, sqlSearch, request, response, visitor); + } + } else { + blogs.doGet(sql, sqlSearch, request, response, visitor); + } } else if (uri.equals("/post")) { com.juick.User visitor = Utils.getVisitorUser(sql, request); if (visitor != null) { pagesNewMessage.doGetNewMessage(sql, request, response, visitor); } else { - login.doGetLoginForm(sql, request, response); + Utils.sendTemporaryRedirect(response, "/"); } } else if (uri.equals("/login")) { if (request.getQueryString() == null) { - login.doGetLoginForm(sql, request, response); + Utils.sendPermanentRedirect(response, "/"); } else { login.doGetLogin(sql, request, response); } @@ -139,9 +148,11 @@ public class Main extends HttpServlet { } else if (uri.startsWith("/help/")) { help.doGetHelp(sql, request, response); } else if (uri.startsWith("/tag/")) { - blogs.doGet(sql, sqlSearch, request, response); + com.juick.User visitor = Utils.getVisitorUser(sql, request); + blogs.doGet(sql, sqlSearch, request, response, visitor); } else if (uri.startsWith("/places/")) { - blogs.doGet(sql, sqlSearch, request, response); + com.juick.User visitor = Utils.getVisitorUser(sql, request); + blogs.doGet(sql, sqlSearch, request, response, visitor); } else if (uri.matches("^/\\d+$")) { String strID = request.getRequestURI().substring(1); int mid = 0; diff --git a/src/java/com/juick/http/www/PageTemplates.java b/src/java/com/juick/http/www/PageTemplates.java index ba19c40b..f83713c9 100644 --- a/src/java/com/juick/http/www/PageTemplates.java +++ b/src/java/com/juick/http/www/PageTemplates.java @@ -83,7 +83,7 @@ public class PageTemplates { out.println("
  • \""
  • "); out.println("
  • "); } else { - out.println("
  • " + rb.getString("Login") + "
  • "); + out.println("
  • " + rb.getString("Login") + "
  • "); } out.println(""); out.println("
    "); -- cgit v1.2.3