From 48b7aa72126b1a75e470077de48408d24fb1b546 Mon Sep 17 00:00:00 2001 From: Ugnich Anton Date: Sat, 15 Feb 2014 13:13:04 +0700 Subject: New message layout (article); Google Analytics; small bugfixes --- src/java/com/juick/http/www/Discover.java | 2 - src/java/com/juick/http/www/Home.java | 8 +- src/java/com/juick/http/www/Main.java | 2 +- src/java/com/juick/http/www/PageTemplates.java | 157 ++++++++++--------------- src/java/com/juick/http/www/User.java | 42 ++++--- 5 files changed, 88 insertions(+), 123 deletions(-) (limited to 'src/java/com/juick/http') 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("
"); if (mids.size() > 0) { - out.println(""); } 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(""); } 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(""); out.print(""); out.print(""); - out.print(""); + out.print(""); out.print(""); - out.print(""); + out.print(""); 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("
"); out.println(" "); - out.println(" "); + out.print(" "); out.print("
"); out.println("
"); if (visitor != null) { - out.println(" "); - out.println(" "); + out.print(" "); + out.print(" "); } else { out.println("

Чтобы добавлять сообщения и комментарии, представьтесь.

"); } @@ -105,21 +98,21 @@ public class PageTemplates { out.println("
"); } - public static void pageYandexAd(PrintWriter out, int stat_id) { - out.println("
"); + public static void pageYandexAd(PrintWriter out, int YandexID) { + out.println("
"); out.println(""); + } + + out.println(""); } 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("
  • "); - out.println(""); + 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 = "" + tags + ""; - } - - out.println("
  • "); - out.println("
    \""
    "); - out.println("
    "); - out.println("
    "); - out.println(" "); - out.print("
    " + formatDate(msg.TimeAgo, msg.TimestampString) + ""); - if (msg.MID == ad_mid) { - out.print(" · Реклама"); - } - out.println("
    "); - - out.print("
    " + txt + "
    "); - + out.println("
    "); + out.println(" "); + out.println("
    @" + msg.User.UName + ":" + tags + "
    "); + out.println("
    "); + out.println("

    " + txt + "

    "); if (msg.AttachmentType != null) { - out.println("
    \"\"/
    "); + out.println("

    \"\"/

    "); } + out.print(" "); + + out.print("
    "); - out.println("
  • "); + out.println(""); + out.println(""); } } } 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("
    "); - out.println(""); - if (mids.size() >= 20) { - String nextpage = "?before=" + mids.get(mids.size() - 1); - if (paramShow != null) { - nextpage += "&show=" + paramShow; - } - if (paramTag != null) { - nextpage += "&tag=" + URLEncoder.encode(paramTag.Name, "UTF-8"); - } - if (paramSearch != null) { - nextpage += "&search=" + URLEncoder.encode(paramSearch, "UTF-8"); + if (mids.size() >= 20) { + String nextpage = "?before=" + mids.get(mids.size() - 1); + if (paramShow != null) { + nextpage += "&show=" + paramShow; + } + if (paramTag != null) { + nextpage += "&tag=" + URLEncoder.encode(paramTag.Name, "UTF-8"); + } + if (paramSearch != null) { + nextpage += "&search=" + URLEncoder.encode(paramSearch, "UTF-8"); + } + out.println("

    Older →

    "); } - out.println("

    Older →

    "); - } - out.println("
    "); + out.println("
    "); + } PageTemplates.pageFooter(request, out, visitor, true); PageTemplates.pageDialogTemplate(out); -- cgit v1.2.3