aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/java/com/juick/http/www/Blogs.java55
-rw-r--r--src/java/com/juick/http/www/Dev.java68
-rw-r--r--src/java/com/juick/http/www/Main.java7
-rw-r--r--src/java/com/juick/http/www/PageTemplates.java9
-rw-r--r--web/scripts4.js17
-rw-r--r--web/style3.css2
-rw-r--r--web/style4.css7
7 files changed, 101 insertions, 64 deletions
diff --git a/src/java/com/juick/http/www/Blogs.java b/src/java/com/juick/http/www/Blogs.java
index 4f455760..8e459dc1 100644
--- a/src/java/com/juick/http/www/Blogs.java
+++ b/src/java/com/juick/http/www/Blogs.java
@@ -42,24 +42,6 @@ import javax.servlet.http.HttpServletResponse;
*/
public class Blogs {
- private int relatedTagsStartMID = 0;
-
- public Blogs(Connection sql) {
- PreparedStatement stmt = null;
- ResultSet rs = null;
- try {
- stmt = sql.prepareStatement("SELECT MIN(message_id) FROM messages WHERE ts>DATE_ADD(NOW(),INTERVAL -6 MONTH)");
- rs = stmt.executeQuery();
- if (rs.first()) {
- relatedTagsStartMID = rs.getInt(1);
- }
- } catch (SQLException e) {
- System.err.println(e);
- } finally {
- Utils.finishSQL(rs, stmt);
- }
- }
-
protected void doGet(Connection sql, Connection sqlSearch, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String paramTagStrQuery = request.getParameter("tag");
if (paramTagStrQuery != null) {
@@ -234,17 +216,6 @@ public class Blogs {
out.println(" <p>" + getTags(sql, 40) + "</p>");
out.println("</div>");
- out.println("<div id=\"rcol\" class=\"abs\">");
- //PageTemplates.pageYandexAd(out, visitor == null ? 2 : 3); // разный ID для залогиненых и нет
- if (paramTag > 0 && relatedTagsStartMID > 0) {
- String related = getRelatedTags(sql, paramTag, 15);
- if (!related.isEmpty()) {
- out.println("<h3>Related tags:</h3>");
- out.println("<ul id=\"reltags\">" + related + "</ul>");
- }
- }
- out.println("</div>");
-
out.println("</div>"); // topwrapper
PageTemplates.pageDialogTemplate(out, locale);
@@ -302,30 +273,4 @@ public class Blogs {
return ret;
}
-
- private String getRelatedTags(Connection sql, int tag_id, int cnt) {
- String ret = "";
-
- PreparedStatement stmt = null;
- ResultSet rs = null;
- try {
- stmt = sql.prepareStatement("SELECT tags.name,COUNT(message_id) AS cnt FROM messages_tags INNER JOIN tags ON messages_tags.tag_id=tags.tag_id WHERE messages_tags.message_id>" + relatedTagsStartMID + " AND messages_tags.message_id IN (SELECT message_id FROM messages_tags WHERE tag_id=?) AND messages_tags.tag_id NOT IN (SELECT tag_id FROM tags_ignore) GROUP BY messages_tags.tag_id HAVING cnt>1 ORDER BY cnt DESC LIMIT 1,?");
- stmt.setInt(1, tag_id);
- stmt.setInt(2, cnt);
- rs = stmt.executeQuery();
- rs.beforeFirst();
- while (rs.next()) {
- try {
- ret += "<li><a href=\"/tag/" + URLEncoder.encode(rs.getString(1), "UTF-8") + "\">" + Utils.encodeHTML(rs.getString(1)) + "</a></li>";
- } catch (UnsupportedEncodingException e) {
- }
- }
- } catch (SQLException e) {
- System.err.println(e);
- } finally {
- Utils.finishSQL(rs, stmt);
- }
-
- return ret;
- }
}
diff --git a/src/java/com/juick/http/www/Dev.java b/src/java/com/juick/http/www/Dev.java
new file mode 100644
index 00000000..480491e0
--- /dev/null
+++ b/src/java/com/juick/http/www/Dev.java
@@ -0,0 +1,68 @@
+/*
+ * 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 java.io.IOException;
+import java.io.PrintWriter;
+import java.sql.Connection;
+import java.util.Locale;
+import java.util.ResourceBundle;
+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);
+
+ if (visitor == null) {
+ response.sendError(403);
+ return;
+ }
+
+ response.setContentType("text/html; charset=UTF-8");
+ PrintWriter out = response.getWriter();
+ try {
+
+ out.println("<!DOCTYPE html>");
+ out.println("<html>");
+ out.println("<head>");
+ out.println("<link rel=\"stylesheet\" href=\"//static.juick.com/style4.css\"/>");
+ out.println("<script type=\"text/javascript\" src=\"//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js\"></script>");
+ out.println("<script type=\"text/javascript\" src=\"//static.juick.com/scripts4.js\"></script>");
+ out.println("<title>Juick</title>");
+ out.println("</head>");
+ out.flush();
+ out.println("<body>");
+
+ out.println("<script type=\"text/javascript\">");
+ out.println("var hash='" + Utils.getCookie(request, "hash") + "';");
+ out.println("var user_id=" + visitor.UID + ";");
+ out.println("</script>");
+
+ out.println("</body></html>");
+ } finally {
+ out.close();
+ }
+ }
+}
diff --git a/src/java/com/juick/http/www/Main.java b/src/java/com/juick/http/www/Main.java
index c6c4f1b8..f4342392 100644
--- a/src/java/com/juick/http/www/Main.java
+++ b/src/java/com/juick/http/www/Main.java
@@ -41,7 +41,7 @@ public class Main extends HttpServlet {
Connection sql;
Connection sqlSearch;
Stream xmpp;
- Blogs blogs;
+ Blogs blogs = new Blogs();
Login login = new Login();
Help help = new Help();
User pagesUser = new User();
@@ -51,6 +51,7 @@ public class Main extends HttpServlet {
VKontakteLogin loginVK = new VKontakteLogin();
SignUp signup = new SignUp();
Settings settings = new Settings();
+ Dev dev = new Dev();
@Override
public void init() throws ServletException {
@@ -68,8 +69,6 @@ public class Main extends HttpServlet {
xmpp.start();
*/
- blogs = new Blogs(sql);
-
PageTemplates.sape = new Sape(conf.getProperty("sape_user"), "juick.com", 2000, 3600);
} catch (Exception e) {
log(null, e);
@@ -144,6 +143,8 @@ public class Main extends HttpServlet {
blogs.doGet(sql, sqlSearch, request, response);
} else if (uri.startsWith("/places/")) {
blogs.doGet(sql, sqlSearch, request, response);
+ } else if (uri.equals("/dev/")) {
+ dev.doGet(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/PageTemplates.java b/src/java/com/juick/http/www/PageTemplates.java
index b5b187a0..10c02a80 100644
--- a/src/java/com/juick/http/www/PageTemplates.java
+++ b/src/java/com/juick/http/www/PageTemplates.java
@@ -23,7 +23,6 @@ import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.sql.Connection;
-import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
@@ -51,10 +50,10 @@ public class PageTemplates {
out.println("<!DOCTYPE html>");
out.print("<html>");
out.print("<head>");
- out.print("<link rel=\"stylesheet\" href=\"/style.2013041001.css\"/>");
+ out.print("<link rel=\"stylesheet\" href=\"/style.2013072200.css\"/>");
out.print("<script type=\"text/javascript\" src=\"//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js\" defer=\"defer\"></script>");
out.print("<script type=\"text/javascript\" src=\"//ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js\" defer=\"defer\" async=\"async\"></script>");
- out.print("<script type=\"text/javascript\" src=\"/scripts.2013032900.js\" defer=\"defer\"></script>");
+ out.print("<script type=\"text/javascript\" src=\"/scripts.2013072200.js\" defer=\"defer\"></script>");
if (headers != null) {
out.print(headers);
}
@@ -240,7 +239,7 @@ public class PageTemplates {
} else {
return sdfFull.format(pDate);
}
- } catch (ParseException e) {
+ } catch (Exception e) {
return fulldate;
}
}
@@ -253,7 +252,7 @@ public class PageTemplates {
+ "var d=new Date(" + date.getTime() + ");"
+ "document.write((d.getDate()<10?'0':'')+d.getDate()+'.'+(d.getMonth()<9?'0':'')+(d.getMonth()+1)+'.'+d.getFullYear()+' '+(d.getHours()<10?'0':'')+d.getHours()+':'+(d.getMinutes()<10?'0':'')+d.getMinutes());"
+ "</script>";
- } catch (ParseException e) {
+ } catch (Exception e) {
System.err.print(e);
}
return "";
diff --git a/web/scripts4.js b/web/scripts4.js
new file mode 100644
index 00000000..f417dfc4
--- /dev/null
+++ b/web/scripts4.js
@@ -0,0 +1,17 @@
+function blogsLoadPM(uname) {
+ $.getJSON('http://api.juick.com/pm?hash='+hash+'&uname='+uname+'&callback=?').done(function(data) {
+ var ul=$('#content>ul');
+ ul.empty();
+ $("p.page").hide();
+ $.each(data,function(i,item) {
+ var li=$("<li/>");
+ if(item.user) {
+ li.attr("class","pm-in");
+ } else {
+ li.attr("class","pm-out");
+ }
+ li.text(item.body);
+ li.appendTo(ul);
+ });
+ });
+}
diff --git a/web/style3.css b/web/style3.css
index db4efd7f..e240160a 100644
--- a/web/style3.css
+++ b/web/style3.css
@@ -106,7 +106,7 @@ blockquote { border-left: 1px dashed #CCC; margin: 10px 0 10px 10px; padding-lef
#rcol { width: 190px; top: 0; margin: 10px 0 0 810px; padding-top: 10px; overflow: hidden; font-size: smaller; }
#rcol h3 { margin: 8px 0; }
-#reltags li { font-size: larger; margin: 2px 0 2px 10px; }
+#rcol p { font-size: small; line-height: 140%; }
/********/
diff --git a/web/style4.css b/web/style4.css
new file mode 100644
index 00000000..91a219d0
--- /dev/null
+++ b/web/style4.css
@@ -0,0 +1,7 @@
+.pm-in,.pm-out { background: #FFF; border: 1px solid #E0E0E0; margin: 10px 0; padding: 10px; }
+.pm-in { width: 85%; }
+.pm-out { margin-left: 15%; }
+
+#pmulist li { overflow: hidden; }
+#pmulist img { width: 32px; height: 32px; margin-right: 5px; vertical-align: middle; }
+#pmulist .unreadcnt { float: right; margin-top: 4px; background: #CCC; padding: 1px 3px; }