diff options
Diffstat (limited to 'src/java/com/juick/http/www/PageTemplates.java')
-rw-r--r-- | src/java/com/juick/http/www/PageTemplates.java | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/src/java/com/juick/http/www/PageTemplates.java b/src/java/com/juick/http/www/PageTemplates.java index 41646e30..2ec42e42 100644 --- a/src/java/com/juick/http/www/PageTemplates.java +++ b/src/java/com/juick/http/www/PageTemplates.java @@ -48,17 +48,18 @@ public class PageTemplates { private static SimpleDateFormat sdfSQL = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S"); 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"); public static void pageHead(PrintWriter out, String title, String headers) { out.println("<!DOCTYPE html>"); out.println("<html>"); out.println("<head>"); out.println(" <title>" + title + "</title>"); - out.println(" <link rel=\"stylesheet\" href=\"//static.juick.com/style3.2012110200.css\"/>"); + out.println(" <link rel=\"stylesheet\" href=\"//static.juick.com/style3.2012110404.css\"/>"); out.println(" <link rel=\"icon\" type=\"image/png\" href=\"//static.juick.com/favicon.png\"/>"); out.println(" <script type=\"text/javascript\" src=\"//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js\" defer=\"defer\"></script>"); out.println(" <script type=\"text/javascript\" src=\"//ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js\" defer=\"defer\" async=\"async\"></script>"); - out.println(" <script type=\"text/javascript\" src=\"//static.juick.com/scripts3.2012102203.js\" defer=\"defer\"></script>"); + out.println(" <script type=\"text/javascript\" src=\"//static.juick.com/scripts3.2012110400.js\" defer=\"defer\"></script>"); if (headers != null) { out.println(headers); } @@ -77,14 +78,12 @@ public class PageTemplates { out.println(" </form>"); out.println(" <ul id=\"nav-right\">"); if (user != null) { - out.println(" <li><a href=\"/post\">" + rb.getString("Post") + "</a></li>"); - out.println(" <li><a href=\"#\" onclick=\"$('#nav-menu').toggle(); return false\"><img src=\"//i.juick.com/as/" + user.UID + ".png\" alt=\"" + user.UName + "\"/>" + user.UName + "</a><ul id=\"nav-menu\">"); - out.println(" <li><a href=\"/" + user.UName + "/\">" + rb.getString("Blog") + "</a></li>"); - out.println(" <li><a href=\"/settings\">" + rb.getString("Settings") + "</a></li>"); - out.println(" <li><a href=\"/logout\">" + rb.getString("Logout") + "</a></li>"); - out.println(" </ul></li>"); + out.println(" <li><a href=\"/post\" class=\"wide\">" + rb.getString("Post") + "</a></li>"); + out.println(" <li><a href=\"/" + user.UName + "\" class=\"wide\"><img src=\"//i.juick.com/as/" + user.UID + ".png\" alt=\"" + user.UName + "\"/>" + user.UName + "</a></li>"); + out.println(" <li><a href=\"/settings\"><div class=\"ico24\" style=\"background-position: 0 11px\"></div></a></li>"); + out.println(" <li><a href=\"/logout\"><div class=\"ico24\" style=\"background-position: -24px 11px\"></div></a></li>"); } else { - out.println(" <li><a href=\"/login\">" + rb.getString("Login") + "</a></li>"); + out.println(" <li><a href=\"/login\" class=\"wide\">" + rb.getString("Login") + "</a></li>"); } out.println(" </ul>"); out.println("</div>"); @@ -205,6 +204,19 @@ public class PageTemplates { } } + public static String formatJSLocalTime(String ts) { + try { + Date date = sdfSQL.parse(ts); + return "<script type=\"text/javascript\">" + + "var d=new Date(" + date.getTime() + ");" + + "document.write(d.getDate()+'.'+(d.getMonth()+1)+'.'+d.getFullYear()+' '+d.getHours()+':'+d.getMinutes());" + + "</script>"; + } catch (ParseException e) { + System.err.print(e); + } + return ""; + } + public static String formatReplies(int replies, Locale loc) { return replies + " repl" + (replies % 10 == 1 ? "y" : "ies"); } @@ -280,10 +292,12 @@ public class PageTemplates { ArrayList<com.juick.Message> msgs = MessagesQueries.getMessages(sql, mids); ArrayList<Integer> blUIDs = new ArrayList<Integer>(20); - for (int i = 0; i < mids.size(); i++) { - blUIDs.add(msgs.get(i).User.UID); + if (visitor != null) { + for (int i = 0; i < mids.size(); i++) { + blUIDs.add(msgs.get(i).User.UID); + } + blUIDs = UserQueries.checkBL(sql, visitor.UID, blUIDs); } - blUIDs = UserQueries.checkBL(sql, visitor.UID, blUIDs); for (int i = 0; i < msgs.size(); i++) { com.juick.Message msg = msgs.get(i); @@ -306,7 +320,7 @@ public class PageTemplates { 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-ts\"><a href=\"/" + msg.User.UName + "/" + msg.MID + "\" title=\"" + msg.TimestampString + "\">" + formatDate(msg.TimeAgo, msg.TimestampString, locale) + "</a></div>"); + out.println(" <div class=\"msg-ts\"><a href=\"/" + msg.User.UName + "/" + msg.MID + "\" title=\"" + msg.TimestampString + " GMT\">" + formatDate(msg.TimeAgo, msg.TimestampString, locale) + "</a></div>"); out.println(" <div class=\"msg-header\"><a href=\"/" + msg.User.UName + "/\">@" + msg.User.UName + "</a>:" + tags + "</div>"); if (msg.Place != null) { out.println(" <div class=\"msg-place\">" + msg.Place.name + "</div>"); |