From 565b8f0b25c9215687ddd4c84f236e1d1696b93d Mon Sep 17 00:00:00 2001
From: Ugnich Anton
Date: Wed, 30 Jul 2014 17:53:19 +0700
Subject: formatTags rel=nofollow
---
src/java/com/juick/http/www/PageTemplates.java | 96 +++++++++++++-------------
src/java/com/juick/http/www/UserThread.java | 24 ++-----
2 files changed, 55 insertions(+), 65 deletions(-)
(limited to 'src/java/com/juick')
diff --git a/src/java/com/juick/http/www/PageTemplates.java b/src/java/com/juick/http/www/PageTemplates.java
index dc8c7c59..686971e8 100644
--- a/src/java/com/juick/http/www/PageTemplates.java
+++ b/src/java/com/juick/http/www/PageTemplates.java
@@ -40,13 +40,13 @@ import ru.sape.Sape;
* @author Ugnich Anton
*/
public class PageTemplates {
-
+
public static Sape sape = null;
private static final SimpleDateFormat sdfSQL = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
private static SimpleDateFormat sdfSimple = new SimpleDateFormat("d MMM");
private static SimpleDateFormat sdfFull = new SimpleDateFormat("d MMM yyyy");
private static String tagsHTML = null;
-
+
public static void pageHead(PrintWriter out, String title, String headers) {
out.println("");
out.print("");
@@ -67,7 +67,7 @@ public class PageTemplates {
out.flush();
out.println("
");
}
-
+
public static void pageNavigation(PrintWriter out, com.juick.User visitor, String search) {
out.println("");
out.println(" ");
@@ -100,7 +100,7 @@ public class PageTemplates {
out.println(" ");
out.println("");
}
-
+
public static void pageYandexAd728(PrintWriter out, int YandexID) {
/*
out.println("");
@@ -137,12 +137,12 @@ public class PageTemplates {
out.println("(adsbygoogle = window.adsbygoogle || []).push({})");
out.println("");
}
-
+
public static void pageHomeColumn(PrintWriter out, Connection sql, com.juick.User visitor) {
if (tagsHTML == null) {
tagsHTML = PageTemplates.getPopularTags(sql, 80);
}
-
+
out.println("");
}
-
+
public static String getPopularTags(Connection sql, int cnt) {
String ret = "";
-
+
PreparedStatement stmt = null;
ResultSet rs = null;
try {
@@ -168,23 +168,23 @@ public class PageTemplates {
ret += "" + Utils.encodeHTML(rs.getString(1)) + "";
} catch (UnsupportedEncodingException e) {
}
-
+
}
} catch (SQLException e) {
System.err.println(e);
} finally {
Utils.finishSQL(rs, stmt);
}
-
+
return ret;
}
-
+
public static void printContestRating(PrintWriter out, Connection sql) {
out.println("
");
out.println("");
out.println("Кто выиграет iPod?
");
out.println("");
-
+
int i = 0;
PreparedStatement stmt = null;
ResultSet rs = null;
@@ -206,11 +206,11 @@ public class PageTemplates {
} finally {
Utils.finishSQL(rs, stmt);
}
-
+
out.println("
");
out.println("");
}
-
+
public static void pageFooter(HttpServletRequest request, PrintWriter out, com.juick.User visitor, boolean sapeon) {
out.println("");
out.print(" ");
out.println("");
-
+
if (visitor != null) {
out.println("");
}
-
+
out.println("");
}
-
+
public static void pageEnd(PrintWriter out) {
out.println("");
}
-
+
public static String formatTags(ArrayList tags) {
String ret = "";
for (int i = 0; i < tags.size(); i++) {
com.juick.Tag tag = tags.get(i);
String tagName = tag.Name.replaceAll("<", "<").replaceAll(">", ">");
- if (tag.UsageCnt > 1) {
- try {
- ret += " *" + tagName + "";
- } catch (UnsupportedEncodingException e) {
+ try {
+ ret += " *" + tagName + "";
+ } catch (UnsupportedEncodingException e) {
}
}
-
+
return ret;
}
-
+
public static String formatTags(ArrayList tags, com.juick.User user) {
String ret = "";
for (int i = 0; i < tags.size(); i++) {
@@ -301,10 +301,10 @@ public class PageTemplates {
} catch (UnsupportedEncodingException e) {
}
}
-
+
return ret;
}
-
+
public static String formatDate(int minutes, String fulldate) {
if (minutes < 1) {
return "сейчас";
@@ -363,7 +363,7 @@ public class PageTemplates {
return ret;
}
}
-
+
public static String formatJSLocalTime(String ts) {
String ret = "";
synchronized (sdfSQL) {
@@ -379,7 +379,7 @@ public class PageTemplates {
}
return ret;
}
-
+
public static String formatReplies(int replies) {
int ld = replies % 10;
int lh = replies % 100;
@@ -392,7 +392,7 @@ public class PageTemplates {
}
}
private static Pattern regexLinks2 = Pattern.compile("((?<=\\s)|(?<=\\A))([\\[\\{]|<)((?:ht|f)tps?://(?:www\\.)?([^\\/\\s\\\"\\)\\!]+)/?(?:[^\\]\\}](?" + msg + "";
}
-
+
public static String formatMessage(String msg) {
msg = msg.replaceAll("&", "&");
msg = msg.replaceAll("<", "<");
@@ -480,14 +480,14 @@ public class PageTemplates {
// > citate
msg = msg.replaceAll("(?:(?<=\\n)|(?<=\\A))> *(.*)?(\\n|(?=\\Z))", "$1
");
msg = msg.replaceAll("", "\n");
-
+
msg = msg.replaceAll("\n", "
\n");
return msg;
}
-
+
public static void printMessages(PrintWriter out, Connection sql, com.juick.User user, ArrayList mids, com.juick.User visitor, int YandexID, int ad_mid) {
ArrayList msgs = MessagesQueries.getMessages(sql, mids);
-
+
for (int i = 0; i < msgs.size(); i++) {
com.juick.Message msg = msgs.get(i);
if (msg.MID == ad_mid) {
@@ -496,7 +496,7 @@ public class PageTemplates {
break;
}
}
-
+
ArrayList blUIDs = new ArrayList(20);
if (visitor != null) {
for (int i = 0; i < msgs.size(); i++) {
@@ -504,15 +504,15 @@ public class PageTemplates {
}
blUIDs = UserQueries.checkBL(sql, visitor.UID, blUIDs);
}
-
+
for (int i = 0; i < msgs.size(); i++) {
-
+
if (i == 0 && YandexID > 0 && ad_mid == 0) {
pageYandexAd728(out, YandexID);
}
-
+
com.juick.Message msg = msgs.get(i);
-
+
ArrayList tags = MessagesQueries.getMessageTags(sql, msg.MID);
String tagsStr = formatTags(tags);
if (msg.ReadOnly) {
@@ -524,14 +524,14 @@ public class PageTemplates {
if (msg.MID == ad_mid) {
tagsStr += " *реклама";
}
-
+
String txt;
if (!msg.Tags.isEmpty() && msg.Tags.contains("code")) {
txt = formatMessageCode(msg.Text);
} else {
txt = formatMessage(msg.Text);
}
-
+
out.println("");
out.println(" ");
out.println(" ");
@@ -561,7 +561,7 @@ public class PageTemplates {
out.print(" x");
}
out.println("");
-
+
out.print("