aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src/main/java/com/juick/www
diff options
context:
space:
mode:
Diffstat (limited to 'juick-www/src/main/java/com/juick/www')
-rw-r--r--juick-www/src/main/java/com/juick/www/controllers/Home.java22
-rw-r--r--juick-www/src/main/java/com/juick/www/controllers/NewMessage.java38
-rw-r--r--juick-www/src/main/java/com/juick/www/controllers/PM.java5
-rw-r--r--juick-www/src/main/java/com/juick/www/controllers/PageTemplates.java50
-rw-r--r--juick-www/src/main/java/com/juick/www/controllers/UserThread.java10
5 files changed, 71 insertions, 54 deletions
diff --git a/juick-www/src/main/java/com/juick/www/controllers/Home.java b/juick-www/src/main/java/com/juick/www/controllers/Home.java
index 2f9dc903..405a4bd6 100644
--- a/juick-www/src/main/java/com/juick/www/controllers/Home.java
+++ b/juick-www/src/main/java/com/juick/www/controllers/Home.java
@@ -176,15 +176,19 @@ public class Home {
if (visitor.getUid() > 0) {
out.println("<form action=\"/post\" method=\"post\" enctype=\"multipart/form-data\">");
out.println("<section id=\"newmessage\">");
- out.println(" <textarea name=\"body\" placeholder=\"Новое сообщение...\"></textarea>");
- out.println(" <div>");
- out.println(" <input type=\"text\" class=\"img\" name=\"img\" " +
- "placeholder=\"Ссылка на изображение (JPG/PNG, до 10Мб)\"/> " +
- "или <a href=\"#\">загрузить</a><br/>");
- out.println(" <input type=\"text\" class=\"tags\" name=\"tags\" " +
- "placeholder=\"Теги (через пробел)\"/><br/>");
- out.println(" <input type=\"submit\" class=\"subm\" value=\"Отправить\"/>");
- out.println(" </div>");
+ if (messagesService.isReadonly()) {
+ out.println("<p>Комментирование временно недоступно</p>");
+ } else {
+ out.println(" <textarea name=\"body\" placeholder=\"Новое сообщение...\"></textarea>");
+ out.println(" <div>");
+ out.println(" <input type=\"text\" class=\"img\" name=\"img\" " +
+ "placeholder=\"Ссылка на изображение (JPG/PNG, до 10Мб)\"/> " +
+ "или <a href=\"#\">загрузить</a><br/>");
+ out.println(" <input type=\"text\" class=\"tags\" name=\"tags\" " +
+ "placeholder=\"Теги (через пробел)\"/><br/>");
+ out.println(" <input type=\"submit\" class=\"subm\" value=\"Отправить\"/>");
+ out.println(" </div>");
+ }
out.println("</section>");
out.println("</form>");
}
diff --git a/juick-www/src/main/java/com/juick/www/controllers/NewMessage.java b/juick-www/src/main/java/com/juick/www/controllers/NewMessage.java
index b340546f..938cd338 100644
--- a/juick-www/src/main/java/com/juick/www/controllers/NewMessage.java
+++ b/juick-www/src/main/java/com/juick/www/controllers/NewMessage.java
@@ -98,26 +98,30 @@ public class NewMessage {
templates.pageNavigation(out, visitor, null);
out.println("<section id=\"content\" class=\"pagetext\">");
- out.println("<form action=\"/post2\" method=\"post\" id=\"postmsg\" enctype=\"multipart/form-data\">");
- out.println("<p style=\"text-align: left\"><b>Место: <span id=\"location\"></span></b> <span id=\"locationclear\">&mdash; <a href=\"#\" onclick=\"clearLocation()\">Отменить</a></span></p>");
- out.println("<p style=\"text-align: left\"><b>Фото:</b> <span id=\"attachmentfile\"><input type=\"file\" name=\"attach\"/> <i>(JPG, PNG, до 10Мб)</i></span></p>");
-
- String body = request.getParameter("body");
- if (body == null) {
- body = StringUtils.EMPTY;
+ if (messagesService.isReadonly()) {
+ out.println("<p>Временно недоступно</p>");
} else {
- if (body.length() > 4096) {
- body = body.substring(0, 4096);
+ out.println("<form action=\"/post2\" method=\"post\" id=\"postmsg\" enctype=\"multipart/form-data\">");
+ out.println("<p style=\"text-align: left\"><b>Место: <span id=\"location\"></span></b> <span id=\"locationclear\">&mdash; <a href=\"#\" onclick=\"clearLocation()\">Отменить</a></span></p>");
+ out.println("<p style=\"text-align: left\"><b>Фото:</b> <span id=\"attachmentfile\"><input type=\"file\" name=\"attach\"/> <i>(JPG, PNG, до 10Мб)</i></span></p>");
+
+ String body = request.getParameter("body");
+ if (body == null) {
+ body = StringUtils.EMPTY;
+ } else {
+ if (body.length() > 4096) {
+ body = body.substring(0, 4096);
+ }
+ body = StringEscapeUtils.escapeHtml4(body);
}
- body = StringEscapeUtils.escapeHtml4(body);
- }
- out.println("<p><textarea name=\"body\" class=\"newmessage\" rows=\"7\" cols=\"10\">" + body + "</textarea><br/>");
+ out.println("<p><textarea name=\"body\" class=\"newmessage\" rows=\"7\" cols=\"10\">" + body + "</textarea><br/>");
- out.println("<input type=\"hidden\" name=\"place_id\"/>" + "" + "<input type=\"submit\" class=\"subm\" value=\" Отправить \"/></p>");
- out.println("</form>");
- out.println("<div id=\"geomap\"></div>");
- out.println("<p style=\"text-align: left\"><b>Теги:</b></p>");
- printUserTags(out, visitor);
+ out.println("<input type=\"hidden\" name=\"place_id\"/>" + "" + "<input type=\"submit\" class=\"subm\" value=\" Отправить \"/></p>");
+ out.println("</form>");
+ out.println("<div id=\"geomap\"></div>");
+ out.println("<p style=\"text-align: left\"><b>Теги:</b></p>");
+ printUserTags(out, visitor);
+ }
out.println("</section>");
templates.pageFooter(request, out, visitor, false);
diff --git a/juick-www/src/main/java/com/juick/www/controllers/PM.java b/juick-www/src/main/java/com/juick/www/controllers/PM.java
index 56b688cf..028feabc 100644
--- a/juick-www/src/main/java/com/juick/www/controllers/PM.java
+++ b/juick-www/src/main/java/com/juick/www/controllers/PM.java
@@ -17,6 +17,7 @@
*/
package com.juick.www.controllers;
+import com.juick.service.MessagesService;
import com.juick.service.PMQueriesService;
import com.juick.service.TagService;
import com.juick.service.UserService;
@@ -55,6 +56,8 @@ public class PM {
@Inject
UserService userService;
@Inject
+ MessagesService messagesService;
+ @Inject
WebApp webApp;
@RequestMapping(value = "/pm/inbox", method = RequestMethod.GET)
@@ -70,6 +73,7 @@ public class PM {
model.addAttribute("visitor", visitor);
model.addAttribute("msgs", msgs);
model.addAttribute("tags", tagService.getPopularTags());
+ model.addAttribute("readonly", messagesService.isReadonly());
return "views/pm_inbox";
}
@@ -92,6 +96,7 @@ public class PM {
model.addAttribute("msgs", msgs);
model.addAttribute("tags", tagService.getPopularTags());
model.addAttribute("uname", uname);
+ model.addAttribute("readonly", messagesService.isReadonly());
return "views/pm_sent";
}
diff --git a/juick-www/src/main/java/com/juick/www/controllers/PageTemplates.java b/juick-www/src/main/java/com/juick/www/controllers/PageTemplates.java
index eb241f7d..6ee18732 100644
--- a/juick-www/src/main/java/com/juick/www/controllers/PageTemplates.java
+++ b/juick-www/src/main/java/com/juick/www/controllers/PageTemplates.java
@@ -81,9 +81,9 @@ public class PageTemplates {
out.println("</head>");
out.flush();
if (visitor.getUid() > 0) {
- out.println("<body id=\"body\" data-hash=\"" + visitor.getAuthHash() + "\">");
+ out.println("<body id=\"body\" data-hash=\"" + visitor.getAuthHash() + "\" data-readonly=\"" + messagesService.isReadonly() + "\">");
} else {
- out.println("<body id=\"body\">");
+ out.println("<body id=\"body\" data-readonly=\"" + messagesService.isReadonly() + "\">");
}
}
@@ -109,7 +109,9 @@ public class PageTemplates {
out.print("<li><a href=\"/?show=recommended\">Рекомендации</a></li>");
out.println("</ul></nav>");
out.print(" <nav id=\"actions\"><ul>");
- out.print("<li><a href=\"/#post\">Написать</a></li>");
+ if (!messagesService.isReadonly()) {
+ out.print("<li><a href=\"/#post\">Написать</a></li>");
+ }
out.print("<li><a href=\"/" + visitor.getName() + "\">@" + visitor.getName() + "</a></li>");
out.print("<li><a href=\"/logout\">Выйти</a></li>");
out.println("</ul></nav>");
@@ -345,27 +347,29 @@ public class PageTemplates {
if (msg.getAttachmentType() != null) {
out.println(" <div class=\"irbr\"></div>");
}
- out.print(" <nav class=\"l\">");
- msg.ReadOnly |= blUIDs.contains(msg.getUser().getUid());
- if (visitor.getUid() == 0) {
- out.print("<a href=\"#\" class=\"a-login\">Рекомендовать</a>");
- } else {
- out.print("<a href=\"/post?body=!+%23" + msg.getMid() + "\" class=\"a-like\">Рекомендовать</a>");
- }
- if (visitor.getUid() == 0 && !msg.ReadOnly) {
- out.print("<a href=\"/" + msg.getMid() + "\" class=\"a-login\">Комментировать</a> ");
- } else if (visitor.getUid() > 0 && (!msg.ReadOnly || visitor.getUid() == msg.getUser().getUid())) {
- out.print("<a class=\"a-comment\" href=\"/" + msg.getMid() + "\">Комментировать</a> ");
- }
- if (visitor.getUid() > 0 && msg.getPrivacy() < 0 && msg.getUser().getUid() == visitor.getUid()) {
- out.print(" <a href=\"#\" class=\"a-privacy\">Открыть доступ</a>");
- }
- if (visitor.getUid() > 0 && visitor.getUid() == 3694) {
- out.print(" <a href=\"#\" class=\"a-popular-plus\">+</a>");
- out.print(" <a href=\"#\" class=\"a-popular-minus\">-</a>");
- out.print(" <a href=\"#\" class=\"a-popular-delete\">x</a>");
+ if (!messagesService.isReadonly()) {
+ out.print(" <nav class=\"l\">");
+ msg.ReadOnly |= blUIDs.contains(msg.getUser().getUid());
+ if (visitor.getUid() == 0) {
+ out.print("<a href=\"#\" class=\"a-login\">Рекомендовать</a>");
+ } else {
+ out.print("<a href=\"/post?body=!+%23" + msg.getMid() + "\" class=\"a-like\">Рекомендовать</a>");
+ }
+ if (visitor.getUid() == 0 && !msg.ReadOnly) {
+ out.print("<a href=\"/" + msg.getMid() + "\" class=\"a-login\">Комментировать</a> ");
+ } else if (visitor.getUid() > 0 && (!msg.ReadOnly || visitor.getUid() == msg.getUser().getUid())) {
+ out.print("<a class=\"a-comment\" href=\"/" + msg.getMid() + "\">Комментировать</a> ");
+ }
+ if (visitor.getUid() > 0 && msg.getPrivacy() < 0 && msg.getUser().getUid() == visitor.getUid()) {
+ out.print(" <a href=\"#\" class=\"a-privacy\">Открыть доступ</a>");
+ }
+ if (visitor.getUid() > 0 && visitor.getUid() == 3694) {
+ out.print(" <a href=\"#\" class=\"a-popular-plus\">+</a>");
+ out.print(" <a href=\"#\" class=\"a-popular-minus\">-</a>");
+ out.print(" <a href=\"#\" class=\"a-popular-delete\">x</a>");
+ }
+ out.println("</nav>");
}
- out.println("</nav>");
out.print(" <nav class=\"s\">");
if (msg.getLikes() > 0) {
diff --git a/juick-www/src/main/java/com/juick/www/controllers/UserThread.java b/juick-www/src/main/java/com/juick/www/controllers/UserThread.java
index cde33a0e..7d3894a8 100644
--- a/juick-www/src/main/java/com/juick/www/controllers/UserThread.java
+++ b/juick-www/src/main/java/com/juick/www/controllers/UserThread.java
@@ -178,7 +178,7 @@ public class UserThread {
}
}
- if (msg.VisitorCanComment) {
+ if (msg.VisitorCanComment && !messagesService.isReadonly()) {
out.println(" <form action=\"/comment\" method=\"POST\" enctype=\"multipart/form-data\"><input type=\"hidden\" name=\"mid\" value=\"" + msg.getMid() + "\"/>");
out.println(" <div class=\"msg-comment\"><div class=\"ta-wrapper\"><textarea name=\"body\" rows=\"1\" class=\"reply\" placeholder=\"Написать комментарий\"></textarea></div></div>");
out.println(" </form>");
@@ -200,7 +200,7 @@ public class UserThread {
out.println(" <li id=\"mtoolbar\"><ul>");
out.println(" <li><a href=\"/" + msg.getMid() + "\"><div style=\"background-position: -64px 0\"></div>" + msg.getMid() + "</a></li>");
- if (visitor.getUid() > 0) {
+ if (visitor.getUid() > 0 && !messagesService.isReadonly()) {
if (visitor.getUid() != msg.getUser().getUid()) {
if (messagesService.isSubscribed(visitor.getUid(), msg.getMid())) {
out.println(" <li><a href=\"/post?body=U+%23" + msg.getMid() + "\"><div style=\"background-position: -48px 0\"></div>Подписан</a></li>");
@@ -336,10 +336,10 @@ public class UserThread {
if (msg.getReplyto() > 0) {
out.print(" в ответ на <a href=\"#" + msg.getReplyto() + "\">/" + msg.getReplyto() + "</a>");
}
- if (msg.VisitorCanComment) {
+ if (msg.VisitorCanComment && !messagesService.isReadonly()) {
out.println(" &#183; <a href=\"/post?body=%23" + msg.getMid() + "/" + msg.getRid() + "%20\" class=\"a-thread-comment\">Ответить</a></div>");
out.println(" <div class=\"msg-comment\" style=\"display: none\"></div>");
- } else if (visitor == null) {
+ } else if (visitor.getUid() == 0) {
out.println(" &#183; <a href=\"#\" class=\"a-login\">Ответить</a></div>");
}
@@ -382,7 +382,7 @@ public class UserThread {
if (msg.getReplyto() > 0) {
out.print(" в ответ на <a href=\"#" + msg.getReplyto() + "\">/" + msg.getReplyto() + "</a>");
}
- if (msg.VisitorCanComment) {
+ if (msg.VisitorCanComment && !messagesService.isReadonly()) {
out.println(" &#183; <a href=\"#\" class=\"a-thread-comment\">Ответить</a></div>");
out.println(" <div class=\"msg-comment\" style=\"display: none\"></div>");
} else if (visitor.getUid() == 0) {