aboutsummaryrefslogtreecommitdiff
path: root/src/java
diff options
context:
space:
mode:
authorGravatar Ugnich Anton2014-06-17 16:29:44 +0700
committerGravatar Ugnich Anton2014-06-17 16:29:44 +0700
commit3ba6237fa51d77bd6da0557a19ca729e70d76d1c (patch)
treeb39e06f9585f10b78a545179ff9ae5a7fcf3beb9 /src/java
parent186016ac2e03c10497e30c9a651dc9757108b489 (diff)
- isMobileRequest;
- Dev * blockquote -> q
Diffstat (limited to 'src/java')
-rw-r--r--src/java/com/juick/http/www/Dev.java101
-rw-r--r--src/java/com/juick/http/www/Discover.java11
-rw-r--r--src/java/com/juick/http/www/Home.java12
-rw-r--r--src/java/com/juick/http/www/Main.java8
-rw-r--r--src/java/com/juick/http/www/NewMessage.java10
-rw-r--r--src/java/com/juick/http/www/PM.java13
-rw-r--r--src/java/com/juick/http/www/PageTemplates.java8
-rw-r--r--src/java/com/juick/http/www/User.java44
-rw-r--r--src/java/com/juick/http/www/UserThread.java10
-rw-r--r--src/java/com/juick/http/www/Utils.java5
10 files changed, 25 insertions, 197 deletions
diff --git a/src/java/com/juick/http/www/Dev.java b/src/java/com/juick/http/www/Dev.java
deleted file mode 100644
index d51ef95f..00000000
--- a/src/java/com/juick/http/www/Dev.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Juick
- * Copyright (C) 2008-2011, Ugnich Anton
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.juick.http.www;
-
-import com.juick.server.MessagesQueries;
-import com.juick.server.TagQueries;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.net.URLDecoder;
-import java.net.URLEncoder;
-import java.sql.Connection;
-import java.util.ArrayList;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-/**
- *
- * @author Ugnich Anton
- */
-public class Dev {
-
- protected void doGet(Connection sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- com.juick.User visitor = Utils.getVisitorUser(sql, request, response);
-
- String paramTagStr = URLDecoder.decode(request.getRequestURI().substring(5), "UTF-8");
- com.juick.Tag paramTag = TagQueries.getTag(sql, paramTagStr, false);
- if (paramTag == null) {
- Errors.doGet404(sql, request, response);
- return;
- } else if (!paramTag.Name.equals(paramTagStr)) {
- String url = "/tag/" + URLEncoder.encode(paramTag.Name, "UTF-8");
- if (request.getQueryString() != null) {
- url += "?" + request.getQueryString();
- }
- Utils.sendPermanentRedirect(response, url);
- return;
- }
-
- int paramBefore = 0;
- String paramBeforeStr = request.getParameter("before");
- if (paramBeforeStr != null) {
- try {
- paramBefore = Integer.parseInt(paramBeforeStr);
- } catch (NumberFormatException e) {
- }
- }
-
- int visitor_uid = visitor != null ? visitor.UID : 0;
-
- String title = "*" + Utils.encodeHTML(paramTag.Name);
- ArrayList<Integer> mids = MessagesQueries.getTag(sql, paramTag.TID, visitor_uid, paramBefore, (visitor == null) ? 40 : 20);
-
- response.setContentType("text/html; charset=UTF-8");
- PrintWriter out = response.getWriter();
- try {
- PageTemplates.pageHead(out, title, null);
-
- if (!Utils.isMobileRequest(request)) {
- PageTemplates.pageNavigation(out, visitor, null);
- PageTemplates.pageHomeColumn(out, sql, visitor);
- }
-
- out.println("<section id=\"content\">");
-
- if (mids.size() > 0) {
- PageTemplates.printMessages(out, sql, null, mids, visitor, visitor == null ? 2 : 3, 0);
- }
-
- if (mids.size() >= 20) {
- String nextpage = "/tag/" + URLEncoder.encode(paramTag.Name, "UTF-8") + "?before=" + mids.get(mids.size() - 1);
- out.println("<p class=\"page\"><a href=\"" + nextpage + "\">Читать дальше →</a></p>");
- }
-
- out.println("</section>");
-
- if (!Utils.isMobileRequest(request)) {
- PageTemplates.pageFooter(request, out, visitor, true);
- }
-
- PageTemplates.pageEnd(out);
- } finally {
- out.close();
- }
- }
-}
diff --git a/src/java/com/juick/http/www/Discover.java b/src/java/com/juick/http/www/Discover.java
index 08930e27..dcc0c441 100644
--- a/src/java/com/juick/http/www/Discover.java
+++ b/src/java/com/juick/http/www/Discover.java
@@ -70,11 +70,8 @@ public class Discover {
PrintWriter out = response.getWriter();
try {
PageTemplates.pageHead(out, title, null);
-
- if (!Utils.isMobileRequest(request)) {
- PageTemplates.pageNavigation(out, visitor, null);
- PageTemplates.pageHomeColumn(out, sql, visitor);
- }
+ PageTemplates.pageNavigation(out, visitor, null);
+ PageTemplates.pageHomeColumn(out, sql, visitor);
out.println("<section id=\"content\">");
@@ -89,9 +86,7 @@ public class Discover {
out.println("</section>");
- if (!Utils.isMobileRequest(request)) {
- PageTemplates.pageFooter(request, out, visitor, true);
- }
+ PageTemplates.pageFooter(request, out, visitor, true);
PageTemplates.pageEnd(out);
} finally {
diff --git a/src/java/com/juick/http/www/Home.java b/src/java/com/juick/http/www/Home.java
index 3931fd24..db8b0b2c 100644
--- a/src/java/com/juick/http/www/Home.java
+++ b/src/java/com/juick/http/www/Home.java
@@ -94,11 +94,8 @@ public class Home {
PrintWriter out = response.getWriter();
try {
PageTemplates.pageHead(out, title, null);
-
- if (!Utils.isMobileRequest(request)) {
- PageTemplates.pageNavigation(out, visitor, paramSearch);
- PageTemplates.pageHomeColumn(out, sql, visitor);
- }
+ PageTemplates.pageNavigation(out, visitor, paramSearch);
+ PageTemplates.pageHomeColumn(out, sql, visitor);
out.println("<section id=\"content\">");
@@ -153,10 +150,7 @@ public class Home {
out.println("</section>");
- if (!Utils.isMobileRequest(request)) {
- PageTemplates.pageFooter(request, out, visitor, true);
- }
-
+ PageTemplates.pageFooter(request, out, visitor, true);
PageTemplates.pageEnd(out);
} finally {
out.close();
diff --git a/src/java/com/juick/http/www/Main.java b/src/java/com/juick/http/www/Main.java
index a81c1ba1..ec7c4e1e 100644
--- a/src/java/com/juick/http/www/Main.java
+++ b/src/java/com/juick/http/www/Main.java
@@ -49,7 +49,6 @@ public class Main extends HttpServlet implements Stream.StreamListener {
Stream xmpp;
Home home = new Home();
Discover discover = new Discover();
- Dev dev = new Dev();
PM pm = new PM();
Login login = new Login();
Help help = new Help();
@@ -193,13 +192,6 @@ public class Main extends HttpServlet implements Stream.StreamListener {
help.doGetHelp(sql, request, response);
} else if (uri.startsWith("/tag/")) {
discover.doGet(sql, sqlSearch, request, response);
- } else if (uri.equals("/dev")) {
- com.juick.User visitor = Utils.getVisitorUser(sql, request, response);
- if (visitor != null && visitor.UID == 1) {
- dev.doGet(sql, request, response);
- } else {
- Errors.doGet404(sql, request, response);
- }
} else if (uri.matches("^/\\d+$")) {
String strID = request.getRequestURI().substring(1);
int mid = 0;
diff --git a/src/java/com/juick/http/www/NewMessage.java b/src/java/com/juick/http/www/NewMessage.java
index 4bb87404..2072e41f 100644
--- a/src/java/com/juick/http/www/NewMessage.java
+++ b/src/java/com/juick/http/www/NewMessage.java
@@ -53,10 +53,7 @@ public class NewMessage {
+ "<script src=\"//static.juick.com/mc.js\" type=\"text/javascript\" defer=\"defer\"></script>"
+ "<script src=\"//static.juick.com/maps.js?2010111500\" type=\"text/javascript\" defer=\"defer\"></script>"
+ "<script src=\"//static.juick.com/post3.js\" type=\"text/javascript\" defer=\"defer\"></script>");
-
- if (!Utils.isMobileRequest(request)) {
- PageTemplates.pageNavigation(out, visitor, null);
- }
+ PageTemplates.pageNavigation(out, visitor, null);
out.println("<section id=\"content\" class=\"pagetext\">");
out.println("<form action=\"/post2\" method=\"post\" id=\"postmsg\" enctype=\"multipart/form-data\">");
@@ -81,10 +78,7 @@ public class NewMessage {
printUserTags(sql, out, visitor);
out.println("</section>");
- if (!Utils.isMobileRequest(request)) {
- PageTemplates.pageFooter(request, out, visitor, false);
- }
-
+ PageTemplates.pageFooter(request, out, visitor, false);
PageTemplates.pageEnd(out);
} finally {
out.close();
diff --git a/src/java/com/juick/http/www/PM.java b/src/java/com/juick/http/www/PM.java
index 2aa0e0f2..c587e5b1 100644
--- a/src/java/com/juick/http/www/PM.java
+++ b/src/java/com/juick/http/www/PM.java
@@ -56,11 +56,8 @@ public class PM {
PrintWriter out = response.getWriter();
try {
PageTemplates.pageHead(out, title, null);
-
- if (!Utils.isMobileRequest(request)) {
- PageTemplates.pageNavigation(out, visitor, null);
- PageTemplates.pageHomeColumn(out, sql, visitor);
- }
+ PageTemplates.pageNavigation(out, visitor, null);
+ PageTemplates.pageHomeColumn(out, sql, visitor);
out.println("<section id=\"content\">");
@@ -97,10 +94,7 @@ public class PM {
out.println("</section>");
- if (!Utils.isMobileRequest(request)) {
- PageTemplates.pageFooter(request, out, visitor, true);
- }
-
+ PageTemplates.pageFooter(request, out, visitor, true);
PageTemplates.pageEnd(out);
} finally {
out.close();
@@ -132,7 +126,6 @@ public class PM {
try {
PageTemplates.pageHead(out, title, null);
PageTemplates.pageNavigation(out, visitor, null);
-
PageTemplates.pageHomeColumn(out, sql, visitor);
out.println("<section id=\"content\">");
diff --git a/src/java/com/juick/http/www/PageTemplates.java b/src/java/com/juick/http/www/PageTemplates.java
index a7b2daf9..e9de8edb 100644
--- a/src/java/com/juick/http/www/PageTemplates.java
+++ b/src/java/com/juick/http/www/PageTemplates.java
@@ -52,7 +52,7 @@ public class PageTemplates {
out.println("<!DOCTYPE html>");
out.print("<html>");
out.print("<head>");
- out.print("<link rel=\"stylesheet\" href=\"/style.2014042400.css\"/>");
+ out.print("<link rel=\"stylesheet\" href=\"/style.2014061700.css\"/>");
out.print("<script type=\"text/javascript\" src=\"//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js\"></script>");
out.print("<script type=\"text/javascript\" src=\"/scripts.2014042200.js\"></script>");
if (headers != null) {
@@ -457,8 +457,8 @@ public class PageTemplates {
msg = sb.toString();
// > citate
- msg = msg.replaceAll("(?:(?<=\\n)|(?<=\\A))&gt; *(.*)?(\\n|(?=\\Z))", "<blockquote>$1</blockquote>");
- msg = msg.replaceAll("</blockquote><blockquote>", "\n");
+ msg = msg.replaceAll("(?:(?<=\\n)|(?<=\\A))&gt; *(.*)?(\\n|(?=\\Z))", "<q>$1</q>");
+ msg = msg.replaceAll("</q><q>", "\n");
msg = msg.replaceAll("\n", "<br/>\n");
return msg;
@@ -550,7 +550,7 @@ public class PageTemplates {
out.print("<a href=\"/" + msg.User.UName + "/" + msg.MID + "\" class=\"replies\">" + msg.Replies + "</a>");
}
out.println("</nav>");
- out.println("</article>");
+ out.print("</article>");
}
}
}
diff --git a/src/java/com/juick/http/www/User.java b/src/java/com/juick/http/www/User.java
index 7ce89895..382d3be9 100644
--- a/src/java/com/juick/http/www/User.java
+++ b/src/java/com/juick/http/www/User.java
@@ -118,11 +118,7 @@ public class User {
PrintWriter out = response.getWriter();
try {
PageTemplates.pageHead(out, title, "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"@" + user.UName + "\" href=\"//rss.juick.com/" + user.UName + "/blog\"/>");
-
- if (!Utils.isMobileRequest(request)) {
- PageTemplates.pageNavigation(out, visitor, null);
- }
-
+ PageTemplates.pageNavigation(out, visitor, null);
pageUserColumn(out, sql, user, visitor);
if (mids.size() > 0) {
@@ -151,10 +147,7 @@ public class User {
out.println("</section>");
}
- if (!Utils.isMobileRequest(request)) {
- PageTemplates.pageFooter(request, out, visitor, true);
- }
-
+ PageTemplates.pageFooter(request, out, visitor, true);
PageTemplates.pageEnd(out);
} finally {
out.close();
@@ -172,21 +165,14 @@ public class User {
PrintWriter out = response.getWriter();
try {
PageTemplates.pageHead(out, "Теги " + user.UName, null);
-
- if (!Utils.isMobileRequest(request)) {
- PageTemplates.pageNavigation(out, visitor, null);
- }
-
+ PageTemplates.pageNavigation(out, visitor, null);
pageUserColumn(out, sql, user, visitor);
out.println("<section id=\"content\">");
out.println("<p>" + pageUserTags(sql, user, visitor, 0) + "</p>");
out.println("</section>");
- if (!Utils.isMobileRequest(request)) {
- PageTemplates.pageFooter(request, out, visitor, false);
- }
-
+ PageTemplates.pageFooter(request, out, visitor, false);
PageTemplates.pageEnd(out);
} finally {
out.close();
@@ -204,11 +190,7 @@ public class User {
PrintWriter out = response.getWriter();
try {
PageTemplates.pageHead(out, "Подписки " + user.UName, null);
-
- if (!Utils.isMobileRequest(request)) {
- PageTemplates.pageNavigation(out, visitor, null);
- }
-
+ PageTemplates.pageNavigation(out, visitor, null);
pageUserColumn(out, sql, user, visitor);
out.println("<section id=\"content\">");
@@ -238,10 +220,7 @@ public class User {
out.println("</tr></table>");
out.println("</section>");
- if (!Utils.isMobileRequest(request)) {
- PageTemplates.pageFooter(request, out, visitor, false);
- }
-
+ PageTemplates.pageFooter(request, out, visitor, false);
PageTemplates.pageEnd(out);
} finally {
out.close();
@@ -259,11 +238,7 @@ public class User {
PrintWriter out = response.getWriter();
try {
PageTemplates.pageHead(out, "Читатели " + user.UName, null);
-
- if (!Utils.isMobileRequest(request)) {
- PageTemplates.pageNavigation(out, visitor, null);
- }
-
+ PageTemplates.pageNavigation(out, visitor, null);
pageUserColumn(out, sql, user, visitor);
out.println("<section id=\"content\">");
@@ -293,10 +268,7 @@ public class User {
out.println("</tr></table>");
out.println("</section>");
- if (!Utils.isMobileRequest(request)) {
- PageTemplates.pageFooter(request, out, visitor, false);
- }
-
+ PageTemplates.pageFooter(request, out, visitor, false);
PageTemplates.pageEnd(out);
} finally {
out.close();
diff --git a/src/java/com/juick/http/www/UserThread.java b/src/java/com/juick/http/www/UserThread.java
index efec8899..42cb5541 100644
--- a/src/java/com/juick/http/www/UserThread.java
+++ b/src/java/com/juick/http/www/UserThread.java
@@ -72,20 +72,14 @@ public class UserThread {
headers += "<link rel=\"canonical\" href=\"http://juick.com/" + msg.User.UName + "/" + msg.MID + "\"/>";
}
PageTemplates.pageHead(out, title, headers);
-
- if (!Utils.isMobileRequest(request)) {
- PageTemplates.pageNavigation(out, visitor, null);
- }
+ PageTemplates.pageNavigation(out, visitor, null);
out.println("<section id=\"content\" style=\"margin-left: 0; width: 100%\">");
printMessage(out, sql, msg, visitor);
printReplies(out, sql, msg, visitor, listview);
out.println("</section>");
- if (!Utils.isMobileRequest(request)) {
- PageTemplates.pageFooter(request, out, visitor, false);
- }
-
+ PageTemplates.pageFooter(request, out, visitor, false);
PageTemplates.pageEnd(out);
} finally {
out.close();
diff --git a/src/java/com/juick/http/www/Utils.java b/src/java/com/juick/http/www/Utils.java
index 271252c7..e20be893 100644
--- a/src/java/com/juick/http/www/Utils.java
+++ b/src/java/com/juick/http/www/Utils.java
@@ -88,11 +88,6 @@ public class Utils {
}
}
- public static boolean isMobileRequest(HttpServletRequest request) {
- String ua = request.getHeader("User-Agent");
- return ua != null && ua.contains(" Juick/");
- }
-
public static void sendTemporaryRedirect(HttpServletResponse response, String location) {
response.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
response.setHeader("Location", location);