From e67f01bb08125eae47c42965367dc96624e5f146 Mon Sep 17 00:00:00 2001
From: Ugnich Anton
Date: Sun, 23 Feb 2014 12:11:58 +0700
Subject: isMobileRequest
---
src/java/com/juick/http/www/Discover.java | 11 +++++--
src/java/com/juick/http/www/Home.java | 11 +++++--
src/java/com/juick/http/www/NewMessage.java | 10 +++++--
src/java/com/juick/http/www/PM.java | 11 +++++--
src/java/com/juick/http/www/PageTemplates.java | 4 +--
src/java/com/juick/http/www/User.java | 40 ++++++++++++++++++++------
src/java/com/juick/http/www/UserThread.java | 10 +++++--
src/java/com/juick/http/www/Utils.java | 5 ++++
8 files changed, 79 insertions(+), 23 deletions(-)
(limited to 'src/java/com/juick')
diff --git a/src/java/com/juick/http/www/Discover.java b/src/java/com/juick/http/www/Discover.java
index 1db264f7..1ba6992a 100644
--- a/src/java/com/juick/http/www/Discover.java
+++ b/src/java/com/juick/http/www/Discover.java
@@ -73,9 +73,11 @@ public class Discover {
canonical = "";
}
PageTemplates.pageHead(out, title, canonical);
- PageTemplates.pageNavigation(out, visitor, null);
- PageTemplates.pageHomeColumn(out, sql, visitor);
+ if (!Utils.isMobileRequest(request)) {
+ PageTemplates.pageNavigation(out, visitor, null);
+ PageTemplates.pageHomeColumn(out, sql, visitor);
+ }
out.println("");
@@ -90,7 +92,10 @@ public class Discover {
out.println("");
- PageTemplates.pageFooter(request, out, visitor, true);
+ if (!Utils.isMobileRequest(request)) {
+ PageTemplates.pageFooter(request, out, visitor, true);
+ }
+
PageTemplates.pageDialogTemplate(out);
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 1319a135..75eeb941 100644
--- a/src/java/com/juick/http/www/Home.java
+++ b/src/java/com/juick/http/www/Home.java
@@ -91,9 +91,11 @@ public class Home {
PrintWriter out = response.getWriter();
try {
PageTemplates.pageHead(out, title, null);
- PageTemplates.pageNavigation(out, visitor, paramSearch);
- PageTemplates.pageHomeColumn(out, sql, visitor);
+ if (!Utils.isMobileRequest(request)) {
+ PageTemplates.pageNavigation(out, visitor, paramSearch);
+ PageTemplates.pageHomeColumn(out, sql, visitor);
+ }
out.println("");
@@ -135,7 +137,10 @@ public class Home {
out.println("");
- PageTemplates.pageFooter(request, out, visitor, true);
+ if (!Utils.isMobileRequest(request)) {
+ PageTemplates.pageFooter(request, out, visitor, true);
+ }
+
PageTemplates.pageDialogTemplate(out);
PageTemplates.pageEnd(out);
} finally {
diff --git a/src/java/com/juick/http/www/NewMessage.java b/src/java/com/juick/http/www/NewMessage.java
index 2c8aed9c..895bfe91 100644
--- a/src/java/com/juick/http/www/NewMessage.java
+++ b/src/java/com/juick/http/www/NewMessage.java
@@ -43,7 +43,10 @@ public class NewMessage {
+ ""
+ ""
+ "");
- PageTemplates.pageNavigation(out, visitor, null);
+
+ if (!Utils.isMobileRequest(request)) {
+ PageTemplates.pageNavigation(out, visitor, null);
+ }
out.println("");
- PageTemplates.pageFooter(request, out, visitor, false);
+ if (!Utils.isMobileRequest(request)) {
+ 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 6d8e04ba..8dbe1036 100644
--- a/src/java/com/juick/http/www/PM.java
+++ b/src/java/com/juick/http/www/PM.java
@@ -56,9 +56,11 @@ public class PM {
PrintWriter out = response.getWriter();
try {
PageTemplates.pageHead(out, title, null);
- PageTemplates.pageNavigation(out, visitor, null);
- PageTemplates.pageHomeColumn(out, sql, visitor);
+ if (!Utils.isMobileRequest(request)) {
+ PageTemplates.pageNavigation(out, visitor, null);
+ PageTemplates.pageHomeColumn(out, sql, visitor);
+ }
out.println("");
@@ -95,7 +97,10 @@ public class PM {
out.println("");
- PageTemplates.pageFooter(request, out, visitor, true);
+ if (!Utils.isMobileRequest(request)) {
+ PageTemplates.pageFooter(request, out, visitor, true);
+ }
+
PageTemplates.pageDialogTemplate(out);
PageTemplates.pageEnd(out);
} finally {
diff --git a/src/java/com/juick/http/www/PageTemplates.java b/src/java/com/juick/http/www/PageTemplates.java
index 228cff91..c76ded41 100644
--- a/src/java/com/juick/http/www/PageTemplates.java
+++ b/src/java/com/juick/http/www/PageTemplates.java
@@ -52,9 +52,9 @@ public class PageTemplates {
out.println("");
out.print("");
out.print("
");
- out.print("");
+ out.print("");
out.print("");
- out.print("");
+ out.print("");
if (headers != null) {
out.print(headers);
}
diff --git a/src/java/com/juick/http/www/User.java b/src/java/com/juick/http/www/User.java
index 1e469a1d..c673edbd 100644
--- a/src/java/com/juick/http/www/User.java
+++ b/src/java/com/juick/http/www/User.java
@@ -109,7 +109,10 @@ public class User {
PrintWriter out = response.getWriter();
try {
PageTemplates.pageHead(out, title, "");
- PageTemplates.pageNavigation(out, visitor, null);
+
+ if (!Utils.isMobileRequest(request)) {
+ PageTemplates.pageNavigation(out, visitor, null);
+ }
pageUserColumn(out, sql, user, visitor);
@@ -134,7 +137,10 @@ public class User {
out.println("");
}
- PageTemplates.pageFooter(request, out, visitor, true);
+ if (!Utils.isMobileRequest(request)) {
+ PageTemplates.pageFooter(request, out, visitor, true);
+ }
+
PageTemplates.pageDialogTemplate(out);
PageTemplates.pageEnd(out);
} finally {
@@ -149,7 +155,10 @@ public class User {
PrintWriter out = response.getWriter();
try {
PageTemplates.pageHead(out, "Теги " + user.UName, null);
- PageTemplates.pageNavigation(out, visitor, null);
+
+ if (!Utils.isMobileRequest(request)) {
+ PageTemplates.pageNavigation(out, visitor, null);
+ }
pageUserColumn(out, sql, user, visitor);
@@ -157,7 +166,10 @@ public class User {
out.println("" + pageUserTags(sql, user, visitor, 0) + "
");
out.println("");
- PageTemplates.pageFooter(request, out, visitor, false);
+ if (!Utils.isMobileRequest(request)) {
+ PageTemplates.pageFooter(request, out, visitor, false);
+ }
+
PageTemplates.pageDialogTemplate(out);
PageTemplates.pageEnd(out);
} finally {
@@ -172,7 +184,10 @@ public class User {
PrintWriter out = response.getWriter();
try {
PageTemplates.pageHead(out, "Подписки " + user.UName, null);
- PageTemplates.pageNavigation(out, visitor, null);
+
+ if (!Utils.isMobileRequest(request)) {
+ PageTemplates.pageNavigation(out, visitor, null);
+ }
pageUserColumn(out, sql, user, visitor);
@@ -203,7 +218,10 @@ public class User {
out.println("");
out.println("");
- PageTemplates.pageFooter(request, out, visitor, false);
+ if (!Utils.isMobileRequest(request)) {
+ PageTemplates.pageFooter(request, out, visitor, false);
+ }
+
PageTemplates.pageDialogTemplate(out);
PageTemplates.pageEnd(out);
} finally {
@@ -218,7 +236,10 @@ public class User {
PrintWriter out = response.getWriter();
try {
PageTemplates.pageHead(out, "Читатели " + user.UName, null);
- PageTemplates.pageNavigation(out, visitor, null);
+
+ if (!Utils.isMobileRequest(request)) {
+ PageTemplates.pageNavigation(out, visitor, null);
+ }
pageUserColumn(out, sql, user, visitor);
@@ -249,7 +270,10 @@ public class User {
out.println("");
out.println("");
- PageTemplates.pageFooter(request, out, visitor, false);
+ if (!Utils.isMobileRequest(request)) {
+ PageTemplates.pageFooter(request, out, visitor, false);
+ }
+
PageTemplates.pageDialogTemplate(out);
PageTemplates.pageEnd(out);
} finally {
diff --git a/src/java/com/juick/http/www/UserThread.java b/src/java/com/juick/http/www/UserThread.java
index 095612d7..cf1ae76a 100644
--- a/src/java/com/juick/http/www/UserThread.java
+++ b/src/java/com/juick/http/www/UserThread.java
@@ -64,15 +64,21 @@ public class UserThread {
PrintWriter out = response.getWriter();
try {
PageTemplates.pageHead(out, title, "");
- PageTemplates.pageNavigation(out, visitor, null);
+
+ if (!Utils.isMobileRequest(request)) {
+ PageTemplates.pageNavigation(out, visitor, null);
+ }
out.println("");
printMessage(out, sql, msg, visitor);
printReplies(out, sql, msg, visitor, listview);
out.println("");
+ if (!Utils.isMobileRequest(request)) {
+ PageTemplates.pageFooter(request, out, visitor, false);
+ }
+
PageTemplates.pageDialogTemplate(out);
- 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 35b918b8..66450acd 100644
--- a/src/java/com/juick/http/www/Utils.java
+++ b/src/java/com/juick/http/www/Utils.java
@@ -61,6 +61,11 @@ 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);
--
cgit v1.2.3