From c449c1fe8b43f41714fe0cd87bdacf03a68587fe Mon Sep 17 00:00:00 2001
From: Ugnich Anton
Date: Tue, 23 Jul 2013 03:39:32 +0700
Subject: remove "related tags" /dev/
---
src/java/com/juick/http/www/Blogs.java | 55 ---------------------
src/java/com/juick/http/www/Dev.java | 68 ++++++++++++++++++++++++++
src/java/com/juick/http/www/Main.java | 7 +--
src/java/com/juick/http/www/PageTemplates.java | 9 ++--
4 files changed, 76 insertions(+), 63 deletions(-)
create mode 100644 src/java/com/juick/http/www/Dev.java
(limited to 'src')
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("
" + getTags(sql, 40) + "
");
out.println("");
- out.println("");
- //PageTemplates.pageYandexAd(out, visitor == null ? 2 : 3); // разный ID для залогиненых и нет
- if (paramTag > 0 && relatedTagsStartMID > 0) {
- String related = getRelatedTags(sql, paramTag, 15);
- if (!related.isEmpty()) {
- out.println("
Related tags: ");
- out.println("
");
- }
- }
- out.println("
");
-
out.println(""); // 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 += "" + Utils.encodeHTML(rs.getString(1)) + " ";
- } 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 .
+ */
+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("");
+ out.println("");
+ out.println("");
+ out.println(" ");
+ out.println("");
+ out.println("");
+ out.println("Juick ");
+ out.println("");
+ out.flush();
+ out.println("");
+
+ out.println("");
+
+ out.println("");
+ } 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("");
out.print("");
out.print("");
- out.print(" ");
+ out.print(" ");
out.print("");
out.print("");
- out.print("");
+ out.print("");
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());"
+ "";
- } catch (ParseException e) {
+ } catch (Exception e) {
System.err.print(e);
}
return "";
--
cgit v1.2.3