From 52c8d049af6c0963b63dd1e70f66128527a7cba5 Mon Sep 17 00:00:00 2001
From: Ugnich Anton
Date: Wed, 7 Nov 2012 16:36:17 +0700
Subject: JS local time auto-expand comments
---
src/java/com/juick/http/www/UserThread.java | 280 +++++++++++++++-------------
1 file changed, 148 insertions(+), 132 deletions(-)
(limited to 'src/java/com/juick/http/www/UserThread.java')
diff --git a/src/java/com/juick/http/www/UserThread.java b/src/java/com/juick/http/www/UserThread.java
index ec3412f3..a0bb3a86 100644
--- a/src/java/com/juick/http/www/UserThread.java
+++ b/src/java/com/juick/http/www/UserThread.java
@@ -22,11 +22,7 @@ import com.juick.server.UserQueries;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Locale;
import java.util.ResourceBundle;
import javax.servlet.ServletException;
@@ -70,14 +66,14 @@ public class UserThread {
try {
PageTemplates.pageHead(out, title, null);
PageTemplates.pageNavigation(out, locale, visitor);
- PageTemplates.pageUserTitle(out, sql, locale, user, visitor);
+ //PageTemplates.pageUserTitle(out, sql, locale, user, visitor);
out.println("
");
out.println("
");
out.println("
");
- printMessage(out, sql, MID, visitor, locale);
- printReplies(out, sql, MID, visitor, locale, listview);
+ com.juick.Message msg = printMessage(out, sql, MID, visitor, locale);
+ printReplies(out, sql, msg, visitor, locale, listview);
out.println("
");
out.println("
");
@@ -89,154 +85,163 @@ public class UserThread {
}
}
- public static void printMessage(PrintWriter out, Connection sql, int mid, com.juick.User visitor, Locale locale) {
+ public static com.juick.Message printMessage(PrintWriter out, Connection sql, int mid, com.juick.User visitor, Locale locale) {
ResourceBundle rb = ResourceBundle.getBundle("Global", locale);
ResourceBundle rbthread = ResourceBundle.getBundle("UserThread", locale);
- PreparedStatement stmt = null;
- ResultSet rs = null;
- try {
- stmt = sql.prepareStatement("SELECT STRAIGHT_JOIN messages.message_id,messages.user_id,users.nick,messages_txt.tags,messages.readonly,messages.privacy,messages_txt.txt,TIMESTAMPDIFF(MINUTE,messages.ts,NOW()),messages.ts,messages.replies,messages.attach,messages.place_id,places.name,messages.lat,messages.lon FROM ((messages INNER JOIN messages_txt ON messages.message_id=messages_txt.message_id) INNER JOIN users ON messages.user_id=users.id) LEFT JOIN places ON messages.place_id=places.place_id WHERE messages.message_id=?");
- stmt.setInt(1, mid);
- rs = stmt.executeQuery();
- if (rs.first()) {
- int uid = rs.getInt(2);
- String uname = rs.getString(3);
- String tags = rs.getString(4);
- String txt = rs.getString(7);
- // timediff
- // timestamp
- // replies
- // attach
- // pid
- // pname
- // lat
- // lon
-
- boolean cancomment = visitor != null;
-
- tags = (tags != null) ? PageTemplates.formatTags(new ArrayList
(Arrays.asList(tags.split(" ")))) : "";
- if (rs.getInt(5) == 1) {
- tags += " *readonly";
- cancomment = false;
- }
- switch (rs.getInt(6)) {
- case 2:
- tags += " *public";
- break;
- case -1:
- tags += " *friends";
- break;
- case -2:
- tags += " *private";
- break;
- }
+ com.juick.Message msg = MessagesQueries.getMessage(sql, mid);
- txt = PageTemplates.formatMessage(txt);
+ msg.VisitorCanComment = visitor != null;
- out.println("");
- out.println(" - ");
-
- out.println(" ");
- out.println(" ");
- out.println(" ");
- if (rs.getString(13) != null) {
- out.println("
" + rs.getString(14) + "
");
- }
- out.println(" " + txt + "
");
+ String tags = (msg.Tags.isEmpty()) ? "" : PageTemplates.formatTags(msg.Tags);
+ if (msg.ReadOnly) {
+ tags += " *readonly";
+ msg.VisitorCanComment = false;
+ }
+ switch (msg.Privacy) {
+ case 2:
+ tags += " *public";
+ break;
+ case -1:
+ tags += " *friends";
+ break;
+ case -2:
+ tags += " *private";
+ break;
+ }
- if (rs.getString(11) != null) {
- if (rs.getString(11).equals("jpg")) {
- out.println(" ");
- } else {
- out.println(" ");
- }
- }
+ out.println("