aboutsummaryrefslogtreecommitdiff
path: root/src/java/com/juick/http/www/Main.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/com/juick/http/www/Main.java')
-rw-r--r--src/java/com/juick/http/www/Main.java21
1 files changed, 16 insertions, 5 deletions
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;