From 6ceb03cce40e5183b2bb5e93c0cb4b5d39992e94 Mon Sep 17 00:00:00 2001 From: Ugnich Anton Date: Tue, 1 Jul 2014 17:33:00 +0700 Subject: Share new post --- src/java/com/juick/http/www/Discover.java | 2 +- src/java/com/juick/http/www/Errors.java | 5 +-- src/java/com/juick/http/www/NewMessage.java | 50 +++++++++++++++++++++++++- src/java/com/juick/http/www/PageTemplates.java | 5 ++- 4 files changed, 53 insertions(+), 9 deletions(-) (limited to 'src/java/com/juick') diff --git a/src/java/com/juick/http/www/Discover.java b/src/java/com/juick/http/www/Discover.java index c38a1508..ff4b3ee5 100644 --- a/src/java/com/juick/http/www/Discover.java +++ b/src/java/com/juick/http/www/Discover.java @@ -72,7 +72,7 @@ public class Discover { String head = ""; if (TagQueries.getTagNoIndex(sql, paramTag.TID)) { head = ""; - } else if (paramBefore > 0) { + } else if (paramBefore > 0 || mids.size() < 5) { head = ""; } PageTemplates.pageHead(out, title, head); diff --git a/src/java/com/juick/http/www/Errors.java b/src/java/com/juick/http/www/Errors.java index c1ffc2e8..f65b6201 100644 --- a/src/java/com/juick/http/www/Errors.java +++ b/src/java/com/juick/http/www/Errors.java @@ -28,10 +28,7 @@ public class Errors { try { PageTemplates.pageHead(out, "404 Страница не найдена", null); PageTemplates.pageNavigation(out, visitor, null); - - out.println(""); + PageTemplates.pageHomeColumn(out, sql, visitor); out.println("
"); out.println("

Страница не найдена

"); diff --git a/src/java/com/juick/http/www/NewMessage.java b/src/java/com/juick/http/www/NewMessage.java index 2072e41f..34733511 100644 --- a/src/java/com/juick/http/www/NewMessage.java +++ b/src/java/com/juick/http/www/NewMessage.java @@ -18,6 +18,7 @@ package com.juick.http.www; import com.juick.Tag; +import com.juick.server.CrosspostQueries; import com.juick.server.MessagesQueries; import com.juick.server.SubscriptionsQueries; import com.juick.server.TagQueries; @@ -235,7 +236,54 @@ public class NewMessage { xmsg.to.Username = "jubo"; xmpp.send(xmsg); - Utils.sendTemporaryRedirect(response, "/" + visitor.UName + "/" + mid); + // + + response.setContentType("text/html; charset=UTF-8"); + PrintWriter out = response.getWriter(); + try { + PageTemplates.pageHead(out, "Сообщение опубликовано", null); + PageTemplates.pageNavigation(out, visitor, null); + PageTemplates.pageHomeColumn(out, sql, visitor); + + String hashtags = ""; + String tagscomma = ""; + for (int i = 0; i < tagsArr.length; i++) { + if (i > 0) { + hashtags += " "; + tagscomma += ","; + } + hashtags += "#" + tagsArr[i]; + tagscomma += tagsArr[i]; + } + + String url = URLEncoder.encode("http://juick.com/" + mid, "utf-8"); + String sharetwi = hashtags + " " + body; + if (sharetwi.length() > 115) { + sharetwi = sharetwi.substring(0, 114) + "…"; + } + sharetwi += " http://juick.com/" + mid; + String sharelj = URLEncoder.encode(body + "\n", "utf-8") + url; + + out.println("
"); + out.println("

Сообщение опубликовано

"); + out.println("

Поделитесь своим новым постом в социальных сетях:

"); + if (CrosspostQueries.getTwitterTokens(sql, visitor.UID) == null) { + out.println("

Отправить в Twitter

"); + } + out.println("

Отправить в LiveJournal

"); + out.println("

Отправить в ВКонтакте

"); + if (CrosspostQueries.getFacebookToken(sql, visitor.UID) == null) { + out.println("

Отправить в Facebook

"); + } + out.println("

Отправить в Google+

"); + out.println("

Ссылка на сообщение: http://juick.com/" + mid + "

"); + out.println("
"); + + PageTemplates.pageFooter(request, out, visitor, false); + PageTemplates.pageEnd(out); + } finally { + out.close(); + } } public void doPostComment(Connection sql, HttpServletRequest request, HttpServletResponse response, Stream xmpp, com.juick.User visitor) throws ServletException, IOException { diff --git a/src/java/com/juick/http/www/PageTemplates.java b/src/java/com/juick/http/www/PageTemplates.java index c2e56fcb..37b17abf 100644 --- a/src/java/com/juick/http/www/PageTemplates.java +++ b/src/java/com/juick/http/www/PageTemplates.java @@ -28,7 +28,6 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Arrays; import java.util.Calendar; import java.util.Date; import java.util.regex.Matcher; @@ -52,9 +51,9 @@ public class PageTemplates { out.println(""); out.print(""); out.print(""); - out.print(""); + out.print(""); out.print(""); - out.print(""); + out.print(""); if (headers != null) { out.print(headers); } -- cgit v1.2.3