diff options
author | 2014-07-01 17:33:00 +0700 | |
---|---|---|
committer | 2014-07-01 17:33:00 +0700 | |
commit | 6ceb03cce40e5183b2bb5e93c0cb4b5d39992e94 (patch) | |
tree | 80721ee8741525a25505316ce87c79b8567f36b3 /src/java/com/juick/http/www | |
parent | 0439784c9e32e2bfe6ccb7ea7569fa8a503c1152 (diff) |
Share new post
Diffstat (limited to 'src/java/com/juick/http/www')
-rw-r--r-- | src/java/com/juick/http/www/Discover.java | 2 | ||||
-rw-r--r-- | src/java/com/juick/http/www/Errors.java | 5 | ||||
-rw-r--r-- | src/java/com/juick/http/www/NewMessage.java | 50 | ||||
-rw-r--r-- | src/java/com/juick/http/www/PageTemplates.java | 5 |
4 files changed, 53 insertions, 9 deletions
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 = "<meta name=\"robots\" content=\"noindex,nofollow\"/>"; - } else if (paramBefore > 0) { + } else if (paramBefore > 0 || mids.size() < 5) { head = "<meta name=\"robots\" content=\"noindex\"/>"; } 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("<aside id=\"column\">"); - out.println(" <p class=\"tags\">" + tagsHTML + "</p>"); - out.println("</aside>"); + PageTemplates.pageHomeColumn(out, sql, visitor); out.println("<section id=\"content\">"); out.println("<h1>Страница не найдена</h1>"); 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("<section id=\"content\">"); + out.println("<h1>Сообщение опубликовано</h1>"); + out.println("<p>Поделитесь своим новым постом в социальных сетях:</p>"); + if (CrosspostQueries.getTwitterTokens(sql, visitor.UID) == null) { + out.println("<p><a href=\"https://twitter.com/intent/tweet?text=" + URLEncoder.encode(sharetwi, "utf-8") + "\" onclick=\"return openSocialWindow(this)\" class=\"ico32-twi sharenew\">Отправить в Twitter</a></p>"); + } + out.println("<p><a href=\"http://www.livejournal.com/update.bml?subject=" + URLEncoder.encode(hashtags, "utf-8") + "&event=" + sharelj + "&prop_taglist=" + URLEncoder.encode(tagscomma, "utf-8") + "\" target=\"_blank\" class=\"ico32-lj sharenew\">Отправить в LiveJournal</a></p>"); + out.println("<p><a href=\"https://vk.com/share.php?url=" + url + "\" onclick=\"return openSocialWindow(this)\" class=\"ico32-vk sharenew\">Отправить в ВКонтакте</a></p>"); + if (CrosspostQueries.getFacebookToken(sql, visitor.UID) == null) { + out.println("<p><a href=\"https://www.facebook.com/sharer/sharer.php?u=" + url + "\" onclick=\"return openSocialWindow(this)\" class=\"ico32-fb sharenew\">Отправить в Facebook</a></p>"); + } + out.println("<p><a href=\"https://plus.google.com/share?url=" + url + "\" onclick=\"return openSocialWindow(this)\" class=\"ico32-gp sharenew\">Отправить в Google+</a></p>"); + out.println("<p>Ссылка на сообщение: <a href=\"http://juick.com/" + mid + "\">http://juick.com/" + mid + "</a></p>"); + out.println("</section>"); + + 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("<!DOCTYPE html>"); out.print("<html>"); out.print("<head>"); - out.print("<link rel=\"stylesheet\" href=\"/style.2014061900.css\"/>"); + out.print("<link rel=\"stylesheet\" href=\"/style.2014062903.css\"/>"); out.print("<script type=\"text/javascript\" src=\"//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js\"></script>"); - out.print("<script type=\"text/javascript\" src=\"/scripts.2014042200.js\"></script>"); + out.print("<script type=\"text/javascript\" src=\"/scripts.2014062900.js\"></script>"); if (headers != null) { out.print(headers); } |