diff options
author | Ugnich Anton | 2014-02-15 13:13:04 +0700 |
---|---|---|
committer | Ugnich Anton | 2014-02-15 13:13:04 +0700 |
commit | 48b7aa72126b1a75e470077de48408d24fb1b546 (patch) | |
tree | 2149e2b47144a54280b965cc9a0b4b488c26d694 /src/java/com/juick/http/www/PageTemplates.java | |
parent | c25951ec334d94a9471ad0f2575b7c8ee4e7e21a (diff) |
New message layout (article); Google Analytics; small bugfixes
Diffstat (limited to 'src/java/com/juick/http/www/PageTemplates.java')
-rw-r--r-- | src/java/com/juick/http/www/PageTemplates.java | 157 |
1 files changed, 61 insertions, 96 deletions
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(" · <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>"); } } } |