diff options
Diffstat (limited to 'src/java/com/juick/http/www/UserThread.java')
-rw-r--r-- | src/java/com/juick/http/www/UserThread.java | 70 |
1 files changed, 29 insertions, 41 deletions
diff --git a/src/java/com/juick/http/www/UserThread.java b/src/java/com/juick/http/www/UserThread.java index ff05cf4b..57c1a696 100644 --- a/src/java/com/juick/http/www/UserThread.java +++ b/src/java/com/juick/http/www/UserThread.java @@ -23,8 +23,6 @@ import java.io.IOException; import java.io.PrintWriter; import java.sql.Connection; import java.util.ArrayList; -import java.util.Locale; -import java.util.ResourceBundle; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -37,7 +35,6 @@ public class UserThread { protected void doGetThread(Connection sql, HttpServletRequest request, HttpServletResponse response, com.juick.User user, int MID) throws ServletException, IOException { com.juick.User visitor = Utils.getVisitorUser(sql, request, response); - Locale locale = request.getLocale(); if (!MessagesQueries.canViewThread(sql, MID, visitor != null ? visitor.UID : 0)) { response.sendError(403); @@ -65,25 +62,22 @@ public class UserThread { PrintWriter out = response.getWriter(); try { PageTemplates.pageHead(out, title, "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"@" + user.UName + "\" href=\"//rss.juick.com/" + user.UName + "/blog\"/>"); - PageTemplates.pageNavigation(out, locale, visitor, null); + PageTemplates.pageNavigation(out, visitor, null); out.println("<section id=\"content\" style=\"margin-left: 0; width: 100%\">"); - com.juick.Message msg = printMessage(out, sql, user, MID, visitor, locale); - printReplies(out, sql, msg, visitor, locale, listview); + com.juick.Message msg = printMessage(out, sql, user, MID, visitor); + printReplies(out, sql, msg, visitor, listview); out.println("</section>"); - PageTemplates.pageDialogTemplate(out, locale); - PageTemplates.pageFooter(request, out, locale, visitor, false); + PageTemplates.pageDialogTemplate(out); + PageTemplates.pageFooter(request, out, visitor, false); PageTemplates.pageEnd(out); } finally { out.close(); } } - public static com.juick.Message printMessage(PrintWriter out, Connection sql, com.juick.User user, int mid, com.juick.User visitor, Locale locale) { - ResourceBundle rb = ResourceBundle.getBundle("Global", locale); - ResourceBundle rbthread = ResourceBundle.getBundle("UserThread", locale); - + public static com.juick.Message printMessage(PrintWriter out, Connection sql, com.juick.User user, int mid, com.juick.User visitor) { com.juick.Message msg = MessagesQueries.getMessage(sql, mid); msg.VisitorCanComment = visitor != null; @@ -146,13 +140,13 @@ public class UserThread { 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\"><div class=\"ta-wrapper\"><textarea name=\"body\" rows=\"1\" class=\"reply\" placeholder=\"" + rb.getString("Add a comment") + "\" onkeypress=\"postformListener(this.form,event)\"></textarea></div></div>"); + out.println(" <div class=\"msg-comment\"><div class=\"ta-wrapper\"><textarea name=\"body\" rows=\"1\" class=\"reply\" placeholder=\"Написать комментарий\" onkeypress=\"postformListener(this.form,event)\"></textarea></div></div>"); out.println(" </form>"); } 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() + "): "); + out.print(" <div class=\"" + (msg.VisitorCanComment ? "msg-recomms" : "msg-comments") + "\">Рекомендовали (" + recomm.size() + "): "); for (int i = 0; i < recomm.size(); i++) { if (i > 0) { out.print(", "); @@ -169,15 +163,15 @@ public class UserThread { 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>"); + out.println(" <li><a href=\"/post?body=U+%23" + mid + "\"><div style=\"background-position: -48px 0\"></div>Подписан</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>"); + out.println(" <li><a href=\"/post?body=S+%23" + mid + "\"><div style=\"background-position: -16px 0\"></div>Подписаться</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(" <li><a href=\"/post?body=%21+%23" + mid + "\"><div style=\"background-position: -32px 0\"></div>Рекомендовать</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><a href=\"/post?body=D+%23" + mid + "\"><div style=\"background-position: 0\"></div>Удалить</a></li>"); } } out.println(" </ul></li>"); @@ -186,9 +180,7 @@ public class UserThread { return msg; } - 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); - + public static void printReplies(PrintWriter out, Connection sql, com.juick.Message msg, com.juick.User visitor, boolean listview) { ArrayList<com.juick.Message> replies = MessagesQueries.getReplies(sql, msg.MID); ArrayList<Integer> blUIDs = new ArrayList<Integer>(); @@ -242,22 +234,22 @@ public class UserThread { 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>"); + out.print("<a href=\"?view=tree\">Показать деревом</a>"); } else { 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> · </span>"); + out.print("<span id=\"unfoldall\"><a href=\"#\" onclick=\"$('#replies>li').show(); $('#replies .msg-comments').hide(); $('#unfoldall').hide(); return false\">Раскрыть все</a> · </span>"); } - out.print("<a href=\"?view=list\">" + rbuser.getString("View as list") + "</a>"); + out.print("<a href=\"?view=list\">Показать списком</a>"); } out.print("</div>"); - out.println(" <h2>" + rbuser.getString("Replies") + " (" + replies.size() + ")</h2>"); + out.println(" <h2>Ответы (" + replies.size() + ")</h2>"); out.println("</div>"); out.println("<ul id=\"replies\">"); if (listview) { - printList(out, replies, locale); + printList(out, replies); } else { - printTree(out, replies, 0, 0, false, locale); + printTree(out, replies, 0, 0, false); } out.println("</ul>"); @@ -268,9 +260,7 @@ public class UserThread { } } - 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); - + public static void printTree(PrintWriter out, ArrayList<com.juick.Message> replies, int ReplyTo, int margin, boolean hidden) { if (margin > 240) { margin = 240; } @@ -291,36 +281,34 @@ public class UserThread { out.println(" <div class=\"msg-cont\">"); out.println(" <div class=\"msg-menu\"><a href=\"#\" onclick=\"showMessageLinksDialog(" + msg.MID + "," + msg.RID + "); return false\"></a></div>"); out.println(" <div class=\"msg-header\"><a href=\"/" + msg.User.UName + "/\">@" + msg.User.UName + "</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-ts\"><a href=\"/" + msg.MID + "#" + msg.RID + "\" title=\"" + msg.TimestampString + " GMT\">" + PageTemplates.formatDate(msg.TimeAgo, msg.TimestampString) + "</a></div>"); out.println(" <div class=\"msg-txt\">" + PageTemplates.formatMessage(msg.Text) + "</div>"); if (msg.AttachmentType != null) { out.println(" <div class=\"msg-media\"><a href=\"//i.juick.com/p/" + msg.MID + "-" + msg.RID + "." + msg.AttachmentType + "\"><img src=\"//i.juick.com/photos-512/" + msg.MID + "-" + msg.RID + "." + msg.AttachmentType + "\" alt=\"\"/></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-links\"><a href=\"#\" onclick=\"return showCommentForm(" + msg.MID + "," + msg.RID + ")\">Ответить</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(" <div class=\"msg-comments\"><a href=\"#\" onclick=\"return showMoreReplies(" + msg.RID + ")\">" + PageTemplates.formatReplies(childs) + " more</a></div>"); } out.println(" </div>"); out.println(" </li>"); if (ReplyTo == 0 && childs > 1 && replies.size() > 10) { - printTree(out, msg.childs, msg.RID, margin + 20, true, locale); + printTree(out, msg.childs, msg.RID, margin + 20, true); } else if (childs > 0) { - printTree(out, msg.childs, msg.RID, margin + 20, hidden, locale); + printTree(out, msg.childs, msg.RID, margin + 20, hidden); } } } } - public static void printList(PrintWriter out, ArrayList<com.juick.Message> replies, Locale locale) { - ResourceBundle rb = ResourceBundle.getBundle("Global", locale); - + public static void printList(PrintWriter out, ArrayList<com.juick.Message> replies) { for (int i = 0; i < replies.size(); i++) { com.juick.Message msg = replies.get(i); @@ -329,17 +317,17 @@ public class UserThread { out.println(" <div class=\"msg-cont\">"); out.println(" <div class=\"msg-menu\"><a href=\"#\" onclick=\"showMessageLinksDialog(" + msg.MID + "," + msg.RID + "); return false\"></a></div>"); out.println(" <div class=\"msg-header\"><a href=\"/" + msg.User.UName + "/\">@" + msg.User.UName + "</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-ts\"><a href=\"/" + msg.MID + "#" + msg.RID + "\" title=\"" + msg.TimestampString + " GMT\">" + PageTemplates.formatDate(msg.TimeAgo, msg.TimestampString) + "</a></div>"); out.println(" <div class=\"msg-txt\">" + PageTemplates.formatMessage(msg.Text) + "</div>"); if (msg.AttachmentType != null) { out.println(" <div class=\"msg-media\"><a href=\"//i.juick.com/p/" + msg.MID + "-" + msg.RID + "." + msg.AttachmentType + "\"><img src=\"//i.juick.com/photos-512/" + msg.MID + "-" + msg.RID + "." + msg.AttachmentType + "\" alt=\"\"/></a></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.print(" в ответ на <a href=\"#" + msg.ReplyTo + "\">/" + msg.ReplyTo + "</a>"); } if (msg.VisitorCanComment) { - out.println(" · <a href=\"#\" onclick=\"return showCommentForm(" + msg.MID + "," + msg.RID + ")\">" + rb.getString("Comment") + "</a></div>"); + out.println(" · <a href=\"#\" onclick=\"return showCommentForm(" + msg.MID + "," + msg.RID + ")\">Ответить</a></div>"); out.println(" <div class=\"msg-comment\" style=\"display: none\"></div>"); } out.println(" </div>"); |