aboutsummaryrefslogtreecommitdiff
path: root/src/java/com/juick/http/www/Main.java
diff options
context:
space:
mode:
authorGravatar Ugnich Anton2015-10-19 22:57:41 +0700
committerGravatar Ugnich Anton2015-10-19 22:57:41 +0700
commited878bfc46df42c56d13fb6f235f9e7f63a64d61 (patch)
tree1842d1fab6b77cb9a72c63eae01e4d6d7ce943d3 /src/java/com/juick/http/www/Main.java
parent804ef16a1df1ecd8a948cdc0894d82cba77e8f42 (diff)
+ RSS, basic classes
Diffstat (limited to 'src/java/com/juick/http/www/Main.java')
-rw-r--r--src/java/com/juick/http/www/Main.java39
1 files changed, 22 insertions, 17 deletions
diff --git a/src/java/com/juick/http/www/Main.java b/src/java/com/juick/http/www/Main.java
index 0fe93173..56aa439f 100644
--- a/src/java/com/juick/http/www/Main.java
+++ b/src/java/com/juick/http/www/Main.java
@@ -17,6 +17,7 @@
*/
package com.juick.http.www;
+import com.juick.server.UserQueries;
import com.juick.xmpp.JID;
import com.juick.xmpp.Stream;
import com.juick.xmpp.StreamComponent;
@@ -43,13 +44,12 @@ import ru.sape.Sape;
@WebServlet(name = "Main", urlPatterns = {"/"})
@MultipartConfig(fileSizeThreshold = 1024 * 1024, maxRequestSize = 1024 * 1024 * 10)
public class Main extends HttpServlet implements Stream.StreamListener {
-
+
Connection sql;
Connection sqlSearch;
Stream xmpp;
Home home = new Home();
Discover discover = new Discover();
- Reader reader = new Reader();
PM pm = new PM();
Login login = new Login();
Help help = new Help();
@@ -60,29 +60,30 @@ public class Main extends HttpServlet implements Stream.StreamListener {
VKontakteLogin loginVK = new VKontakteLogin();
SignUp signup = new SignUp();
Settings settings = new Settings();
-
+ RSS rss = new RSS();
+
@Override
public void init() throws ServletException {
super.init();
try {
Properties conf = new Properties();
conf.load(new FileInputStream("/etc/juick/www.conf"));
-
+
Class.forName("com.mysql.jdbc.Driver");
sql = DriverManager.getConnection("jdbc:mysql://localhost/juick?autoReconnect=true&user=" + conf.getProperty("mysql_username", "") + "&password=" + conf.getProperty("mysql_password", ""));
sqlSearch = DriverManager.getConnection("jdbc:mysql://127.0.0.1:9306?autoReconnect=true&characterEncoding=utf8&maxAllowedPacket=512000", "", "");
-
+
setupXmppComponent(conf.getProperty("xmpp_password"));
-
+
PageTemplates.sape = new Sape(conf.getProperty("sape_user"), "juick.com", 2000, 3600);
} catch (Exception e) {
log(null, e);
}
}
-
+
public void setupXmppComponent(final String password) {
Thread thr = new Thread(new Runnable() {
-
+
@Override
public void run() {
try {
@@ -97,17 +98,17 @@ public class Main extends HttpServlet implements Stream.StreamListener {
});
thr.start();
}
-
+
@Override
public void onStreamFail(String msg) {
System.err.println("XMPP STREAM FAIL: " + msg);
}
-
+
@Override
public void onStreamReady() {
System.err.println("XMPP STREAM READY");
}
-
+
@Override
public void destroy() {
super.destroy();
@@ -142,7 +143,7 @@ public class Main extends HttpServlet implements Stream.StreamListener {
request.setCharacterEncoding("UTF-8");
}
String uri = request.getRequestURI();
-
+
if (uri.equals("/")) {
String tag = request.getParameter("tag");
if (tag != null) {
@@ -151,10 +152,6 @@ public class Main extends HttpServlet implements Stream.StreamListener {
com.juick.User visitor = Utils.getVisitorUser(sql, request, response);
home.doGet(sql, sqlSearch, request, response, visitor);
}
- } else if (uri.equals("/reader")) {
- reader.doGet(sql, request, response);
- } else if (uri.equals("/_out")) {
- reader.doGetOut(sql, request, response);
} else if (uri.equals("/post")) {
com.juick.User visitor = Utils.getVisitorUser(sql, request, response);
if (visitor != null) {
@@ -181,6 +178,14 @@ public class Main extends HttpServlet implements Stream.StreamListener {
Errors.doGet404(sql, request, response);
}
}
+ } else if (uri.startsWith("/rss/")) {
+ String uname = uri.substring(5);
+ int uid = UserQueries.getUIDbyName(sql, uname);
+ if (uid > 0) {
+ rss.doGet(sql, request, response, uid, uname);
+ } else {
+ response.sendError(404);
+ }
} else if (uri.equals("/logout")) {
login.doGetLogout(sql, request, response);
} else if (uri.equals("/settings")) {
@@ -274,7 +279,7 @@ public class Main extends HttpServlet implements Stream.StreamListener {
if (request.getCharacterEncoding() == null) {
request.setCharacterEncoding("UTF-8");
}
-
+
String uri = request.getRequestURI();
if (uri.equals("/post")) {
com.juick.User visitor = Utils.getVisitorUser(sql, request, response);