aboutsummaryrefslogtreecommitdiff
path: root/src/java/com/juick/http/www
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/com/juick/http/www')
-rw-r--r--src/java/com/juick/http/www/Discover.java2
-rw-r--r--src/java/com/juick/http/www/Home.java8
-rw-r--r--src/java/com/juick/http/www/Main.java2
-rw-r--r--src/java/com/juick/http/www/PageTemplates.java157
-rw-r--r--src/java/com/juick/http/www/User.java42
5 files changed, 88 insertions, 123 deletions
diff --git a/src/java/com/juick/http/www/Discover.java b/src/java/com/juick/http/www/Discover.java
index 4e4a6b3d..1db264f7 100644
--- a/src/java/com/juick/http/www/Discover.java
+++ b/src/java/com/juick/http/www/Discover.java
@@ -80,9 +80,7 @@ public class Discover {
out.println("<section id=\"content\">");
if (mids.size() > 0) {
- out.println("<ul>");
PageTemplates.printMessages(out, sql, null, mids, visitor, visitor == null ? 2 : 3, 0);
- out.println("</ul>");
}
if (mids.size() >= 20) {
diff --git a/src/java/com/juick/http/www/Home.java b/src/java/com/juick/http/www/Home.java
index 1240e62e..1319a135 100644
--- a/src/java/com/juick/http/www/Home.java
+++ b/src/java/com/juick/http/www/Home.java
@@ -57,10 +57,10 @@ public class Home {
title = "Поиск: " + Utils.encodeHTML(paramSearch);
mids = MessagesQueries.getSearch(sql, sqlSearch, Utils.encodeSphinx(paramSearch), paramBefore);
} else if (paramShow == null || paramShow.equals("top")) {
- if(visitor!=null) {
- title = "Популярные";
+ if (visitor != null) {
+ title = "Популярные";
} else {
- title="Микроблоги Juick: популярные записи";
+ title = "Микроблоги Juick: популярные записи";
}
mids = MessagesQueries.getPopular(sql, paramBefore);
} else if (paramShow.equals("my") && visitor != null) {
@@ -114,9 +114,7 @@ public class Home {
}
}
- out.println("<ul>");
PageTemplates.printMessages(out, sql, null, mids, visitor, visitor == null ? 2 : 3, ad_mid);
- out.println("</ul>");
}
if (mids.size() >= 20) {
diff --git a/src/java/com/juick/http/www/Main.java b/src/java/com/juick/http/www/Main.java
index 66237ebe..98034359 100644
--- a/src/java/com/juick/http/www/Main.java
+++ b/src/java/com/juick/http/www/Main.java
@@ -238,7 +238,7 @@ public class Main extends HttpServlet implements Stream.StreamListener {
if (!author.UName.equals(user.UName)) {
Utils.sendPermanentRedirect(response, "/" + author.UName + "/" + mid);
} else {
- pagesUserThread.doGetThread(sql, request, response, user, mid);
+ pagesUserThread.doGetThread(sql, request, response, mid);
}
} else {
response.sendError(404);
diff --git a/src/java/com/juick/http/www/PageTemplates.java b/src/java/com/juick/http/www/PageTemplates.java
index 32e77239..228cff91 100644
--- a/src/java/com/juick/http/www/PageTemplates.java
+++ b/src/java/com/juick/http/www/PageTemplates.java
@@ -46,16 +46,15 @@ public class PageTemplates {
private static final SimpleDateFormat sdfSQL = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
private static SimpleDateFormat sdfSimple = new SimpleDateFormat("d MMM");
private static SimpleDateFormat sdfFull = new SimpleDateFormat("d MMM yyyy");
- private static SimpleDateFormat sdfJS = new SimpleDateFormat("yyyy,MM,dd,HH,mm,ss");
private static String tagsHTML = null;
public static void pageHead(PrintWriter out, String title, String headers) {
out.println("<!DOCTYPE html>");
out.print("<html>");
out.print("<head>");
- out.print("<link rel=\"stylesheet\" href=\"/style.2014020202.css\"/>");
+ out.print("<link rel=\"stylesheet\" href=\"/style.2014021500.css\"/>");
out.print("<script type=\"text/javascript\" src=\"//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js\" defer=\"defer\"></script>");
- out.print("<script type=\"text/javascript\" src=\"/scripts.2014013000.js\" defer=\"defer\"></script>");
+ out.print("<script type=\"text/javascript\" src=\"/scripts.2014021400.js\" defer=\"defer\"></script>");
if (headers != null) {
out.print(headers);
}
@@ -70,11 +69,10 @@ public class PageTemplates {
public static void pageNavigation(PrintWriter out, com.juick.User visitor, String search) {
out.println("<header>");
out.println(" <div id=\"logo\"><a href=\"/\">Juick</a></div>");
- out.println(" <nav id=\"global\"><ul>");
- out.println(" <li><a href=\"/\">Популярные</a></li>");
- out.println(" <li>/</li>");
- out.println(" <li><a href=\"/?show=all\">Все сообщения</a></li>");
- out.println(" </ul></nav>");
+ out.print(" <nav id=\"global\"><ul>");
+ out.print("<li><a href=\"/\">Популярные</a></li>");
+ out.print("<li><a href=\"/?show=all\">Все сообщения</a></li>");
+ out.println("</ul></nav>");
out.print(" <div id=\"search\"><form action=\"/\"><input type=\"text\" name=\"search\" class=\"text\" placeholder=\"Поиск\"");
if (search != null) {
out.print(" value=\"" + Utils.encodeHTML(search) + "\"");
@@ -82,22 +80,17 @@ public class PageTemplates {
out.println("/></form></div>");
out.println(" <section id=\"headdiv\">");
if (visitor != null) {
- out.println(" <nav id=\"user\"><ul>");
- out.println(" <li><a href=\"/?show=my\">Моя лента</a></li>");
- out.println(" <li>/</li>");
- out.println(" <li><a href=\"/pm/inbox\">Приватные</a></li>");
- out.println(" <li>/</li>");
- out.println(" <li><a href=\"/?show=discuss\">Обсуждения</a></li>");
- out.println(" <li>/</li>");
- out.println(" <li><a href=\"/?show=recommended\">Рекомендации</a></li>");
- out.println(" </ul></nav>");
- out.println(" <nav id=\"actions\"><ul>");
- out.println(" <li><a href=\"/post\">Написать</a></li>");
- out.println(" <li>/</li>");
- out.println(" <li><a href=\"/" + visitor.UName + "\">@" + visitor.UName + "</a></li>");
- out.println(" <li>/</li>");
- out.println(" <li><a href=\"/logout\">Выйти</a></li>");
- out.println(" </ul></nav>");
+ out.print(" <nav id=\"user\"><ul>");
+ out.print("<li><a href=\"/?show=my\">Моя лента</a></li>");
+ out.print("<li><a href=\"/pm/inbox\">Приватные</a></li>");
+ out.print("<li><a href=\"/?show=discuss\">Обсуждения</a></li>");
+ 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>");
+ out.print("<li><a href=\"/" + visitor.UName + "\">@" + visitor.UName + "</a></li>");
+ out.print("<li><a href=\"/logout\">Выйти</a></li>");
+ out.println("</ul></nav>");
} else {
out.println("<p>Чтобы добавлять сообщения и комментарии, <a href=\"/login\">представьтесь</a>.</p>");
}
@@ -105,21 +98,21 @@ public class PageTemplates {
out.println("</header>");
}
- public static void pageYandexAd(PrintWriter out, int stat_id) {
- out.println("<div id=\"yandex_ad\"></div>");
+ public static void pageYandexAd(PrintWriter out, int YandexID) {
+ out.println("<article class=\"ads\"><div id=\"yandex_ad\"></div></article>");
out.println("<script type=\"text/javascript\">");
out.println("(function(w, d, n, s, t) {");
out.println("w[n] = w[n] || [];");
out.println("w[n].push(function() {");
out.println("Ya.Direct.insertInto(84715, \"yandex_ad\", {");
- out.println("stat_id: " + stat_id + ",");
+ out.println("stat_id: " + YandexID + ",");
out.println("site_charset: \"utf-8\",");
out.println("ad_format: \"direct\",");
out.println("font_size: 1,");
- out.println("type: \"vertical\",");
+ out.println("type: \"flat\",");
out.println("limit: 1,");
out.println("title_font_size: 2,");
- out.println("site_bg_color: \"EEEEE5\",");
+ out.println("site_bg_color: \"FFFFFF\",");
out.println("title_color: \"006699\",");
out.println("url_color: \"000000\",");
out.println("text_color: \"000000\",");
@@ -223,6 +216,21 @@ public class PageTemplates {
}
out.println("</div>");
out.println("</div></div>");
+
+ if (visitor != null) {
+ out.println("<script type=\"text/javascript\">");
+ out.println("var hash=\"" + visitor.AuthHash + "\";");
+ out.println("</script>");
+ }
+
+ out.println("<script>");
+ out.println("(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){");
+ out.println("(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),");
+ out.println("m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)");
+ out.println("})(window,document,'script','//www.google-analytics.com/analytics.js','ga');");
+ out.println("ga('create','UA-385578-4','juick.com');");
+ out.println("ga('send','pageview');");
+ out.println("</script>");
}
public static void pageEnd(PrintWriter out) {
@@ -448,34 +456,7 @@ public class PageTemplates {
for (int i = 0; i < msgs.size(); i++) {
if (i == 1 && YandexID > 0 && ad_mid == 0) {
- out.println(" <li class=\"ads\"><div id=\"yandex_ad\"></div></li>");
- out.println("<script type=\"text/javascript\">");
- out.println("(function(w, d, n, s, t) {");
- out.println("w[n] = w[n] || [];");
- out.println("w[n].push(function() {");
- out.println("Ya.Direct.insertInto(84715, \"yandex_ad\", {");
- out.println("stat_id: " + YandexID + ",");
- out.println("site_charset: \"utf-8\",");
- out.println("ad_format: \"direct\",");
- out.println("font_size: 1,");
- out.println("type: \"flat\",");
- out.println("limit: 1,");
- out.println("title_font_size: 2,");
- out.println("site_bg_color: \"FFFFFF\",");
- out.println("title_color: \"006699\",");
- out.println("url_color: \"000000\",");
- out.println("text_color: \"000000\",");
- out.println("hover_color: \"006699\"");
- out.println("});");
- out.println("});");
- out.println("t = d.documentElement.firstChild;");
- out.println("s = d.createElement(\"script\");");
- out.println("s.type = \"text/javascript\";");
- out.println("s.src = \"http://an.yandex.ru/system/context.js\";");
- out.println("s.setAttribute(\"async\", \"true\");");
- out.println("t.insertBefore(s, t.firstChild);");
- out.println("})(window, document, \"yandex_context_callbacks\");");
- out.println("</script>");
+ pageYandexAd(out, YandexID);
}
com.juick.Message msg = msgs.get(i);
@@ -484,19 +465,11 @@ public class PageTemplates {
if (msg.ReadOnly) {
tags += " *readonly";
}
- switch (msg.Privacy) {
- case 2:
- tags += " *public";
- break;
- case -1:
- tags += " *friends";
- break;
- case -2:
- tags += " *friends";
- break;
- case -3:
- tags += " *private";
- break;
+ if (msg.Privacy < 0) {
+ tags += " *friends";
+ }
+ if (msg.MID == ad_mid) {
+ tags += " *реклама";
}
String txt;
@@ -506,40 +479,32 @@ public class PageTemplates {
txt = formatMessage(msg.Text);
}
- if (!tags.isEmpty()) {
- tags = "<span class=\"msg-tags\">" + tags + "</span>";
- }
-
- out.println(" <li id=\"msg-" + msg.MID + "\" class=\"msg\">");
- out.println(" <div class=\"msg-avatar\"><a href=\"/" + msg.User.UName + "/\"><img src=\"//i.juick.com/a/" + msg.User.UID + ".png\" alt=\"" + msg.User.UName + "\"/></a></div>");
- out.println(" <div class=\"msg-cont\">");
- out.println(" <div class=\"msg-menu\"><a href=\"#\" onclick=\"showMessageLinksDialog(" + msg.MID + "); return false\"></a></div>");
- out.println(" <div class=\"msg-header\"><a href=\"/" + msg.User.UName + "/\">@" + msg.User.UName + "</a>:" + tags + "</div>");
- out.print(" <div class=\"msg-ts\"><a href=\"/" + msg.User.UName + "/" + msg.MID + "\" title=\"" + msg.TimestampString + " GMT\">" + formatDate(msg.TimeAgo, msg.TimestampString) + "</a>");
- if (msg.MID == ad_mid) {
- out.print(" &#183; <a href=\"/help/ru/adv\">Реклама</a>");
- }
- out.println("</div>");
-
- out.print(" <div class=\"msg-txt\">" + txt + "</div>");
-
+ out.println("<article data-mid=\"" + msg.MID + "\">");
+ out.println(" <aside><a href=\"/" + msg.User.UName + "/\"><img src=\"//i.juick.com/a/" + msg.User.UID + ".png\" alt=\"" + msg.User.UName + "\"/></a></aside>");
+ out.println(" <header class=\"u\">@<a href=\"/" + msg.User.UName + "/\">" + msg.User.UName + "</a>:" + tags + "</header>");
+ out.println(" <header class=\"t\"><a href=\"/" + msg.User.UName + "/" + msg.MID + "\"><time datetime=\"" + msg.TimestampString + "Z\">" + formatDate(msg.TimeAgo, msg.TimestampString) + "</time></a></header>");
+ out.println(" <p>" + txt + "</p>");
if (msg.AttachmentType != null) {
- out.println(" <div class=\"msg-media\"><a href=\"//i.juick.com/photos-1024/" + msg.MID + "." + msg.AttachmentType + "\"><img src=\"//i.juick.com/photos-512/" + msg.MID + "." + msg.AttachmentType + "\" alt=\"\"/></a></div>");
+ out.println(" <p class=\"i\"><a href=\"//i.juick.com/photos-1024/" + msg.MID + "." + msg.AttachmentType + "\"><img src=\"//i.juick.com/photos-512/" + msg.MID + "." + msg.AttachmentType + "\" alt=\"\"/></a></p>");
}
+ out.print(" <nav class=\"l\">");
msg.ReadOnly |= blUIDs.contains(msg.User.UID);
-
if (visitor != null && (msg.ReadOnly == false || visitor.UID == msg.User.UID)) {
- out.println(" <form action=\"/post\" method=\"POST\" enctype=\"multipart/form-data\"><input type=\"hidden\" name=\"mid\" value=\"" + msg.MID + "\"/>");
- out.println(" <div class=\"msg-comment\"><div class=\"ta-wrapper\"><textarea name=\"body\" rows=\"1\" class=\"reply\" placeholder=\"Написать комментарий\" onkeypress=\"postformListener(this.form,event)\"></textarea></div></div>");
- out.println(" </form>");
+ out.print("<a href=\"#\" onclick=\"return showCommentFooter(this)\">Комментировать</a> ");
+ }
+ out.print("<a href=\"/post?body=%21+%23" + msg.MID + "\">Рекомендовать</a>");
+ out.println("</nav>");
+
+ out.print(" <nav class=\"s\">");
+ if (msg.Likes > 0) {
+ out.print("<a href=\"/" + msg.User.UName + "/" + msg.MID + "\" class=\"likes\">" + msg.Likes + "</a>");
}
if (msg.Replies > 0) {
- String repliesby = (msg.RepliesBy != null) ? msg.RepliesBy : "...";
- out.println(" <div class=\"msg-comments\"><a href=\"/" + msg.User.UName + "/" + msg.MID + "\">" + formatReplies(msg.Replies) + "</a> от " + repliesby + "</div>");
+ out.print("<a href=\"/" + msg.User.UName + "/" + msg.MID + "\" class=\"replies\">" + msg.Replies + "</a>");
}
- out.println(" </div>");
- out.println(" </li>");
+ out.println("</nav>");
+ out.println("</article>");
}
}
}
diff --git a/src/java/com/juick/http/www/User.java b/src/java/com/juick/http/www/User.java
index 71b9ae16..1e469a1d 100644
--- a/src/java/com/juick/http/www/User.java
+++ b/src/java/com/juick/http/www/User.java
@@ -49,8 +49,14 @@ public class User {
com.juick.Tag paramTag = null;
String paramTagStr = request.getParameter("tag");
- if (paramTagStr != null && paramTagStr.length() < 64) {
- paramTag = TagQueries.getTag(sql, paramTagStr, false);
+ if (paramTagStr != null) {
+ if (paramTagStr.length() < 64) {
+ paramTag = TagQueries.getTag(sql, paramTagStr, false);
+ }
+ if (paramTag == null) {
+ response.sendError(404);
+ return;
+ }
}
int paramBefore = 0;
@@ -107,28 +113,26 @@ public class User {
pageUserColumn(out, sql, user, visitor);
- out.println("<section id=\"content\">");
- out.println("<ul>");
if (mids.size() > 0) {
+ out.println("<section id=\"content\">");
PageTemplates.printMessages(out, sql, user, mids, visitor, visitor == null ? 4 : 5, 0);
- }
- out.println("</ul>");
- if (mids.size() >= 20) {
- String nextpage = "?before=" + mids.get(mids.size() - 1);
- if (paramShow != null) {
- nextpage += "&amp;show=" + paramShow;
- }
- if (paramTag != null) {
- nextpage += "&amp;tag=" + URLEncoder.encode(paramTag.Name, "UTF-8");
- }
- if (paramSearch != null) {
- nextpage += "&amp;search=" + URLEncoder.encode(paramSearch, "UTF-8");
+ if (mids.size() >= 20) {
+ String nextpage = "?before=" + mids.get(mids.size() - 1);
+ if (paramShow != null) {
+ nextpage += "&amp;show=" + paramShow;
+ }
+ if (paramTag != null) {
+ nextpage += "&amp;tag=" + URLEncoder.encode(paramTag.Name, "UTF-8");
+ }
+ if (paramSearch != null) {
+ nextpage += "&amp;search=" + URLEncoder.encode(paramSearch, "UTF-8");
+ }
+ out.println("<p class=\"page\"><a href=\"" + nextpage + "\">Older →</a></p>");
}
- out.println("<p class=\"page\"><a href=\"" + nextpage + "\">Older →</a></p>");
- }
- out.println("</section>");
+ out.println("</section>");
+ }
PageTemplates.pageFooter(request, out, visitor, true);
PageTemplates.pageDialogTemplate(out);