From 34da94d887ae7be134d17c4bc9e101a8c198b300 Mon Sep 17 00:00:00 2001 From: Ugnich Anton Date: Mon, 20 Feb 2012 21:38:29 +0700 Subject: Bugfixes --- nbproject/project.properties | 1 + src/java/Global.properties | 4 +++ src/java/Global_ru.properties | 4 +++ src/java/com/juick/http/www/Blogs.java | 36 ++++++++++++++++++------ src/java/com/juick/http/www/Login.java | 4 +-- src/java/com/juick/http/www/Main.java | 2 +- src/java/com/juick/http/www/NewMessage.java | 12 ++++++-- src/java/com/juick/http/www/PageTemplates.java | 13 ++++++--- src/java/com/juick/http/www/UserThread.java | 38 ++++++++++++++++++++------ web/scripts3.js | 4 +-- web/style3.css | 19 +++++++++---- 11 files changed, 104 insertions(+), 33 deletions(-) diff --git a/nbproject/project.properties b/nbproject/project.properties index 1ae4ca76..3855d649 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -1,5 +1,6 @@ annotation.processing.enabled=true annotation.processing.enabled.in.editor=true +annotation.processing.processors.list= annotation.processing.run.all.processors=true annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output build.classes.dir=${build.web.dir}/WEB-INF/classes diff --git a/src/java/Global.properties b/src/java/Global.properties index ebede501..9f618c91 100644 --- a/src/java/Global.properties +++ b/src/java/Global.properties @@ -17,3 +17,7 @@ Newer=Newer (replies)\ by=by Comment=Comment Sponsored\ by=Sponsored by +Block\ user=Block user +Send\ private\ message=Send private message +Recommend\ message=Recommend message +in\ reply\ to=in reply to diff --git a/src/java/Global_ru.properties b/src/java/Global_ru.properties index 34d7418a..f87f4c75 100644 --- a/src/java/Global_ru.properties +++ b/src/java/Global_ru.properties @@ -17,3 +17,7 @@ Newer=\u041d\u043e\u0432\u044b\u0435 (replies)\ by=\u043e\u0442 Comment=\u041e\u0442\u0432\u0435\u0442\u0438\u0442\u044c Sponsored\ by=\u041f\u0440\u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0435 +Block\ user=\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 +Send\ private\ message=\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 +Recommend\ message=\u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 +in\ reply\ to=\u0432 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 diff --git a/src/java/com/juick/http/www/Blogs.java b/src/java/com/juick/http/www/Blogs.java index 1e212b7a..a1cfdeb0 100644 --- a/src/java/com/juick/http/www/Blogs.java +++ b/src/java/com/juick/http/www/Blogs.java @@ -83,17 +83,37 @@ public class Blogs { mids = MessagesQueries.getAll(sql, paramBefore); } } else if (paramShow.equals("my")) { - title = rb.getString("My feed"); - mids = MessagesQueries.getMyFeed(sql, visitor.UID, paramBefore); + if (visitor != null) { + title = rb.getString("My feed"); + mids = MessagesQueries.getMyFeed(sql, visitor.UID, paramBefore); + } else { + response.sendError(404); + return; + } } else if (paramShow.equals("private")) { - title = rb.getString("Private"); - mids = MessagesQueries.getPrivate(sql, visitor.UID, paramBefore); + if (visitor != null) { + title = rb.getString("Private"); + mids = MessagesQueries.getPrivate(sql, visitor.UID, paramBefore); + } else { + response.sendError(404); + return; + } } else if (paramShow.equals("incoming")) { - title = rb.getString("Incoming"); - mids = MessagesQueries.getIncoming(sql, visitor.UID, paramBefore); + if (visitor != null) { + title = rb.getString("Incoming"); + mids = MessagesQueries.getIncoming(sql, visitor.UID, paramBefore); + } else { + response.sendError(404); + return; + } } else if (paramShow.equals("recommended")) { - title = rb.getString("Recommended"); - mids = MessagesQueries.getRecommended(sql, visitor.UID, paramBefore); + if (visitor != null) { + title = rb.getString("Recommended"); + mids = MessagesQueries.getRecommended(sql, visitor.UID, paramBefore); + } else { + response.sendError(404); + return; + } } else if (paramShow.equals("top")) { title = rb.getString("Popular"); mids = MessagesQueries.getPopular(sql, paramBefore); diff --git a/src/java/com/juick/http/www/Login.java b/src/java/com/juick/http/www/Login.java index 1baf6e43..0006f9d0 100644 --- a/src/java/com/juick/http/www/Login.java +++ b/src/java/com/juick/http/www/Login.java @@ -73,7 +73,7 @@ public class Login { if (com.juick.server.UserQueries.getUIDbyHash(sql, hash) > 0) { Cookie c = new Cookie("hash", hash); c.setDomain(".juick.com"); - c.setMaxAge(0); + c.setMaxAge(365 * 24 * 60 * 60); response.addCookie(c); response.sendRedirect("/"); @@ -95,7 +95,7 @@ public class Login { String hash = com.juick.server.UserQueries.getHashByUID(sql, uid); Cookie c = new Cookie("hash", hash); c.setDomain(".juick.com"); - c.setMaxAge(0); + c.setMaxAge(365 * 24 * 60 * 60); response.addCookie(c); String referer = request.getHeader("Referer"); diff --git a/src/java/com/juick/http/www/Main.java b/src/java/com/juick/http/www/Main.java index b7f95a4a..910a554f 100644 --- a/src/java/com/juick/http/www/Main.java +++ b/src/java/com/juick/http/www/Main.java @@ -149,7 +149,7 @@ public class Main extends HttpServlet implements XmppListener { //TODO settings } else if (uri.matches("^/\\d+$")) { rootRedirects.doGetPostID(sql, request, response); - } else if (uri.matches("^/[^/]$")) { + } else if (uri.matches("^/[^/]+$")) { rootRedirects.doGetUsername(sql, request, response); } else if (uri.matches("^/.+/.*")) { String uriparts[] = uri.split("/"); diff --git a/src/java/com/juick/http/www/NewMessage.java b/src/java/com/juick/http/www/NewMessage.java index 1beacf62..d35af8f3 100644 --- a/src/java/com/juick/http/www/NewMessage.java +++ b/src/java/com/juick/http/www/NewMessage.java @@ -54,10 +54,18 @@ public class NewMessage { out.println("
"); out.println("
"); out.println("

" + rbnm.getString("Location") + ": " + rbnm.getString("Clear") + "

"); - out.println("

" + rbnm.getString("Attachment") + ": " + rbnm.getString("or") + " " + rbnm.getString("from webcam") + "
"); + out.println("

" + rbnm.getString("Attachment") + ": " + rbnm.getString("or") + " " + rbnm.getString("from webcam") + "
"); out.println("" + rbnm.getString("Photo_JPG") + "
" + rbnm.getString("Webcam photo") + " — " + rbnm.getString("Clear") + "

"); out.println("
"); - out.println("


"); + + String body = request.getParameter("body"); + if (body != null && body.length() < 4096) { + body = Utils.encodeHTML(body); + } else { + body = ""; + } + out.println("


"); + out.println("" + "" + "

"); out.println("
"); out.println("
"); diff --git a/src/java/com/juick/http/www/PageTemplates.java b/src/java/com/juick/http/www/PageTemplates.java index 4997f778..b7b2f536 100644 --- a/src/java/com/juick/http/www/PageTemplates.java +++ b/src/java/com/juick/http/www/PageTemplates.java @@ -62,7 +62,7 @@ public class PageTemplates { public static void pageNavigation(PrintWriter out, Locale loc, com.juick.User user) { ResourceBundle rb = ResourceBundle.getBundle("Global", loc); out.println("
"); - out.println("
\"Juick\"/
"); + out.println("
\"Juick\"/
"); out.println("
    "); out.println("
  • " + rb.getString("Blogs") + "
  • "); // out.println("
  • " + rb.getString("Chats") + "
  • "); @@ -324,9 +324,12 @@ public class PageTemplates { // lat // lon + boolean cancomment = true; + tags = (tags != null) ? formatTags(tags) : ""; if (rs.getInt(5) == 1) { tags += " *readonly"; + cancomment = false; } switch (rs.getInt(6)) { case 2: @@ -361,7 +364,9 @@ public class PageTemplates { out.println("
    \""
    "); out.println(" "); out.println("
    @" + uname + ":" + tags + "
    "); out.println("
    " + txt + "
    "); @@ -372,9 +377,9 @@ public class PageTemplates { repliesby = "..."; } out.println("
    " + formatReplies(rs.getInt(10), locale) + " " + rb.getString("(replies) by") + " " + repliesby + "
    "); - } else { + } else if (cancomment) { out.println("
    "); - out.println("
    "); + out.println("
    "); out.println("
    "); } out.println(" "); diff --git a/src/java/com/juick/http/www/UserThread.java b/src/java/com/juick/http/www/UserThread.java index eb3adfad..406698bf 100644 --- a/src/java/com/juick/http/www/UserThread.java +++ b/src/java/com/juick/http/www/UserThread.java @@ -17,6 +17,7 @@ */ package com.juick.http.www; +import com.juick.server.MessagesQueries; import com.juick.server.UserQueries; import java.io.IOException; import java.io.PrintWriter; @@ -41,6 +42,11 @@ public class UserThread { com.juick.User visitor = Utils.getVisitorUser(sql, request); Locale locale = request.getLocale(); + if (!MessagesQueries.canViewThread(sql, MID, visitor != null ? visitor.UID : 0)) { + response.sendError(403); + return; + } + boolean listview = false; String paramView = request.getParameter("view"); if (paramView != null) { @@ -65,6 +71,7 @@ public class UserThread { PageTemplates.pageNavigation(out, locale, visitor); PageTemplates.pageUserTitle(out, sql, locale, user, visitor); + out.println("
    "); out.println("
    "); @@ -105,9 +112,12 @@ public class UserThread { // lat // lon + boolean cancomment = true; + tags = (tags != null) ? PageTemplates.formatTags(tags) : ""; if (rs.getInt(5) == 1) { tags += " *readonly"; + cancomment = false; } switch (rs.getInt(6)) { case 2: @@ -139,14 +149,18 @@ public class UserThread { out.println("
    \""
    "); out.println(" "); out.println("
    @" + uname + ":" + tags + "
    "); out.println("
    " + txt + "
    "); - out.println("
    "); - out.println("
    "); - out.println("
    "); + if (cancomment) { + out.println("
    "); + out.println("
    "); + out.println("
    "); + } out.println(" "); out.println("
"); @@ -259,8 +273,9 @@ public class UserThread { } } out.println("
\""
"); - out.println("
" + PageTemplates.formatDate(msg.MinutesAgo, msg.TimestampString, locale) + "
    "); - out.println("
  • Under construction
  • "); + out.println(" "); out.println(" "); out.println("
    " + msg.Text + "
    "); @@ -297,12 +312,17 @@ public class UserThread { } } out.println("
    "); - out.println("
    " + PageTemplates.formatDate(msg.MinutesAgo, msg.TimestampString, locale) + "
      "); - out.println("
    • Under construction
    • "); + out.println(" "); out.println(" "); out.println("
      " + msg.Text + "
      "); - out.println(" "); + out.print("
      /" + msg.RID); + if (msg.ReplyTo > 0) { + out.print(" " + rb.getString("in reply to") + " /" + msg.ReplyTo + ""); + } + out.println(" · " + rb.getString("Comment") + "
      "); out.println("
      "); out.println(" "); } diff --git a/web/scripts3.js b/web/scripts3.js index 12e0aeee..f6e9cdef 100644 --- a/web/scripts3.js +++ b/web/scripts3.js @@ -39,9 +39,9 @@ function showCommentForm(mid,rid) { var c=$('#replies #'+rid+' .msg-comment'); c.wrap('
      '); c.before(''); - c.append(''); + c.append(''); } - $('#replies #'+rid+' .msg-links').hide(); +// $('#replies #'+rid+' .msg-links').hide(); $('#replies #'+rid+' .msg-comment').show(); $('#replies #'+rid+' textarea')[0].focus(); $('#replies #'+rid+' textarea').autoResize({ diff --git a/web/style3.css b/web/style3.css index 49add6f2..0678dc02 100644 --- a/web/style3.css +++ b/web/style3.css @@ -54,14 +54,17 @@ img { border: none; } #content .msg-ts a { font-size: small; } #content .msg-menu { margin: 0 8px; display: inline; position: relative; } #content .msg-menu img { vertical-align: top; } -#content .msg-menu ul { display: none; position: absolute; top: 20px; right: 0; width: 200px; margin: 0; padding: 5px; } -#content .msg-menu li { margin: 0; padding: 0; } -#content .msg-header { margin-left: 58px; } +#content .msg-menu ul { display: none; position: absolute; top: 20px; right: 0; width: 300px; margin: 0; padding: 5px; } +#content .msg-menu li { margin: 0; padding: 10px 5px; } +#content .msg-header { margin-left: 58px; overflow: hidden; } #content .msg-txt { margin-left: 58px; padding: 6px 0 0 0; } #content .msg-links { font-size: small; margin: 10px 0 0 68px; } #content .msg-comments { margin: 10px 0 0 58px; padding: 5px 20px; overflow: hidden; font-size: small; } #content .msg-comment { margin: 10px 0 0 58px; padding: 0px 0 0 20px; } -#content textarea { border: 1px solid; width: 556px; padding: 2px; resize: vertical; } +#content .msg-comment textarea { border: 1px solid; width: 500px; padding: 2px; resize: vertical; } +#content .msg-comment input { border: 1px solid; width: 50px; margin-left: 5px; vertical-align: top; } + +#content textarea.newmessage { border: 1px solid; width: 640px; padding: 2px; resize: vertical; } #chats li { margin: 16px; } @@ -101,8 +104,14 @@ a { color: #069; } #content .msg { border-color: #DDD; } #content .msg-comments { background: #F5F5F5; color: #999; } #content .msg-ts a { color: #999; } -#content textarea { border-color: #DDD; } +#content .msg-links { color: #999; } +#content .msg-comment textarea { border-color: #DDD; } +#content .msg-comment input { border-color: #CCC; background-color: #EEE; color: #999; } #content .msg-menu ul { background: #DDD; } +#content .msg-menu a { color: #000; } + +#content textarea.newmessage { border-color: #DDD; } + .title2 { background: #F0F0F0; } .page { background: #F0F0F0; } -- cgit v1.2.3