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/Login.properties | 14 +-- src/java/Login_ru.properties | 14 +-- 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 +- 6 files changed, 170 insertions(+), 52 deletions(-) diff --git a/src/java/Login.properties b/src/java/Login.properties index f8b3919b..3275155e 100644 --- a/src/java/Login.properties +++ b/src/java/Login.properties @@ -1,12 +1,6 @@ -# To change this template, choose Tools | Templates -# and open the template in the editor. - -Login=Login +SignUp=Sign up +VKontakte=VKontakte +XMPPLogin=Send LOGIN to +HaveAccount=Already have an account? Username=Username Password=Password -Login\ Facebook=Login with Facebook -Login\ VK=Login with VKontakte -Login\ VK\ text=Login -Login\ XMPP=Login with Jabber/XMPP -XMPP\ instructions=Send LOGIN from your Jabber/XMPP account to juick@juick.com. -Have\ Juick=Have a Juick account? diff --git a/src/java/Login_ru.properties b/src/java/Login_ru.properties index 6d5922e4..b3acd0c7 100644 --- a/src/java/Login_ru.properties +++ b/src/java/Login_ru.properties @@ -1,12 +1,6 @@ -# To change this template, choose Tools | Templates -# and open the template in the editor. - -Login=\u0412\u0445\u043e\u0434 +SignUp=\u0417\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f +VKontakte=\u0412\u041a\u043e\u043d\u0442\u0430\u043a\u0442\u0435 +XMPPLogin=\u041e\u0442\u043f\u0440\u0430\u0432\u044c\u0442\u0435 LOGIN \u043d\u0430 +HaveAccount=\u0423\u0436\u0435 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b? Username=\u0418\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f Password=\u041f\u0430\u0440\u043e\u043b\u044c -Login\ Facebook=\u0412\u043e\u0439\u0442\u0438 \u0447\u0435\u0440\u0435\u0437 Facebook -Login\ VK=\u0412\u043e\u0439\u0442\u0438 \u0447\u0435\u0440\u0435\u0437 \u0412\u041a\u043e\u043d\u0442\u0430\u043a\u0442\u0435 -Login\ VK\ text=\u0412\u043e\u0439\u0442\u0438 -Login\ XMPP=\u0412\u043e\u0439\u0442\u0438 \u0447\u0435\u0440\u0435\u0437 Jabber/XMPP -XMPP\ instructions=\u041e\u0442\u043f\u0440\u0430\u0432\u044c\u0442\u0435 LOGIN \u0441 \u0432\u0430\u0448\u0435\u0433\u043e \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0430 Jabber/XMPP \u043d\u0430 juick@juick.com. -Have\ Juick=\u0423\u0436\u0435 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043d\u0430 Juick? 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