From 51d9de02265d6cc9d6045d79497d2a987ae2f7f7 Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Tue, 15 Nov 2016 14:21:27 +0300
Subject: core classes are now serializeable with JAXB (to use as babbler
extension)
---
.../src/main/java/com/juick/www/Discover.java | 4 +-
juick-www/src/main/java/com/juick/www/Home.java | 24 ++--
juick-www/src/main/java/com/juick/www/Login.java | 6 +-
juick-www/src/main/java/com/juick/www/Main.java | 26 ++--
.../src/main/java/com/juick/www/NewMessage.java | 34 +++---
juick-www/src/main/java/com/juick/www/PM.java | 14 +--
.../src/main/java/com/juick/www/PageTemplates.java | 54 ++++-----
.../src/main/java/com/juick/www/Settings.java | 54 ++++-----
juick-www/src/main/java/com/juick/www/SignUp.java | 4 +-
.../src/main/java/com/juick/www/TwitterAuth.java | 2 +-
juick-www/src/main/java/com/juick/www/User.java | 104 ++++++++--------
.../src/main/java/com/juick/www/UserThread.java | 134 ++++++++++-----------
juick-www/src/main/java/com/juick/www/Utils.java | 4 +-
juick-www/src/main/resources/views/pm_inbox.html | 8 +-
juick-www/src/main/resources/views/pm_sent.html | 6 +-
15 files changed, 239 insertions(+), 239 deletions(-)
(limited to 'juick-www/src/main')
diff --git a/juick-www/src/main/java/com/juick/www/Discover.java b/juick-www/src/main/java/com/juick/www/Discover.java
index 4fd8c3b6..860ad893 100644
--- a/juick-www/src/main/java/com/juick/www/Discover.java
+++ b/juick-www/src/main/java/com/juick/www/Discover.java
@@ -72,7 +72,7 @@ public class Discover {
}
}
- int visitor_uid = visitor.getUID();
+ int visitor_uid = visitor.getUid();
String title = "*" + StringEscapeUtils.escapeHtml4(paramTag.getName());
List mids = MessagesQueries.getTag(sql, paramTag.TID, visitor_uid, paramBefore, (visitor_uid == 0) ? 40 : 20);
@@ -91,7 +91,7 @@ public class Discover {
out.println("");
if (mids.size() > 0) {
- int vuid = visitor.getUID();
+ int vuid = visitor.getUid();
int ad_mid = AdsQueries.getAdMID(sql, vuid);
if (ad_mid > 0 && mids.indexOf(ad_mid) == -1) {
mids.add(0, ad_mid);
diff --git a/juick-www/src/main/java/com/juick/www/Home.java b/juick-www/src/main/java/com/juick/www/Home.java
index d8688b68..870c2d55 100644
--- a/juick-www/src/main/java/com/juick/www/Home.java
+++ b/juick-www/src/main/java/com/juick/www/Home.java
@@ -53,9 +53,9 @@ public class Home {
title = "Поиск: " + StringEscapeUtils.escapeHtml4(paramSearch);
mids = MessagesQueries.getSearch(sql, sqlSearch, Utils.encodeSphinx(paramSearch), paramBefore);
} else if (paramShow == null) {
- if (visitor.getUID() > 0) {
+ if (visitor.getUid() > 0) {
title = "Популярные";
- mids = MessagesQueries.getPopular(sql, visitor.getUID(), paramBefore);
+ mids = MessagesQueries.getPopular(sql, visitor.getUid(), paramBefore);
} else {
title = "Микроблоги Juick: популярные записи";
mids = MessagesQueries.getPopular(sql, 0, paramBefore);
@@ -66,27 +66,27 @@ public class Home {
return;
} else if (paramShow.equals("my") && visitor != null) {
title = "Моя лента";
- mids = MessagesQueries.getMyFeed(sql, visitor.getUID(), paramBefore);
+ mids = MessagesQueries.getMyFeed(sql, visitor.getUid(), paramBefore);
} else if (paramShow.equals("private") && visitor != null) {
title = "Приватные";
- mids = MessagesQueries.getPrivate(sql, visitor.getUID(), paramBefore);
+ mids = MessagesQueries.getPrivate(sql, visitor.getUid(), paramBefore);
} else if (paramShow.equals("discuss") && visitor != null) {
title = "Обсуждения";
- mids = MessagesQueries.getDiscussions(sql, visitor.getUID(), paramBefore);
+ mids = MessagesQueries.getDiscussions(sql, visitor.getUid(), paramBefore);
} else if (paramShow.equals("recommended") && visitor != null) {
title = "Рекомендации";
- mids = MessagesQueries.getRecommended(sql, visitor.getUID(), paramBefore);
+ mids = MessagesQueries.getRecommended(sql, visitor.getUid(), paramBefore);
} else if (paramShow.equals("photos")) {
title = "Фотографии";
if (visitor != null) {
- mids = MessagesQueries.getPhotos(sql, visitor.getUID(), paramBefore);
+ mids = MessagesQueries.getPhotos(sql, visitor.getUid(), paramBefore);
} else {
mids = MessagesQueries.getPhotos(sql, 0, paramBefore);
}
} else if (paramShow.equals("all")) {
title = "Все сообщения";
if (visitor != null) {
- mids = MessagesQueries.getAll(sql, visitor.getUID(), paramBefore);
+ mids = MessagesQueries.getAll(sql, visitor.getUid(), paramBefore);
} else {
mids = MessagesQueries.getAll(sql, 0, paramBefore);
}
@@ -110,7 +110,7 @@ public class Home {
out.println("");
}
- if (visitor.getUID() > 0) {
+ if (visitor.getUid() > 0) {
out.println("");
out.println(" ");
- if (visitor.getUID() > 0) {
+ if (visitor.getUid() > 0) {
out.print(" ");
out.print("Моя лента ");
out.print("Приватные ");
@@ -102,7 +102,7 @@ public class PageTemplates {
out.println(" ");
out.print(" ");
} else {
@@ -151,7 +151,7 @@ public class PageTemplates {
String queryString = request.getQueryString();
String requestURI = request.getRequestURI();
- if (sapeon && sape != null && (visitor.getUID() == 0 || visitor.getUID() == 1) && queryString == null) {
+ if (sapeon && sape != null && (visitor.getUid() == 0 || visitor.getUid() == 1) && queryString == null) {
String links = sape.getPageLinks(requestURI, request.getCookies()).render();
if (links != null && !links.isEmpty()) {
out.print(" Спонсоры: " + links);
@@ -284,7 +284,7 @@ public class PageTemplates {
for (int i = 0; i < msgs.size(); i++) {
com.juick.Message msg = msgs.get(i);
- if (msg.getMID() == ad_mid) {
+ if (msg.getMid() == ad_mid) {
msgs.remove(i);
msgs.add(0, msg);
break;
@@ -294,43 +294,43 @@ public class PageTemplates {
List blUIDs = new ArrayList(20);
if (visitor != null) {
for (Message msg : msgs) {
- blUIDs.add(msg.getUser().getUID());
+ blUIDs.add(msg.getUser().getUid());
}
- blUIDs = UserQueries.checkBL(sql, visitor.getUID(), blUIDs);
+ blUIDs = UserQueries.checkBL(sql, visitor.getUid(), blUIDs);
}
for (Message msg : msgs) {
- List tags = MessagesQueries.getMessageTags(sql, msg.getMID());
+ List tags = MessagesQueries.getMessageTags(sql, msg.getMid());
String tagsStr = formatTags(tags);
if (msg.ReadOnly) {
tagsStr += "readonly ";
}
- if (msg.Privacy < 0) {
+ if (msg.getPrivacy() < 0) {
tagsStr += "friends ";
}
- if (msg.getMID() == ad_mid) {
+ if (msg.getMid() == ad_mid) {
tagsStr += "реклама ";
}
String txt;
- if (msg.Tags.stream().anyMatch(t -> t.getName().equals("code"))) {
+ if (msg.getTags().stream().anyMatch(t -> t.getName().equals("code"))) {
txt = Utils.formatMessageCode(msg.getText());
} else {
txt = Utils.formatMessage(msg.getText());
}
- out.println("");
+ out.println("");
out.println(" ");
if (msg.AttachmentType != null) {
- String fname = msg.getMID() + "." + msg.AttachmentType;
+ String fname = msg.getMid() + "." + msg.AttachmentType;
out.println("
");
}
out.println(" " + txt + "
");
@@ -338,21 +338,21 @@ public class PageTemplates {
out.println("
");
}
out.print(" ");
- msg.ReadOnly |= blUIDs.contains(msg.getUser().getUID());
- if (visitor.getUID() == 0) {
+ msg.ReadOnly |= blUIDs.contains(msg.getUser().getUid());
+ if (visitor.getUid() == 0) {
out.print("Мне нравится ");
} else {
- out.print("Мне нравится ");
+ out.print("Мне нравится ");
}
- if (visitor.getUID() == 0 && !msg.ReadOnly) {
- out.print("Комментировать ");
- } else if (visitor.getUID() > 0 && (!msg.ReadOnly || visitor.getUID() == msg.getUser().getUID())) {
- out.print(" ");
+ if (visitor.getUid() == 0 && !msg.ReadOnly) {
+ out.print("Комментировать ");
+ } else if (visitor.getUid() > 0 && (!msg.ReadOnly || visitor.getUid() == msg.getUser().getUid())) {
+ out.print(" ");
}
- if (visitor.getUID() > 0 && msg.Privacy < 0 && msg.getUser().getUID() == visitor.getUID()) {
+ if (visitor.getUid() > 0 && msg.getPrivacy() < 0 && msg.getUser().getUid() == visitor.getUid()) {
out.print(" Открыть доступ ");
}
- if (visitor.getUID() > 0 && visitor.getUID() == 3694) {
+ if (visitor.getUid() > 0 && visitor.getUid() == 3694) {
out.print(" + ");
out.print(" - ");
out.print(" x ");
@@ -361,10 +361,10 @@ public class PageTemplates {
out.print(" ");
if (msg.Likes > 0) {
- out.print(" " + msg.Likes + " ");
+ out.print(" " + msg.Likes + " ");
}
if (msg.Replies > 0) {
- out.print(" " + msg.Replies + " ");
+ out.print(" " + msg.Replies + " ");
}
out.println(" ");
out.print(" ");
diff --git a/juick-www/src/main/java/com/juick/www/Settings.java b/juick-www/src/main/java/com/juick/www/Settings.java
index 6be16acc..5c25564f 100644
--- a/juick-www/src/main/java/com/juick/www/Settings.java
+++ b/juick-www/src/main/java/com/juick/www/Settings.java
@@ -71,7 +71,7 @@ public class Settings {
protected void doGet(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, PebbleException {
com.juick.User visitor = Utils.getVisitorUser(sql, request, response);
- if (visitor.getUID() == 0) {
+ if (visitor.getUid() == 0) {
response.sendRedirect("/login");
}
List pages = Arrays.asList("main", "password", "about", "auth-email", "privacy");
@@ -95,17 +95,17 @@ public class Settings {
List hours = IntStream.rangeClosed(0, 23).boxed()
.map(i -> StringUtils.leftPad(String.format("%d", i), 2, "0")).collect(Collectors.toList());
context.put("hours", hours);
- context.put("fbstatus", CrosspostQueries.isFBCrossPostEnabled(sql, visitor.getUID()));
- context.put("twitter_name", CrosspostQueries.getTwitterName(sql, visitor.getUID()));
- context.put("telegram_name", CrosspostQueries.getTelegramName(sql, visitor.getUID()));
+ context.put("fbstatus", CrosspostQueries.isFBCrossPostEnabled(sql, visitor.getUid()));
+ context.put("twitter_name", CrosspostQueries.getTwitterName(sql, visitor.getUid()));
+ context.put("telegram_name", CrosspostQueries.getTelegramName(sql, visitor.getUid()));
context.put("notify_options", SubscriptionsQueries.getNotifyOptions(sql, visitor));
context.put("userinfo", UserQueries.getUserInfo(sql, visitor));
if (page.equals("auth-email")) {
try {
String account = sql.queryForObject("SELECT account FROM auth WHERE user_id=? AND protocol='email' AND authcode=?",
- String.class, visitor.getUID(), request.getParameter("code"));
- sql.update("INSERT INTO emails(user_id,email) VALUES (?,?)", visitor.getUID(), account);
- sql.update("DELETE FROM auth WHERE user_id=? AND authcode=?", visitor.getUID(), request.getParameter("code"));
+ String.class, visitor.getUid(), request.getParameter("code"));
+ sql.update("INSERT INTO emails(user_id,email) VALUES (?,?)", visitor.getUid(), account);
+ sql.update("DELETE FROM auth WHERE user_id=? AND authcode=?", visitor.getUid(), request.getParameter("code"));
context.put("result", "OK!");
} catch (EmptyResultDataAccessException e) {
context.put("result", "Sorry, code unknown.");
@@ -117,7 +117,7 @@ public class Settings {
protected void doPost(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, PebbleException {
com.juick.User visitor = Utils.getVisitorUser(sql, request, response);
- if (visitor.getUID() == 0) {
+ if (visitor.getUid() == 0) {
response.sendError(400);
return;
}
@@ -134,7 +134,7 @@ public class Settings {
case "password":
if (UserQueries.updatePassword(sql, visitor, request.getParameter("password"))) {
result = "Password has been changed.
";
- String hash = com.juick.server.UserQueries.getHashByUID(sql, visitor.getUID());
+ String hash = com.juick.server.UserQueries.getHashByUID(sql, visitor.getUid());
Cookie c = new Cookie("hash", hash);
c.setMaxAge(365 * 24 * 60 * 60);
response.addCookie(c);
@@ -158,8 +158,8 @@ public class Settings {
String avatarTmpPath = Utils.receiveMultiPartFile(request, "avatar");
if (StringUtils.isNotEmpty(avatarTmpPath)) {
String originalExtension = FilenameUtils.getExtension(avatarTmpPath);
- String originalName = String.format("%s.%s", visitor.getUID(), originalExtension);
- String targetName = String.format("%s.png", visitor.getUID());
+ String originalName = String.format("%s.%s", visitor.getUid(), originalExtension);
+ String targetName = String.format("%s.png", visitor.getUid());
Path ao = Paths.get(imgPath, "ao", originalName);
Path a = Paths.get(imgPath, "a", targetName);
Path as = Paths.get(imgPath, "as", targetName);
@@ -168,16 +168,16 @@ public class Settings {
Thumbnails.of(ao.toFile()).size(32, 32).toFile(as.toFile());
}
if (UserQueries.updateUserInfo(sql, visitor, info)) {
- result = String.format("Your info is updated.
Back to blog .
", visitor.getUName());
+ result = String.format("Your info is updated.
Back to blog .
", visitor.getName());
}
break;
case "jid-del":
String[] params = request.getParameter("delete").split(";", 2);
int res = -1;
if (params[0].equals("xmpp")) {
- res = sql.update("DELETE FROM jids WHERE user_id=? AND jid=?", visitor.getUID(), params[1]);
+ res = sql.update("DELETE FROM jids WHERE user_id=? AND jid=?", visitor.getUid(), params[1]);
} else if (params[0].equals("xmpp-unauth")) {
- res = sql.update("DELETE FROM auth WHERE user_id=? AND protocol='xmpp' AND account=?", visitor.getUID(), params[1]);
+ res = sql.update("DELETE FROM auth WHERE user_id=? AND protocol='xmpp' AND account=?", visitor.getUid(), params[1]);
}
if (res == 1) {
result = "Deleted. Back .
";
@@ -198,11 +198,11 @@ public class Settings {
case "email-add":
try {
sql.queryForObject("SELECT authcode FROM auth WHERE user_id=? AND protocol='email' " +
- "AND account=?", String.class, visitor.getUID(), request.getParameter("account"));
+ "AND account=?", String.class, visitor.getUid(), request.getParameter("account"));
} catch (EmptyResultDataAccessException e) {
String authCode = UserUtils.generateHash(8);
if (sql.update("INSERT INTO auth(user_id,protocol,account,authcode) VALUES (?,'email',?,?)",
- visitor.getUID(), request.getParameter("account"), authCode) > 0) {
+ visitor.getUid(), request.getParameter("account"), authCode) > 0) {
Session session = Session.getDefaultInstance(System.getProperties());
try {
MimeMessage message = new MimeMessage(session);
@@ -225,18 +225,18 @@ public class Settings {
}
break;
case "email-del":
- if (sql.update("DELETE FROM emails WHERE user_id=? AND email=?", visitor.getUID(), request.getParameter("account")) > 0) {
+ if (sql.update("DELETE FROM emails WHERE user_id=? AND email=?", visitor.getUid(), request.getParameter("account")) > 0) {
result = "Deleted. Back .
";
} else {
result = "An error occured while deleting.
";
}
break;
case "email-subscr":
- sql.update("UPDATE emails SET subscr_hour=NULL WHERE user_id=?", visitor.getUID());
+ sql.update("UPDATE emails SET subscr_hour=NULL WHERE user_id=?", visitor.getUid());
String email = request.getParameter("account");
if (StringUtils.isNotEmpty(email)) {
sql.update("UPDATE emails SET subscr_hour=? WHERE user_id=? AND email=?",
- request.getParameter("time"), visitor.getUID(), email);
+ request.getParameter("time"), visitor.getUid(), email);
result = String.format("Saved! Will send to %s at %s:00 GMT ." +
"
Back
", email, request.getParameter("time"));
} else {
@@ -244,8 +244,8 @@ public class Settings {
}
break;
case "twitter-del":
- sql.update("DELETE FROM twitter WHERE user_id=?", visitor.getUID());
- sql.update("DELETE FROM subscr_users WHERE user_id=? AND suser_id=1741", visitor.getUID());
+ sql.update("DELETE FROM twitter WHERE user_id=?", visitor.getUid());
+ sql.update("DELETE FROM subscr_users WHERE user_id=? AND suser_id=1741", visitor.getUid());
for (Cookie cookie : request.getCookies()) {
if (cookie.getName().equals("request_token")) {
cookie.setMaxAge(0);
@@ -259,21 +259,21 @@ public class Settings {
result = "Back
";
break;
case "telegram-del":
- sql.update("DELETE FROM telegram WHERE user_id=?", visitor.getUID());
+ sql.update("DELETE FROM telegram WHERE user_id=?", visitor.getUid());
result = "Back
";
break;
case "facebook-disable":
- sql.update("UPDATE facebook SET crosspost=0 WHERE user_id=?", visitor.getUID());
- sql.update("DELETE FROM subscr_users WHERE user_id=? AND suser_id=5863", visitor.getUID());
+ sql.update("UPDATE facebook SET crosspost=0 WHERE user_id=?", visitor.getUid());
+ sql.update("DELETE FROM subscr_users WHERE user_id=? AND suser_id=5863", visitor.getUid());
result = "Back
";
break;
case "facebook-enable":
- sql.update("UPDATE facebook SET crosspost=1 WHERE user_id=?", visitor.getUID());
- sql.update("INSERT INTO subscr_users(user_id,suser_id,jid,active) VALUES (?,5863,'juick@facebook.juick.com',1)", visitor.getUID());
+ sql.update("UPDATE facebook SET crosspost=1 WHERE user_id=?", visitor.getUid());
+ sql.update("INSERT INTO subscr_users(user_id,suser_id,jid,active) VALUES (?,5863,'juick@facebook.juick.com',1)", visitor.getUid());
result = "Back
";
break;
case "vk-del":
- sql.update("DELETE FROM vk WHERE user_id=?", visitor.getUID());
+ sql.update("DELETE FROM vk WHERE user_id=?", visitor.getUid());
result = "Back
";
break;
default:
diff --git a/juick-www/src/main/java/com/juick/www/SignUp.java b/juick-www/src/main/java/com/juick/www/SignUp.java
index 43c82a9a..ea40c810 100644
--- a/juick-www/src/main/java/com/juick/www/SignUp.java
+++ b/juick-www/src/main/java/com/juick/www/SignUp.java
@@ -97,7 +97,7 @@ public class SignUp {
String action = request.getParameter("action");
if (action.charAt(0) == 'l') {
- if (visitor.getUID() == 0) {
+ if (visitor.getUid() == 0) {
String username = request.getParameter("username");
String password = request.getParameter("password");
if (username == null || password == null || username.length() > 32 || password.isEmpty()) {
@@ -106,7 +106,7 @@ public class SignUp {
}
uid = com.juick.server.UserQueries.checkPassword(sql, username, password);
} else {
- uid = visitor.getUID();
+ uid = visitor.getUid();
}
if (uid <= 0) {
diff --git a/juick-www/src/main/java/com/juick/www/TwitterAuth.java b/juick-www/src/main/java/com/juick/www/TwitterAuth.java
index d4be4335..173ad7b7 100644
--- a/juick-www/src/main/java/com/juick/www/TwitterAuth.java
+++ b/juick-www/src/main/java/com/juick/www/TwitterAuth.java
@@ -48,7 +48,7 @@ public class TwitterAuth {
}
}
com.juick.User user = UserQueries.getUserByHash(sql, hash);
- if ( user == null || user.getUID() == 0) {
+ if ( user == null || user.getUid() == 0) {
response.sendError(403);
return;
}
diff --git a/juick-www/src/main/java/com/juick/www/User.java b/juick-www/src/main/java/com/juick/www/User.java
index 967d06c7..3cc38b37 100644
--- a/juick-www/src/main/java/com/juick/www/User.java
+++ b/juick-www/src/main/java/com/juick/www/User.java
@@ -58,7 +58,7 @@ public class User {
Errors.doGet404(sql, request, response);
return;
} else if (!paramTag.getName().equals(paramTagStr)) {
- String url = "/" + user.getUName() + "/?tag=" + URLEncoder.encode(paramTag.getName(), "UTF-8");
+ String url = "/" + user.getName() + "/?tag=" + URLEncoder.encode(paramTag.getName(), "UTF-8");
Utils.sendPermanentRedirect(response, url);
return;
}
@@ -79,10 +79,10 @@ public class User {
}
int privacy = 0;
- if (visitor.getUID() > 0) {
- if (user.getUID() == visitor.getUID() || visitor.getUID() == 1) {
+ if (visitor.getUid() > 0) {
+ if (user.getUid() == visitor.getUid() || visitor.getUid() == 1) {
privacy = -3;
- } else if (UserQueries.isInWL(sql, user.getUID(), visitor.getUID())) {
+ } else if (UserQueries.isInWL(sql, user.getUid(), visitor.getUid())) {
privacy = -2;
}
}
@@ -90,34 +90,34 @@ public class User {
String title;
if (paramShow == null) {
if (paramTag != null) {
- title = "Блог " + user.getUName() + ": *" + StringEscapeUtils.escapeHtml4(paramTag.getName());
- mids = MessagesQueries.getUserTag(sql, user.getUID(), paramTag.TID, privacy, paramBefore);
+ title = "Блог " + user.getName() + ": *" + StringEscapeUtils.escapeHtml4(paramTag.getName());
+ mids = MessagesQueries.getUserTag(sql, user.getUid(), paramTag.TID, privacy, paramBefore);
} else if (paramSearch != null) {
- title = "Блог " + user.getUName() + ": " + StringEscapeUtils.escapeHtml4(paramSearch);
- mids = MessagesQueries.getUserSearch(sql, sqlSearch, user.getUID(), Utils.encodeSphinx(paramSearch), privacy, paramBefore);
+ title = "Блог " + user.getName() + ": " + StringEscapeUtils.escapeHtml4(paramSearch);
+ mids = MessagesQueries.getUserSearch(sql, sqlSearch, user.getUid(), Utils.encodeSphinx(paramSearch), privacy, paramBefore);
} else {
- title = "Блог " + user.getUName();
- mids = MessagesQueries.getUserBlog(sql, user.getUID(), privacy, paramBefore);
+ title = "Блог " + user.getName();
+ mids = MessagesQueries.getUserBlog(sql, user.getUid(), privacy, paramBefore);
}
} else if (paramShow.equals("recomm")) {
- title = "Рекомендации " + user.getUName();
- mids = MessagesQueries.getUserRecommendations(sql, user.getUID(), paramBefore);
+ title = "Рекомендации " + user.getName();
+ mids = MessagesQueries.getUserRecommendations(sql, user.getUid(), paramBefore);
} else if (paramShow.equals("photos")) {
- title = "Фотографии " + user.getUName();
- mids = MessagesQueries.getUserPhotos(sql, user.getUID(), privacy, paramBefore);
+ title = "Фотографии " + user.getName();
+ mids = MessagesQueries.getUserPhotos(sql, user.getUid(), privacy, paramBefore);
} else {
Errors.doGet404(sql, request, response);
return;
}
- if (visitor.getUID() == 0) {
- pageUserRefCookie(request, response, user.getUID());
+ if (visitor.getUid() == 0) {
+ pageUserRefCookie(request, response, user.getUid());
}
response.setContentType("text/html; charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
String head = " ";
+ user.getName() + "\" href=\"//rss.juick.com/" + user.getName() + "/blog\"/>";
if (paramTag != null && TagQueries.getTagNoIndex(sql, paramTag.TID)) {
head += " ";
} else if (paramBefore > 0 || paramShow != null) {
@@ -136,7 +136,7 @@ public class User {
StringEscapeUtils.escapeHtml4(paramTag.getName()) + "
");
}
- PageTemplates.printMessages(out, sql, user, mids, visitor, visitor.getUID() == 0 ? 4 : 5, 0);
+ PageTemplates.printMessages(out, sql, user, mids, visitor, visitor.getUid() == 0 ? 4 : 5, 0);
if (mids.size() >= 20) {
String nextpage = "?before=" + mids.get(mids.size() - 1);
@@ -163,14 +163,14 @@ public class User {
protected void doGetTags(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response, com.juick.User user) throws ServletException, IOException {
com.juick.User visitor = Utils.getVisitorUser(sql, request, response);
- if (visitor.getUID() == 0) {
- pageUserRefCookie(request, response, user.getUID());
+ if (visitor.getUid() == 0) {
+ pageUserRefCookie(request, response, user.getUid());
}
response.setContentType("text/html; charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
String head = " ";
- PageTemplates.pageHead(out, visitor, "Теги " + user.getUName(), head);
+ PageTemplates.pageHead(out, visitor, "Теги " + user.getName(), head);
PageTemplates.pageNavigation(out, visitor, null);
pageUserColumn(out, sql, user, visitor);
@@ -186,28 +186,28 @@ public class User {
protected void doGetFriends(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response, com.juick.User user) throws ServletException, IOException {
com.juick.User visitor = Utils.getVisitorUser(sql, request, response);
- if (visitor.getUID() == 0) {
- pageUserRefCookie(request, response, user.getUID());
+ if (visitor.getUid() == 0) {
+ pageUserRefCookie(request, response, user.getUid());
}
response.setContentType("text/html; charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
String head = " ";
- PageTemplates.pageHead(out, visitor, "Подписки " + user.getUName(), head);
+ PageTemplates.pageHead(out, visitor, "Подписки " + user.getName(), head);
PageTemplates.pageNavigation(out, visitor, null);
pageUserColumn(out, sql, user, visitor);
out.println("");
out.println("");
@@ -221,28 +221,28 @@ public class User {
protected void doGetReaders(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response, com.juick.User user) throws ServletException, IOException {
com.juick.User visitor = Utils.getVisitorUser(sql, request, response);
- if (visitor.getUID() == 0) {
- pageUserRefCookie(request, response, user.getUID());
+ if (visitor.getUid() == 0) {
+ pageUserRefCookie(request, response, user.getUid());
}
response.setContentType("text/html; charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
String head = " ";
- PageTemplates.pageHead(out, visitor, "Читатели " + user.getUName(), head);
+ PageTemplates.pageHead(out, visitor, "Читатели " + user.getName(), head);
PageTemplates.pageNavigation(out, visitor, null);
pageUserColumn(out, sql, user, visitor);
out.println("");
out.println("");
@@ -267,21 +267,21 @@ public class User {
public static void pageUserColumn(PrintWriter out, JdbcTemplate sql, com.juick.User user, com.juick.User visitor) {
out.println("");
- out.println(" ");
- if (visitor.getUID() > 0 && visitor.getUID() != user.getUID()) {
+ out.println(" ");
+ if (visitor.getUid() > 0 && visitor.getUid() != user.getUid()) {
out.println(" ");
} else {
@@ -299,13 +299,13 @@ public class User {
out.println(" " + pageUserTags(sql, user, visitor, 20) + "...
");
out.println(" ");
out.println(" ");
- List
iread = UserQueries.getUserReadLeastPopular(sql, user.getUID(), 8);
+ List iread = UserQueries.getUserReadLeastPopular(sql, user.getUid(), 8);
if (!iread.isEmpty()) {
out.println("");
for (int i = 0; i < iread.size(); i++) {
@@ -313,7 +313,7 @@ public class User {
out.println(" ");
}
com.juick.User u = iread.get(i);
- out.println(" ");
+ out.println(" ");
}
out.println("
");
}
@@ -323,7 +323,7 @@ public class User {
}
public static String pageUserTags(JdbcTemplate sql, com.juick.User user, com.juick.User visitor, int cnt) {
- List tags = TagQueries.getUserTagsAll(sql, user.getUID()).stream()
+ List tags = TagQueries.getUserTagsAll(sql, user.getUid()).stream()
.sorted((e1, e2) -> Integer.compare(e2.UsageCnt, e1.UsageCnt)).collect(Collectors.toList());
int maxUsageCnt = tags.stream().map(t -> t.UsageCnt).max(Integer::max).orElse(0);
String ret = "";
diff --git a/juick-www/src/main/java/com/juick/www/UserThread.java b/juick-www/src/main/java/com/juick/www/UserThread.java
index 5f9f7e9a..3dee9697 100644
--- a/juick-www/src/main/java/com/juick/www/UserThread.java
+++ b/juick-www/src/main/java/com/juick/www/UserThread.java
@@ -40,7 +40,7 @@ public class UserThread {
protected void doGetThread(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response, int MID) throws ServletException, IOException {
com.juick.User visitor = Utils.getVisitorUser(sql, request, response);
- if (!MessagesQueries.canViewThread(sql, MID, visitor.getUID())) {
+ if (!MessagesQueries.canViewThread(sql, MID, visitor.getUid())) {
response.sendError(403);
return;
}
@@ -52,27 +52,27 @@ public class UserThread {
if (paramView != null) {
if (paramView.equals("list")) {
listview = true;
- if (visitor.getUID() > 0) {
- UserQueries.setUserOptionInt(sql, visitor.getUID(), "repliesview", 1);
+ if (visitor.getUid() > 0) {
+ UserQueries.setUserOptionInt(sql, visitor.getUid(), "repliesview", 1);
}
- } else if (paramView.equals("tree") && visitor.getUID() > 0) {
- UserQueries.setUserOptionInt(sql, visitor.getUID(), "repliesview", 0);
+ } else if (paramView.equals("tree") && visitor.getUid() > 0) {
+ UserQueries.setUserOptionInt(sql, visitor.getUid(), "repliesview", 0);
}
- } else if (visitor.getUID() > 0 && UserQueries.getUserOptionInt(sql, visitor.getUID(), "repliesview", 0) == 1) {
+ } else if (visitor.getUid() > 0 && UserQueries.getUserOptionInt(sql, visitor.getUid(), "repliesview", 0) == 1) {
listview = true;
}
- String title = msg.getUser().getUName() + ": " + msg.getTagsString();
+ String title = msg.getUser().getName() + ": " + msg.getTagsString();
- if (visitor.getUID() > 0) {
- User.pageUserRefCookie(request, response, msg.getUser().getUID());
+ if (visitor.getUid() > 0) {
+ User.pageUserRefCookie(request, response, msg.getUser().getUid());
}
response.setContentType("text/html; charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
- String headers = " ";
+ String headers = " ";
if (paramView != null) {
- headers += " ";
+ headers += " ";
}
if (msg.Hidden) {
headers += " ";
@@ -80,7 +80,7 @@ public class UserThread {
PageTemplates.pageHead(out, visitor, title, headers);
PageTemplates.pageNavigation(out, visitor, null);
- out.println("");
+ out.println("");
printMessage(out, sql, msg, visitor);
printReplies(out, sql, msg, visitor, listview);
out.println(" ");
@@ -92,20 +92,20 @@ public class UserThread {
}
public static com.juick.Message printMessage(PrintWriter out, JdbcTemplate sql, com.juick.Message msg, com.juick.User visitor) {
- msg.VisitorCanComment = visitor.getUID() > 0;
+ msg.VisitorCanComment = visitor.getUid() > 0;
- List tags = MessagesQueries.getMessageTags(sql, msg.getMID());
+ List tags = MessagesQueries.getMessageTags(sql, msg.getMid());
String tagsStr = PageTemplates.formatTags(tags);
if (msg.ReadOnly) {
tagsStr += "readonly ";
msg.VisitorCanComment = false;
}
- if (msg.Privacy < 0) {
+ if (msg.getPrivacy() < 0) {
tagsStr += "friends ";
}
String txt;
- if (msg.Tags.stream().anyMatch(t -> t.getName().equals("code"))) {
+ if (msg.getTags().stream().anyMatch(t -> t.getName().equals("code"))) {
txt = Utils.formatMessageCode(msg.getText());
} else {
txt = Utils.formatMessage(msg.getText());
@@ -116,24 +116,24 @@ public class UserThread {
}
out.println("");
- out.println(" ");
+ out.println(" ");
out.println(" ");
out.println(" ");
out.println("
" + PageTemplates.formatJSLocalTime(msg.getDate()) + "
");
- out.println("
");
- out.println(" ");
+ out.println("
");
+ out.println(" ");
out.println("
" + txt + "
");
if (msg.AttachmentType != null) {
- out.println("
");
+ out.println("
");
}
boolean visitorInBL = false;
- if (visitor.getUID() > 0) {
- if (visitor.getUID() == msg.getUser().getUID()) {
+ if (visitor.getUid() > 0) {
+ if (visitor.getUid() == msg.getUser().getUid()) {
msg.VisitorCanComment = true;
} else {
- visitorInBL = UserQueries.isInBL(sql, msg.getUser().getUID(), visitor.getUID());
+ visitorInBL = UserQueries.isInBL(sql, msg.getUser().getUid(), visitor.getUid());
if (visitorInBL) {
msg.VisitorCanComment = false;
}
@@ -141,12 +141,12 @@ public class UserThread {
}
if (msg.VisitorCanComment) {
- out.println("
");
+ out.println(" ");
out.println(" ");
out.println(" ");
}
- List
recomm = MessagesQueries.getMessageRecommendations(sql, msg.getMID());
+ List recomm = MessagesQueries.getMessageRecommendations(sql, msg.getMid());
if (!recomm.isEmpty()) {
out.print(" Рекомендовали (" + recomm.size() + "): ");
for (int i = 0; i < recomm.size(); i++) {
@@ -161,19 +161,19 @@ public class UserThread {
out.println(" ");
out.println("
");
- out.println("
" + msg.getMID() + " ");
- if (visitor.getUID() > 0) {
- if (visitor.getUID() != msg.getUser().getUID()) {
- if (MessagesQueries.isSubscribed(sql, visitor.getUID(), msg.getMID())) {
- out.println("
Подписан ");
+ out.println("
" + msg.getMid() + " ");
+ if (visitor.getUid() > 0) {
+ if (visitor.getUid() != msg.getUser().getUid()) {
+ if (MessagesQueries.isSubscribed(sql, visitor.getUid(), msg.getMid())) {
+ out.println("
Подписан ");
} else {
- out.println("
Подписаться ");
+ out.println("
Подписаться ");
}
if (!visitorInBL) {
- out.println("
Рекомендовать ");
+ out.println("
Рекомендовать ");
}
} else {
- out.println("
Удалить ");
+ out.println("
Удалить ");
}
}
out.println(" ");
@@ -183,38 +183,38 @@ public class UserThread {
}
public static void printReplies(PrintWriter out, JdbcTemplate sql, com.juick.Message msg, com.juick.User visitor, boolean listview) {
- List
replies = MessagesQueries.getReplies(sql, msg.getMID());
+ List replies = MessagesQueries.getReplies(sql, msg.getMid());
List blUIDs = new ArrayList();
for (int i = 0; i < replies.size(); i++) {
com.juick.Message reply = replies.get(i);
- if (reply.getUser().getUID() != msg.getUser().getUID() && !blUIDs.contains(reply.getUser().getUID())) {
- blUIDs.add(reply.getUser().getUID());
+ if (reply.getUser().getUid() != msg.getUser().getUid() && !blUIDs.contains(reply.getUser().getUid())) {
+ blUIDs.add(reply.getUser().getUid());
}
- if (reply.ReplyTo > 0) {
+ if (reply.getReplyto() > 0) {
boolean added = false;
for (int n = 0; n < replies.size(); n++) {
- if (replies.get(n).getRID() == reply.ReplyTo) {
+ if (replies.get(n).getRid() == reply.getReplyto()) {
replies.get(n).childs.add(reply);
added = true;
break;
}
}
if (!added) {
- reply.ReplyTo = 0;
+ reply.setReplyto(0);
}
}
}
if (!replies.isEmpty()) {
- if (visitor.getUID() > 0 && msg.getUser().getUID() == visitor.getUID()) {
+ if (visitor.getUid() > 0 && msg.getUser().getUid() == visitor.getUid()) {
for (Message reply : replies) {
reply.VisitorCanComment = true;
}
- } else if (visitor.getUID() > 0 && msg.VisitorCanComment) {
- blUIDs = UserQueries.checkBL(sql, visitor.getUID(), blUIDs);
+ } else if (visitor.getUid() > 0 && msg.VisitorCanComment) {
+ blUIDs = UserQueries.checkBL(sql, visitor.getUid(), blUIDs);
for (Message reply : replies) {
- reply.VisitorCanComment = reply.getUser().getUID() == visitor.getUID() || !blUIDs.contains(reply.getUser().getUID());
+ reply.VisitorCanComment = reply.getUser().getUid() == visitor.getUid() || !blUIDs.contains(reply.getUser().getUid());
}
} else {
for (Message reply : replies) {
@@ -268,9 +268,9 @@ public class UserThread {
for (int i = 0; i < replies.size(); i++) {
com.juick.Message msg = replies.get(i);
- if (msg.ReplyTo == ReplyTo) {
+ if (msg.getReplyto() == ReplyTo) {
- out.print(" 0) {
out.print("margin-left: " + margin + "px;");
}
@@ -280,26 +280,26 @@ public class UserThread {
out.println("\">");
out.println(" ");
out.println(" ");
out.println("
" + Utils.formatMessage(msg.getText()) + "
");
if (msg.AttachmentType != null) {
- out.println("
");
+ out.println("
");
}
- out.print("
/" + msg.getRID());
- if (msg.ReplyTo > 0) {
- out.print(" в ответ на
/" + msg.ReplyTo + " ");
+ out.print("
/" + msg.getRid());
+ if (msg.getReplyto() > 0) {
+ out.print(" в ответ на
/" + msg.getReplyto() + " ");
}
if (msg.VisitorCanComment) {
- out.println(" ·
");
+ out.println(" ·
");
out.println(" ");
} else if (visitor == null) {
out.println(" ·
Ответить ");
@@ -313,9 +313,9 @@ public class UserThread {
out.println(" ");
if (ReplyTo == 0 && childs > 1 && replies.size() > 10) {
- printTree(out, msg.childs, visitor, msg.getRID(), margin + 20, true);
+ printTree(out, msg.childs, visitor, msg.getRid(), margin + 20, true);
} else if (childs > 0) {
- printTree(out, msg.childs, visitor, msg.getRID(), margin + 20, hidden);
+ printTree(out, msg.childs, visitor, msg.getRid(), margin + 20, hidden);
}
}
}
@@ -323,32 +323,32 @@ public class UserThread {
public static void printList(PrintWriter out, List replies, com.juick.User visitor) {
for (Message msg : replies) {
- out.print(" ");
+ out.print(" ");
out.println(" ");
out.println(" ");
out.println("
" + Utils.formatMessage(msg.getText()) + "
");
if (msg.AttachmentType != null) {
- out.println("
");
+ out.println("
");
}
- out.print("
/" + msg.getRID());
- if (msg.ReplyTo > 0) {
- out.print(" в ответ на
/" + msg.ReplyTo + " ");
+ out.print("
/" + msg.getRid());
+ if (msg.getReplyto() > 0) {
+ out.print(" в ответ на
/" + msg.getReplyto() + " ");
}
if (msg.VisitorCanComment) {
out.println(" ·
");
out.println(" ");
- } else if (visitor.getUID() == 0) {
- out.println("
");
+ } else if (visitor.getUid() == 0) {
+ out.println("
");
}
out.println("
");
out.println(" ");
diff --git a/juick-www/src/main/java/com/juick/www/Utils.java b/juick-www/src/main/java/com/juick/www/Utils.java
index c236ac62..988ecb17 100644
--- a/juick-www/src/main/java/com/juick/www/Utils.java
+++ b/juick-www/src/main/java/com/juick/www/Utils.java
@@ -86,8 +86,8 @@ public class Utils {
String hash = getCookie(request, "hash");
if (hash != null) {
com.juick.User visitor = com.juick.server.UserQueries.getUserByHash(sql, hash);
- if (response != null && visitor.getUID() > 0) {
- response.setHeader("X-Username", visitor.getUName());
+ if (response != null && visitor.getUid() > 0) {
+ response.setHeader("X-Username", visitor.getName());
}
return visitor;
} else {
diff --git a/juick-www/src/main/resources/views/pm_inbox.html b/juick-www/src/main/resources/views/pm_inbox.html
index d8fbf4ce..36b3e511 100644
--- a/juick-www/src/main/resources/views/pm_inbox.html
+++ b/juick-www/src/main/resources/views/pm_inbox.html
@@ -6,10 +6,10 @@