aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/java/User.properties5
-rw-r--r--src/java/User_ru.properties5
-rw-r--r--src/java/com/juick/http/www/PageTemplates.java40
-rw-r--r--src/java/com/juick/http/www/User.java14
-rw-r--r--src/java/com/juick/http/www/UserThread.java280
-rw-r--r--web/scripts3.js6
-rw-r--r--web/style3.css33
7 files changed, 205 insertions, 178 deletions
diff --git a/src/java/User.properties b/src/java/User.properties
index f3b563dba..3ed6bfa78 100644
--- a/src/java/User.properties
+++ b/src/java/User.properties
@@ -17,3 +17,8 @@ View\ as\ list=View as list
View\ as\ tree=View as tree
all=all
Search=Search
+(UToolbar)\ Subcribe=Subscribe
+(UToolbar)\ Subcribed=Subscribed
+(UToolbar)\ Block=Block user
+(UToolbar)\ Unblock=Unblock user
+(UToolbar)\ Private=Send a private message
diff --git a/src/java/User_ru.properties b/src/java/User_ru.properties
index fd38d0d5c..fab91cebc 100644
--- a/src/java/User_ru.properties
+++ b/src/java/User_ru.properties
@@ -17,3 +17,8 @@ View\ as\ list=\u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u043f\u04
View\ as\ tree=\u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0434\u0435\u0440\u0435\u0432\u043e\u043c
all=\u0432\u0441\u0435
Search=\u041f\u043e\u0438\u0441\u043a
+(UToolbar)\ Subcribe=\u041f\u043e\u0434\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f
+(UToolbar)\ Subcribed=\u041f\u043e\u0434\u043f\u0438\u0441\u0430\u043d
+(UToolbar)\ Block=\u0417\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f
+(UToolbar)\ Unblock=\u0420\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f
+(UToolbar)\ Private=\u041e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435
diff --git a/src/java/com/juick/http/www/PageTemplates.java b/src/java/com/juick/http/www/PageTemplates.java
index 41646e309..2ec42e421 100644
--- a/src/java/com/juick/http/www/PageTemplates.java
+++ b/src/java/com/juick/http/www/PageTemplates.java
@@ -48,17 +48,18 @@ public class PageTemplates {
private static SimpleDateFormat sdfSQL = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
private static SimpleDateFormat sdfSimple = new SimpleDateFormat("d MMM");
private static SimpleDateFormat sdfFull = new SimpleDateFormat("d MMM yyyy");
+ private static SimpleDateFormat sdfJS = new SimpleDateFormat("yyyy,MM,dd,HH,mm,ss");
public static void pageHead(PrintWriter out, String title, String headers) {
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println(" <title>" + title + "</title>");
- out.println(" <link rel=\"stylesheet\" href=\"//static.juick.com/style3.2012110200.css\"/>");
+ out.println(" <link rel=\"stylesheet\" href=\"//static.juick.com/style3.2012110404.css\"/>");
out.println(" <link rel=\"icon\" type=\"image/png\" href=\"//static.juick.com/favicon.png\"/>");
out.println(" <script type=\"text/javascript\" src=\"//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js\" defer=\"defer\"></script>");
out.println(" <script type=\"text/javascript\" src=\"//ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js\" defer=\"defer\" async=\"async\"></script>");
- out.println(" <script type=\"text/javascript\" src=\"//static.juick.com/scripts3.2012102203.js\" defer=\"defer\"></script>");
+ out.println(" <script type=\"text/javascript\" src=\"//static.juick.com/scripts3.2012110400.js\" defer=\"defer\"></script>");
if (headers != null) {
out.println(headers);
}
@@ -77,14 +78,12 @@ public class PageTemplates {
out.println(" </form>");
out.println(" <ul id=\"nav-right\">");
if (user != null) {
- out.println(" <li><a href=\"/post\">" + rb.getString("Post") + "</a></li>");
- out.println(" <li><a href=\"#\" onclick=\"$('#nav-menu').toggle(); return false\"><img src=\"//i.juick.com/as/" + user.UID + ".png\" alt=\"" + user.UName + "\"/>" + user.UName + "</a><ul id=\"nav-menu\">");
- out.println(" <li><a href=\"/" + user.UName + "/\">" + rb.getString("Blog") + "</a></li>");
- out.println(" <li><a href=\"/settings\">" + rb.getString("Settings") + "</a></li>");
- out.println(" <li><a href=\"/logout\">" + rb.getString("Logout") + "</a></li>");
- out.println(" </ul></li>");
+ out.println(" <li><a href=\"/post\" class=\"wide\">" + rb.getString("Post") + "</a></li>");
+ out.println(" <li><a href=\"/" + user.UName + "\" class=\"wide\"><img src=\"//i.juick.com/as/" + user.UID + ".png\" alt=\"" + user.UName + "\"/>" + user.UName + "</a></li>");
+ out.println(" <li><a href=\"/settings\"><div class=\"ico24\" style=\"background-position: 0 11px\"></div></a></li>");
+ out.println(" <li><a href=\"/logout\"><div class=\"ico24\" style=\"background-position: -24px 11px\"></div></a></li>");
} else {
- out.println(" <li><a href=\"/login\">" + rb.getString("Login") + "</a></li>");
+ out.println(" <li><a href=\"/login\" class=\"wide\">" + rb.getString("Login") + "</a></li>");
}
out.println(" </ul>");
out.println("</div>");
@@ -205,6 +204,19 @@ public class PageTemplates {
}
}
+ public static String formatJSLocalTime(String ts) {
+ try {
+ Date date = sdfSQL.parse(ts);
+ return "<script type=\"text/javascript\">"
+ + "var d=new Date(" + date.getTime() + ");"
+ + "document.write(d.getDate()+'.'+(d.getMonth()+1)+'.'+d.getFullYear()+' '+d.getHours()+':'+d.getMinutes());"
+ + "</script>";
+ } catch (ParseException e) {
+ System.err.print(e);
+ }
+ return "";
+ }
+
public static String formatReplies(int replies, Locale loc) {
return replies + " repl" + (replies % 10 == 1 ? "y" : "ies");
}
@@ -280,10 +292,12 @@ public class PageTemplates {
ArrayList<com.juick.Message> msgs = MessagesQueries.getMessages(sql, mids);
ArrayList<Integer> blUIDs = new ArrayList<Integer>(20);
- for (int i = 0; i < mids.size(); i++) {
- blUIDs.add(msgs.get(i).User.UID);
+ if (visitor != null) {
+ for (int i = 0; i < mids.size(); i++) {
+ blUIDs.add(msgs.get(i).User.UID);
+ }
+ blUIDs = UserQueries.checkBL(sql, visitor.UID, blUIDs);
}
- blUIDs = UserQueries.checkBL(sql, visitor.UID, blUIDs);
for (int i = 0; i < msgs.size(); i++) {
com.juick.Message msg = msgs.get(i);
@@ -306,7 +320,7 @@ public class PageTemplates {
out.println(" <li id=\"msg-" + msg.MID + "\" class=\"msg\">");
out.println(" <div class=\"msg-avatar\"><a href=\"/" + msg.User.UName + "/\"><img src=\"//i.juick.com/a/" + msg.User.UID + ".png\" alt=\"" + msg.User.UName + "\"/></a></div>");
- out.println(" <div class=\"msg-ts\"><a href=\"/" + msg.User.UName + "/" + msg.MID + "\" title=\"" + msg.TimestampString + "\">" + formatDate(msg.TimeAgo, msg.TimestampString, locale) + "</a></div>");
+ out.println(" <div class=\"msg-ts\"><a href=\"/" + msg.User.UName + "/" + msg.MID + "\" title=\"" + msg.TimestampString + " GMT\">" + formatDate(msg.TimeAgo, msg.TimestampString, locale) + "</a></div>");
out.println(" <div class=\"msg-header\"><a href=\"/" + msg.User.UName + "/\">@" + msg.User.UName + "</a>:" + tags + "</div>");
if (msg.Place != null) {
out.println(" <div class=\"msg-place\">" + msg.Place.name + "</div>");
diff --git a/src/java/com/juick/http/www/User.java b/src/java/com/juick/http/www/User.java
index f18968370..de0375f39 100644
--- a/src/java/com/juick/http/www/User.java
+++ b/src/java/com/juick/http/www/User.java
@@ -145,7 +145,7 @@ public class User {
try {
PageTemplates.pageHead(out, "@" + user.UName + ": " + rb.getString("(Menu) Tags"), null);
PageTemplates.pageNavigation(out, locale, visitor);
- PageTemplates.pageUserTitle(out, sql, locale, user, visitor);
+ //PageTemplates.pageUserTitle(out, sql, locale, user, visitor);
out.println("<div id=\"topwrapper\">");
out.println("<div id=\"wrapper\">");
@@ -172,7 +172,7 @@ public class User {
try {
PageTemplates.pageHead(out, "@" + user.UName + ": " + rb.getString("(Stats) I read"), null);
PageTemplates.pageNavigation(out, locale, visitor);
- PageTemplates.pageUserTitle(out, sql, locale, user, visitor);
+ //PageTemplates.pageUserTitle(out, sql, locale, user, visitor);
out.println("<div id=\"topwrapper\">");
out.println("<div id=\"wrapper\">");
@@ -270,17 +270,17 @@ public class User {
if (visitor != null && visitor.UID > 0 && visitor.UID != user.UID) {
out.println(" <ul id=\"ctoolbar\">");
if (UserQueries.isSubscribed(sql, visitor.UID, user.UID)) {
- out.println(" <li><a href=\"/post?body=U+%40" + user.UName + "\"><div style=\"background-position: -48px 0\"></div></a></li>");
+ out.println(" <li><a href=\"/post?body=U+%40" + user.UName + "\" title=\"" + rb.getString("(UToolbar) Subcribed") + "\"><div style=\"background-position: -48px 0\"></div></a></li>");
} else {
- out.println(" <li><a href=\"/post?body=S+%40" + user.UName + "\"><div style=\"background-position: -16px 0\"></div></a></li>");
+ out.println(" <li><a href=\"/post?body=S+%40" + user.UName + "\" title=\"" + rb.getString("(UToolbar) Subcribe") + "\"><div style=\"background-position: -16px 0\"></div></a></li>");
}
if (UserQueries.isInBL(sql, visitor.UID, user.UID)) {
- out.println(" <li><a href=\"/post?body=BL+%40" + user.UName + "\"><div style=\"background-position: -96px 0\"></div></a></li>");
+ out.println(" <li><a href=\"/post?body=BL+%40" + user.UName + "\" title=\"" + rb.getString("(UToolbar) Unblock") + "\"><div style=\"background-position: -96px 0\"></div></a></li>");
} else {
- out.println(" <li><a href=\"/post?body=BL+%40" + user.UName + "\"><div style=\"background-position: -80px 0\"></div></a></li>");
+ out.println(" <li><a href=\"/post?body=BL+%40" + user.UName + "\" title=\"" + rb.getString("(UToolbar) Block") + "\"><div style=\"background-position: -80px 0\"></div></a></li>");
}
if (!UserQueries.isInBL(sql, user.UID, visitor.UID)) {
- out.println(" <li><a href=\"/post?body=PM+%40" + user.UName + "\"><div style=\"background-position: -112px 0\"></div></a></li>");
+ out.println(" <li><a href=\"/post?body=PM+%40" + user.UName + "\" title=\"" + rb.getString("(UToolbar) Private") + "\"><div style=\"background-position: -112px 0\"></div></a></li>");
}
out.println(" </ul>");
} else {
diff --git a/src/java/com/juick/http/www/UserThread.java b/src/java/com/juick/http/www/UserThread.java
index ec3412f34..a0bb3a864 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("<div id=\"topwrapper\">");
out.println("<div id=\"wrapper\">");
out.println("<div id=\"content\" style=\"margin-left: 0; width: 100%\">");
- 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("</div>");
out.println("</div>");
@@ -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<String>(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("<ul>");
- out.println(" <li id=\"msg-" + mid + "\" class=\"msg msgthread\">");
-
- out.println(" <div class=\"msg-avatar\"><a href=\"/" + uname + "/\"><img src=\"//i.juick.com/a/" + uid + ".png\" alt=\"" + uname + "\"/></a></div>");
- out.println(" <div class=\"msg-ts\"><a href=\"/" + uname + "/" + mid + "\" title=\"" + rs.getString(9) + "\">" + PageTemplates.formatDate(rs.getInt(8), rs.getString(9), locale) + "</a></div>");
- out.println(" <div class=\"msg-header\"><a href=\"/" + uname + "/\">@" + uname + "</a>:" + tags + "</div>");
- if (rs.getString(13) != null) {
- out.println(" <div class=\"msg-place\">" + rs.getString(14) + "</div>");
- }
- out.println(" <div class=\"msg-txt\">" + txt + "</div>");
+ 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(" <div class=\"msg-media\"><a href=\"//i.juick.com/p/" + mid + ".jpg\"><img src=\"//i.juick.com/photos-512/" + mid + ".jpg\" alt=\"\"/></a></div>");
- } else {
- out.println(" <div class=\"msg-media\"><div id=\"video-" + mid + "\"><a href=\"//i.juick.com/video/" + mid + ".mp4\" onclick=\"inlinevideo(" + mid + "); return false\"><img src=\"//i.juick.com/thumbs/" + mid + ".jpg\" alt=\"\"/></a></div></div>");
- }
- }
+ out.println("<ul>");
+ out.println(" <li id=\"msg-" + mid + "\" class=\"msg msgthread\">");
+ out.println(" <div class=\"msg-avatar\"><a href=\"/" + msg.User.UName + "/\"><img src=\"//i.juick.com/a/" + msg.User.UID + ".png\" alt=\"" + msg.User.UName + "\"/></a></div>");
+ out.println(" <div class=\"msg-ts\">" + PageTemplates.formatJSLocalTime(msg.TimestampString) + "</div>");
+ out.println(" <div class=\"msg-header\"><a href=\"/" + msg.User.UName + "/\">@" + msg.User.UName + "</a>:" + tags + "</div>");
+ if (msg.Place != null && msg.Place.pid > 0) {
+ out.println(" <div class=\"msg-place\">" + msg.Place.name + "</div>");
+ }
+ out.println(" <div class=\"msg-txt\">" + PageTemplates.formatMessage(msg.Text) + "</div>");
- boolean visitorInBL = UserQueries.isInBL(sql, uid, visitor.UID);
+ if (msg.AttachmentType != null) {
+ if (msg.AttachmentType.equals("jpg")) {
+ out.println(" <div class=\"msg-media\"><a href=\"//i.juick.com/p/" + mid + ".jpg\"><img src=\"//i.juick.com/photos-512/" + mid + ".jpg\" alt=\"\"/></a></div>");
+ } else {
+ out.println(" <div class=\"msg-media\"><div id=\"video-" + mid + "\"><a href=\"//i.juick.com/video/" + mid + ".mp4\" onclick=\"inlinevideo(" + mid + "); return false\"><img src=\"//i.juick.com/thumbs/" + mid + ".jpg\" alt=\"\"/></a></div></div>");
+ }
+ }
+ boolean visitorInBL = false;
+ if (visitor != null) {
+ if (visitor.UID == msg.User.UID) {
+ msg.VisitorCanComment = true;
+ } else {
+ visitorInBL = UserQueries.isInBL(sql, msg.User.UID, visitor.UID);
if (visitorInBL) {
- cancomment = false;
- }
- if (visitor != null && visitor.UID == uid) {
- cancomment = true;
+ msg.VisitorCanComment = false;
}
+ }
+ }
- if (cancomment) {
- out.println(" <form action=\"/post\" method=\"POST\" enctype=\"multipart/form-data\"><input type=\"hidden\" name=\"mid\" value=\"" + mid + "\"/>");
- out.println(" <div class=\"msg-comment\"><textarea name=\"body\" rows=\"1\" class=\"reply\" placeholder=\"" + rb.getString("Add a comment") + "\" onkeypress=\"postformListener(this.form,event)\"></textarea></div>");
- out.println(" </form>");
- }
+ if (msg.VisitorCanComment) {
+ out.println(" <form action=\"/post\" method=\"POST\" enctype=\"multipart/form-data\"><input type=\"hidden\" name=\"mid\" value=\"" + mid + "\"/>");
+ out.println(" <div class=\"msg-comment\"><textarea name=\"body\" rows=\"1\" class=\"reply\" placeholder=\"" + rb.getString("Add a comment") + "\" onkeypress=\"postformListener(this.form,event)\"></textarea></div>");
+ out.println(" </form>");
+ }
- ArrayList<String> recomm = MessagesQueries.getMessageRecommendations(sql, mid);
- if (!recomm.isEmpty()) {
- out.print(" <div class=\"" + (cancomment ? "msg-recomms" : "msg-comments") + "\">" + rb.getString("Recommended by") + " (" + recomm.size() + "): ");
- for (int i = 0; i < recomm.size(); i++) {
- if (i > 0) {
- out.print(", ");
- }
- out.print("<a href=\"/" + recomm.get(i) + "/\">@" + recomm.get(i) + "</a>");
- }
+ ArrayList<String> recomm = MessagesQueries.getMessageRecommendations(sql, mid);
+ if (!recomm.isEmpty()) {
+ out.print(" <div class=\"" + (msg.VisitorCanComment ? "msg-recomms" : "msg-comments") + "\">" + rb.getString("Recommended by") + " (" + recomm.size() + "): ");
+ for (int i = 0; i < recomm.size(); i++) {
+ if (i > 0) {
+ out.print(", ");
}
+ out.print("<a href=\"/" + recomm.get(i) + "/\">@" + recomm.get(i) + "</a>");
+ }
+ }
- out.println(" </li>");
- out.println(" <li class=\"mtoolbar\"><ul>");
- out.println(" <li><a href=\"/" + mid + "\"><div style=\"background-position: -64px 0\"></div>" + mid + "</a></li>");
- if (visitor != null) {
- if (visitor.UID != uid) {
- if (MessagesQueries.isSubscribed(sql, visitor.UID, mid)) {
- out.println(" <li><a href=\"/post?body=U+%23" + mid + "\"><div style=\"background-position: -48px 0\"></div>" + rbthread.getString("(MToolbar) Subcribed") + "</a></li>");
- } else {
- out.println(" <li><a href=\"/post?body=S+%23" + mid + "\"><div style=\"background-position: -16px 0\"></div>" + rbthread.getString("(MToolbar) Subcribe") + "</a></li>");
- }
- if (!visitorInBL) {
- out.println(" <li><a href=\"/post?body=%21+%23" + mid + "\"><div style=\"background-position: -32px 0\"></div>" + rbthread.getString("(MToolbar) Recommend") + "</a></li>");
- }
- } else {
- out.println(" <li><a href=\"/post?body=D+%23" + mid + "\"><div style=\"background-position: 0\"></div>" + rbthread.getString("(MToolbar) Delete") + "</a></li>");
- }
+ out.println(" </li>");
+ out.println(" <li class=\"mtoolbar\"><ul>");
+ out.println(" <li><a href=\"/" + mid + "\"><div style=\"background-position: -64px 0\"></div>" + mid + "</a></li>");
+ if (visitor != null) {
+ if (visitor.UID != msg.User.UID) {
+ if (MessagesQueries.isSubscribed(sql, visitor.UID, mid)) {
+ out.println(" <li><a href=\"/post?body=U+%23" + mid + "\"><div style=\"background-position: -48px 0\"></div>" + rbthread.getString("(MToolbar) Subcribed") + "</a></li>");
+ } else {
+ out.println(" <li><a href=\"/post?body=S+%23" + mid + "\"><div style=\"background-position: -16px 0\"></div>" + rbthread.getString("(MToolbar) Subcribe") + "</a></li>");
+ }
+ if (!visitorInBL) {
+ out.println(" <li><a href=\"/post?body=%21+%23" + mid + "\"><div style=\"background-position: -32px 0\"></div>" + rbthread.getString("(MToolbar) Recommend") + "</a></li>");
}
- out.println(" </ul></li>");
- out.println("</ul>");
+ } else {
+ out.println(" <li><a href=\"/post?body=D+%23" + mid + "\"><div style=\"background-position: 0\"></div>" + rbthread.getString("(MToolbar) Delete") + "</a></li>");
}
- } catch (SQLException e) {
- System.err.println(e);
- } finally {
- Utils.finishSQL(rs, stmt);
}
+ out.println(" </ul></li>");
+ out.println("</ul>");
+ return msg;
}
- public static void printReplies(PrintWriter out, Connection sql, int mid, com.juick.User visitor, Locale locale, boolean listview) {
+ public static void printReplies(PrintWriter out, Connection sql, com.juick.Message msg, com.juick.User visitor, Locale locale, boolean listview) {
ResourceBundle rbuser = ResourceBundle.getBundle("User", locale);
- ArrayList<com.juick.Message> replies = MessagesQueries.getReplies(sql, mid);
+ ArrayList<com.juick.Message> replies = MessagesQueries.getReplies(sql, msg.MID);
+ ArrayList<Integer> blUIDs = new ArrayList<Integer>();
for (int i = 0; i < replies.size(); i++) {
- com.juick.Message msg = replies.get(i);
- if (msg.ReplyTo > 0) {
+ com.juick.Message reply = replies.get(i);
+ if (reply.User.UID != msg.User.UID && !blUIDs.contains(reply.User.UID)) {
+ blUIDs.add(reply.User.UID);
+ }
+ if (reply.ReplyTo > 0) {
boolean added = false;
for (int n = 0; n < replies.size(); n++) {
- if (replies.get(n).RID == msg.ReplyTo) {
- replies.get(n).childs.add(msg);
+ if (replies.get(n).RID == reply.ReplyTo) {
+ replies.get(n).childs.add(reply);
added = true;
break;
}
}
if (!added) {
- msg.ReplyTo = 0;
+ reply.ReplyTo = 0;
}
}
}
if (!replies.isEmpty()) {
+ if (visitor != null && msg.User.UID == visitor.UID) {
+ for (int i = 0; i < replies.size(); i++) {
+ replies.get(i).VisitorCanComment = true;
+ }
+ } else if (visitor != null && msg.VisitorCanComment) {
+ blUIDs = UserQueries.checkBL(sql, visitor.UID, blUIDs);
+ for (int i = 0; i < replies.size(); i++) {
+ com.juick.Message reply = replies.get(i);
+ reply.VisitorCanComment = reply.User.UID == visitor.UID || !blUIDs.contains(reply.User.UID);
+ }
+ } else {
+ for (int i = 0; i < replies.size(); i++) {
+ replies.get(i).VisitorCanComment = false;
+ }
+ }
+
+ boolean foldable = false;
+ if (replies.size() > 10) {
+ for (int i = 0; i < replies.size() - 1; i++) {
+ if (replies.get(i).getChildsCount() > 1) {
+ foldable = true;
+ break;
+ }
+ }
+ }
out.println("<div class=\"title2\">");
out.print(" <div class=\"title2-right\">");
if (listview) {
out.print("<a href=\"?view=tree\">" + rbuser.getString("View as tree") + "</a>");
} else {
- out.print("<span id=\"unfoldall\"><a href=\"#\" onclick=\"$('#replies>li').show(); $('#replies .msg-comments').hide(); $('#unfoldall').hide(); return false\">" + rbuser.getString("Expand all") + "</a> &#183; </span><a href=\"?view=list\">" + rbuser.getString("View as list") + "</a>");
+ if (foldable) {
+ out.print("<span id=\"unfoldall\"><a href=\"#\" onclick=\"$('#replies>li').show(); $('#replies .msg-comments').hide(); $('#unfoldall').hide(); return false\">" + rbuser.getString("Expand all") + "</a> &#183; </span>");
+ }
+ out.print("<a href=\"?view=list\">" + rbuser.getString("View as list") + "</a>");
}
out.print("</div>");
out.println(" <h2>" + rbuser.getString("Replies") + " (" + replies.size() + ")</h2>");
@@ -246,18 +251,18 @@ public class UserThread {
if (listview) {
printList(out, replies, locale);
} else {
- printTree(out, replies, 0, 0, locale);
+ printTree(out, replies, 0, 0, false, locale);
}
out.println("</ul>");
- }
- for (int i = 0; i < replies.size(); i++) {
- replies.get(i).cleanupChilds();
+ for (int i = 0; i < replies.size(); i++) {
+ replies.get(i).cleanupChilds();
+ }
+ replies.clear();
}
- replies.clear();
}
- public static void printTree(PrintWriter out, ArrayList<com.juick.Message> replies, int ReplyTo, int margin, Locale locale) {
+ public static void printTree(PrintWriter out, ArrayList<com.juick.Message> replies, int ReplyTo, int margin, boolean hidden, Locale locale) {
ResourceBundle rb = ResourceBundle.getBundle("Global", locale);
if (margin > 420) {
@@ -273,7 +278,10 @@ public class UserThread {
out.print("border: 0;");
}
if (margin > 0) {
- out.print("margin-left: " + margin + "px;display:none;");
+ out.print("margin-left: " + margin + "px;");
+ }
+ if (hidden) {
+ out.print("display:none;");
}
out.println("\">");
if (msg.AttachmentType != null) {
@@ -284,20 +292,26 @@ public class UserThread {
}
}
out.println(" <div class=\"msg-avatar\"><a href=\"/" + msg.User.UName + "/\"><img src=\"//i.juick.com/a/" + msg.User.UID + ".png\" alt=\"" + msg.User.UName + "\"/></a></div>");
- out.println(" <div class=\"msg-ts\"><a href=\"/" + msg.MID + "#" + msg.RID + "\" title=\"" + msg.TimestampString + "\">" + PageTemplates.formatDate(msg.TimeAgo, msg.TimestampString, locale) + "</a></div>");
+ out.println(" <div class=\"msg-ts\"><a href=\"/" + msg.MID + "#" + msg.RID + "\" title=\"" + msg.TimestampString + " GMT\">" + PageTemplates.formatDate(msg.TimeAgo, msg.TimestampString, locale) + "</a></div>");
out.println(" <div class=\"msg-header\"><a href=\"/" + msg.User.UName + "/\">@" + msg.User.UName + "</a>:</div>");
out.println(" <div class=\"msg-txt\">" + PageTemplates.formatMessage(msg.Text) + "</div>");
- out.println(" <div class=\"msg-links\"><a href=\"#\" onclick=\"return showCommentForm(" + msg.MID + "," + msg.RID + ")\">" + rb.getString("Comment") + "</a></div>");
- out.println(" <div class=\"msg-comment\" style=\"display: none\"></div>");
- if (ReplyTo == 0) {
- int childs = msg.getChildsCount() - 1;
- if (childs > 0) {
- out.println(" <div class=\"msg-comments\"><a href=\"#\" onclick=\"return showMoreReplies(" + msg.RID + ")\">" + PageTemplates.formatReplies(childs, locale) + " more</a></div>");
- }
+ if (msg.VisitorCanComment) {
+ out.println(" <div class=\"msg-links\"><a href=\"#\" onclick=\"return showCommentForm(" + msg.MID + "," + msg.RID + ")\">" + rb.getString("Comment") + "</a></div>");
+ out.println(" <div class=\"msg-comment\" style=\"display: none\"></div>");
+ }
+
+ int childs = msg.getChildsCount();
+ if (ReplyTo == 0 && childs > 1 && replies.size() > 10) {
+ out.println(" <div class=\"msg-comments\"><a href=\"#\" onclick=\"return showMoreReplies(" + msg.RID + ")\">" + PageTemplates.formatReplies(childs, locale) + " more</a></div>");
+
}
out.println(" </li>");
- printTree(out, replies, msg.RID, margin + 20, locale);
+ if (ReplyTo == 0 && childs > 1 && replies.size() > 10) {
+ printTree(out, msg.childs, msg.RID, margin + 20, true, locale);
+ } else if (childs > 0) {
+ printTree(out, msg.childs, msg.RID, margin + 20, hidden, locale);
+ }
}
}
}
@@ -317,15 +331,17 @@ public class UserThread {
}
}
out.println(" <div class=\"msg-avatar\"><a href=\"/" + msg.User.UName + "/\"><img src=\"//i.juick.com/a/" + msg.User.UID + ".png\"></a></div>");
- out.println(" <div class=\"msg-ts\"><a href=\"/" + msg.MID + "#" + msg.RID + "\" title=\"" + msg.TimestampString + "\">" + PageTemplates.formatDate(msg.TimeAgo, msg.TimestampString, locale) + "</a></div>");
+ out.println(" <div class=\"msg-ts\"><a href=\"/" + msg.MID + "#" + msg.RID + "\" title=\"" + msg.TimestampString + " GMT\">" + PageTemplates.formatDate(msg.TimeAgo, msg.TimestampString, locale) + "</a></div>");
out.println(" <div class=\"msg-header\"><a href=\"/" + msg.User.UName + "/\">@" + msg.User.UName + "</a>:</div>");
out.println(" <div class=\"msg-txt\">" + PageTemplates.formatMessage(msg.Text) + "</div>");
out.print(" <div class=\"msg-links\">/" + msg.RID);
if (msg.ReplyTo > 0) {
out.print(" " + rb.getString("in reply to") + " <a href=\"#" + msg.ReplyTo + "\">/" + msg.ReplyTo + "</a>");
}
- out.println(" &#183; <a href=\"#\" onclick=\"return showCommentForm(" + msg.MID + "," + msg.RID + ")\">" + rb.getString("Comment") + "</a></div>");
- out.println(" <div class=\"msg-comment\" style=\"display: none\"></div>");
+ if (msg.VisitorCanComment) {
+ out.println(" &#183; <a href=\"#\" onclick=\"return showCommentForm(" + msg.MID + "," + msg.RID + ")\">" + rb.getString("Comment") + "</a></div>");
+ out.println(" <div class=\"msg-comment\" style=\"display: none\"></div>");
+ }
out.println(" </li>");
}
}
diff --git a/web/scripts3.js b/web/scripts3.js
index c0de77574..1a5ffd661 100644
--- a/web/scripts3.js
+++ b/web/scripts3.js
@@ -1,8 +1,8 @@
function inlinevideo(mid) {
var flashvars={
- file:'//i.juick.com/video/'+mid+'.mp4',
- image:'//i.juick.com/thumbs/'+mid+'.jpg',
- skin:'//static.juick.com/glow.zip',
+ file:'http://i.juick.com/video/'+mid+'.mp4',
+ image:'http://i.juick.com/thumbs/'+mid+'.jpg',
+ skin:'http://static.juick.com/glow.zip',
autostart:'true'
};
var params={
diff --git a/web/style3.css b/web/style3.css
index 9612d0fac..2649de776 100644
--- a/web/style3.css
+++ b/web/style3.css
@@ -14,26 +14,15 @@ img { border: none; }
#logo { float: left; margin: 3px 0 0 30px; }
#header a { text-decoration: none; font-size: 18px; }
-#search { float: left; margin: 10px 0 0 33px; }
+#search { float: left; margin: 10px 0 0 51px; }
#search .text { width: 285px; padding: 4px; border-radius: 2px; }
#nav-right { float: right; }
#nav-right li { float: left; }
-
-#header ul a { display: block; line-height: 48px; padding: 0 20px 0 20px; }
-#nav-right img { vertical-align: middle; margin: 0 4px 0 0; }
-#nav-menu { display: none; position: absolute; z-index: 1; }
-#nav-menu li { float: none; }
-
-/********/
-
-#title { display: none; clear: both; width: 100%; }
-#title>h1 { margin: 20px auto; font-size: 28px; }
-#title-av { width: 100px; height: 100px; margin-left: 20px; float: left; }
-#title-av img { vertical-align: top; padding: 2px; }
-#title-stats { width: 200px; float: right; border-left: 1px solid; }
-#title-stats ul { margin: 10px 0 10px 20px; }
-#title-username { margin: 0 220px 0 140px; }
+#nav-right a { display: block; line-height: 48px; padding: 0 15px; }
+#nav-right .wide { padding: 0 20px; }
+#nav-right img { max-width: 32px; max-height: 32px; vertical-align: middle; margin: 0 4px 0 0; }
+#nav-right .ico24 { width: 24px; height: 24px; background: url(//static.juick.com/icons24.png) no-repeat; padding: 12px 0; }
/********/
@@ -55,11 +44,10 @@ img { border: none; }
#content .msgthread { margin-bottom: 0; }
#content .msg-avatar { float: left; }
#content .msg-avatar img { width: 48px; height: 48px; vertical-align: top; }
-#content .msg-ts { float: right; }
-#content .msg-ts>a { font-size: small; vertical-align: top; }
+#content .msg-ts { float: right; font-size: small; vertical-align: top; }
#content .msg-header { margin-left: 58px; overflow: hidden; }
#content .msg-place { font-size: small; margin: 8px 0 8px 58px; }
-#content .msg-txt { margin: 8px 0 8px 58px; }
+#content .msg-txt { margin: 8px 0 8px 58px; overflow: hidden; }
#content .msg-media { text-align: center; margin: 8px 0 0px 58px; }
#content .msg-links { font-size: small; margin: 8px 0 0 68px; }
#content .msg-comments { margin: 10px 0 0 58px; padding: 5px 0 0 10px; overflow: hidden; font-size: small; border-top: 1px solid; }
@@ -117,10 +105,9 @@ table.users img { width: 32px; height: 32px; vertical-align: middle; margin-righ
html { background: #EEEEE5; color: #000; }
a { color: #069; }
#hwrapper { background: #333; }
-#header a { color: #AAA; }
-#header li a:hover { background: #444; }
+#nav-right a { color: #AAA; }
+#nav-right a:hover { background: #444; }
#title { background: #F0F0F0; }
-#nav-menu { background: #DDD; }
#title-stats { border-color: #CCC; }
#search .text { border: none; background-color: #EEE; }
@@ -130,7 +117,7 @@ a { color: #069; }
#content .msgthread { border-bottom-color: #CCC; }
#content .msg-place { color: #999; }
#content .msg-comments { color: #AAA; border-color: #DDD; }
-#content .msg-ts>a { color: #999; }
+#content .msg-ts, .msg-ts>a { color: #999; }
#content .msg-links { color: #999; }
#content .msg-comment textarea { border-color: #DDD; }
#content .msg-comment input { border-color: #CCC; background-color: #EEE; color: #999; }