aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Ugnich Anton2013-07-23 03:39:32 +0700
committerGravatar Ugnich Anton2013-07-23 03:39:32 +0700
commitc449c1fe8b43f41714fe0cd87bdacf03a68587fe (patch)
tree59feeb6c4c8c5e4f9cc2697f0bd27d06c05e6514 /src
parentc37d78969da40f4238573bbee2c533c878ea3844 (diff)
remove "related tags"
/dev/
Diffstat (limited to 'src')
-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
4 files changed, 76 insertions, 63 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 "";