aboutsummaryrefslogtreecommitdiff
path: root/src/java/com/juick/http/www/PageTemplates.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/com/juick/http/www/PageTemplates.java')
-rw-r--r--src/java/com/juick/http/www/PageTemplates.java134
1 files changed, 104 insertions, 30 deletions
diff --git a/src/java/com/juick/http/www/PageTemplates.java b/src/java/com/juick/http/www/PageTemplates.java
index a76e0280..08e88342 100644
--- a/src/java/com/juick/http/www/PageTemplates.java
+++ b/src/java/com/juick/http/www/PageTemplates.java
@@ -24,7 +24,11 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
import java.util.Locale;
import java.util.ResourceBundle;
import java.util.regex.Matcher;
@@ -39,6 +43,9 @@ import ru.sape.Sape;
public class PageTemplates {
public static Sape sape = null;
+ 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");
public static void pageHead(PrintWriter out, String title, String headers) {
out.println("<!DOCTYPE html>");
@@ -46,10 +53,10 @@ public class PageTemplates {
out.println("<head>");
out.println(" <meta charset=\"utf-8\"/>");
out.println(" <title>" + title + "</title>");
- out.println(" <link rel=\"stylesheet\" href=\"http://static.juick.com/style3.css?20120306\"/>");
+ out.println(" <link rel=\"stylesheet\" href=\"http://static.juick.com/style3.css?2012030601\"/>");
out.println(" <link rel=\"icon\" type=\"image/png\" href=\"http://static.juick.com/favicon.png\"/>");
- out.println(" <script type=\"text/javascript\" src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js\"></script>");
- out.println(" <script type=\"text/javascript\" src=\"https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js\"></script>");
+ out.println(" <script type=\"text/javascript\" src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js\"></script>");
+ out.println(" <script type=\"text/javascript\" src=\"https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.24/jquery-ui.min.js\"></script>");
out.println(" <script type=\"text/javascript\" src=\"https://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js\"></script>");
out.println(" <script type=\"text/javascript\" src=\"http://static.juick.com/scripts3.js?20120306\"></script>");
out.println(" <script type=\"text/javascript\" src=\"http://static.juick.com/js/jquery.autoresize.js\"></script>");
@@ -63,18 +70,16 @@ public class PageTemplates {
public static void pageNavigation(PrintWriter out, Locale loc, com.juick.User user) {
ResourceBundle rb = ResourceBundle.getBundle("Global", loc);
+ out.println("<div id=\"hwrapper\">");
out.println("<div id=\"header\">");
- out.println("<div id=\"logo\"><a href=\"" + (user != null ? "/?show=my" : "/") + "\"><img src=\"http://static.juick.com/logo3.png\" width=\"120\" height=\"40\" alt=\"Juick\"/></a></div>");
- out.println(" <ul id=\"nav\">");
- out.println(" <li><a href=\"/\">" + rb.getString("Blogs") + "</a></li>");
-// out.println(" <li><a href=\"/chats\">" + rb.getString("Chats") + "</a></li>");
- out.println(" <li><a href=\"/photos\">" + rb.getString("Photos") + "</a></li>");
- out.println(" <li><a href=\"/map\">" + rb.getString("Map") + "</a></li>");
- out.println(" </ul>");
+ out.println(" <div id=\"logo\"><a href=\"" + (user != null ? "/?show=my" : "/") + "\"><img src=\"http://static.juick.com/logo3.png\" width=\"120\" height=\"40\" alt=\"Juick\"/></a></div>");
+ out.println(" <form action=\"/\" id=\"search\">");
+ out.println(" <div id=\"search\"><input type=\"text\" name=\"search\" class=\"text\" placeholder=\"" + rb.getString("Search") + "\"/><input type=\"submit\" class=\"submit\" value=\">\"></div>");
+ 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('blind'); return false\"><img src=\"http://i.juick.com/as/" + user.UID + ".png\" alt=\"" + user.UName + "\"/>" + user.UName + "</a><ul id=\"nav-menu\">");
+ out.println(" <li><a href=\"#\" onclick=\"$('#nav-menu').toggle(); return false\"><img src=\"http://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>");
@@ -84,11 +89,21 @@ public class PageTemplates {
}
out.println(" </ul>");
out.println("</div>");
+ out.println("</div>");
}
- public static void pageTitle(PrintWriter out, String title) {
- out.println("<div id=\"title\">");
- out.println(" <h1>" + title + "</h1>");
+ public static void pageFilters(PrintWriter out, Locale loc, com.juick.User user) {
+ ResourceBundle rb = ResourceBundle.getBundle("Global", loc);
+
+ out.println("<div id=\"filters\">");
+ out.println("<ul>");
+ out.println(" <li><a href=\"#\">Messages</a></li>");
+ out.println(" <li><a href=\"#\">Photos</a></li>");
+ out.println(" <li><a href=\"#\">Recommendations</a></li>");
+ out.println(" <li><a href=\"#\">Private</a></li>");
+ out.println(" <li><a href=\"#\">Tags</a></li>");
+ out.println(" <li><a href=\"#\">Users</a></li>");
+ out.println("</ul>");
out.println("</div>");
}
@@ -236,7 +251,19 @@ public class PageTemplates {
int days = (minsago / 1440);
return days + " day" + ((days % 10 == 1) ? "" : "s") + " ago";
} else {
- return fulldate;
+ try {
+ Date pDate = sdfSQL.parse(fulldate);
+ Calendar c = Calendar.getInstance();
+ int curyear = c.get(Calendar.YEAR);
+ c.setTime(pDate);
+ if (c.get(Calendar.YEAR) == curyear) {
+ return sdfSimple.format(pDate);
+ } else {
+ return sdfFull.format(pDate);
+ }
+ } catch (ParseException e) {
+ return fulldate;
+ }
}
}
@@ -355,11 +382,11 @@ public class PageTemplates {
txt = formatMessage(txt);
- out.print(" <li id=\"msg-" + mid + "\" class=\"msg\"");
- if (mid == mids.get(0)) {
- out.print(" style=\"border: 0\"");
- }
- out.println(">");
+ out.println(" <li id=\"msg-" + mid + "\" class=\"msg\">");
+ out.println(" <div class=\"msg-avatar\"><a href=\"/" + uname + "/\"><img src=\"http://i.juick.com/a/" + uid + ".png\" alt=\"" + uname + "\"/></a></div>");
+ out.println(" <div class=\"msg-ts\"><a href=\"/" + uname + "/" + mid + "\" title=\"" + rs.getString(9) + "\">" + formatDate(rs.getInt(8), rs.getString(9), locale) + "</a></div>");
+ out.println(" <div class=\"msg-header\"><a href=\"/" + uname + "/\">@" + uname + "</a>:" + tags + "</div>");
+ out.println(" <div class=\"msg-txt\">" + txt + "</div>");
if (rs.getString(12) != null) {
if (rs.getString(12).equals("jpg")) {
@@ -372,15 +399,6 @@ public class PageTemplates {
}
}
- out.println(" <div class=\"msg-avatar\"><a href=\"/" + uname + "/\"><img src=\"http://i.juick.com/a/" + uid + ".png\" alt=\"" + uname + "\"/></a></div>");
- out.println(" <div class=\"msg-ts\"><a href=\"/" + uname + "/" + mid + "\">" + formatDate(rs.getInt(8), rs.getString(9), locale) + "</a><div class=\"msg-menu\"><a href=\"#\" onclick=\"$('#msg-menu-" + mid + "').toggle('blind'); return false\"><img src=\"http://static.juick.com/message-menu-icon.png\"></a><ul id=\"msg-menu-" + mid + "\">");
- out.println(" <li><a href=\"/post?body=%21%20%23" + mid + "\">" + rb.getString("Recommend message") + "</a></li>");
- out.println(" <li><a href=\"/post?body=%40" + uname + "%20\">" + rb.getString("Send private message") + "</a></li>");
- out.println(" <li><a href=\"/post?body=BL%20%40" + uname + "\">" + rb.getString("Block user") + "</a></li>");
- out.println(" </ul></div></div>");
- out.println(" <div class=\"msg-header\"><a href=\"/" + uname + "/\">@" + uname + "</a>:" + tags + "</div>");
- out.println(" <div class=\"msg-txt\">" + txt + "</div>");
-
if (rs.getInt(10) > 0) {
String repliesby = rs.getString(11);
if (repliesby == null) {
@@ -389,7 +407,7 @@ public class PageTemplates {
out.println(" <div class=\"msg-comments\"><a href=\"/" + uname + "/" + mid + "\">" + formatReplies(rs.getInt(10), locale) + "</a> " + rb.getString("(replies) by") + " " + repliesby + "</div>");
} else if (cancomment) {
out.println(" <form action=\"/post\" method=\"POST\" enctype=\"multipart/form-data\"><input type=\"hidden\" name=\"mid\" value=\"" + mid + "\"/>");
- out.println(" <div class=\"msg-comment\"><textarea name=\"body\" rows=\"1\" class=\"reply\" placeholder=\"Add a comment...\" onkeypress=\"postformListener(this.form,event)\"></textarea><input type=\"submit\" value=\"OK\"/></div>");
+ out.println(" <div class=\"msg-comment\"><textarea name=\"body\" rows=\"1\" class=\"reply\" placeholder=\"Add a comment...\" onkeypress=\"postformListener(this.form,event)\"></textarea></div>");
out.println(" </form>");
}
out.println(" </li>");
@@ -400,4 +418,60 @@ public class PageTemplates {
Utils.finishSQL(rs, stmt);
}
}
+ /*
+ public static void printPhotos(PrintWriter out, Connection sql, ArrayList<Integer> mids, Locale locale) {
+ ResourceBundle rb = ResourceBundle.getBundle("Global", locale);
+
+ out.println("<table class=\"photos\">");
+ out.println(" <tr>");
+
+ PreparedStatement stmt = null;
+ ResultSet rs = null;
+ try {
+ stmt = sql.prepareStatement("SELECT STRAIGHT_JOIN messages.message_id,messages.user_id,users.nick,messages_txt.tags,messages.readonly,messages.privacy,messages_txt.txt,TIMESTAMPDIFF(MINUTE,messages.ts,NOW()),messages.ts,messages.replies,messages_txt.repliesby,messages.attach,messages.place_id,places.name,messages.lat,messages.lon FROM ((messages INNER JOIN messages_txt ON messages.message_id=messages_txt.message_id) INNER JOIN users ON messages.user_id=users.id) LEFT JOIN places ON messages.place_id=places.place_id WHERE messages.message_id IN (" + Utils.convertArray2String(mids) + ") ORDER BY messages.message_id DESC");
+ rs = stmt.executeQuery();
+ rs.beforeFirst();
+ int cnt = 0;
+ while (rs.next()) {
+ int mid = rs.getInt(1);
+ int uid = rs.getInt(2);
+ String uname = rs.getString(3);
+ String tags = rs.getString(4);
+ String txt = rs.getString(7);
+
+ txt = formatMessage(txt);
+
+ if (cnt % 2 == 0 && cnt > 0) {
+ out.println(" </tr>");
+ out.println(" <tr>");
+ }
+
+ out.print(" <td id=\"photo-" + mid + "\" class=\"photo\"");
+ if (mid == mids.get(0)) {
+ out.print(" style=\"border: 0\"");
+ }
+ out.print(">");
+
+ out.println("<div class=\"photowrap\">");
+ out.println(" <a href=\"#\" onclick=\"return photoDetails(" + mid + ")\"><img src=\"http://i.juick.com/" + (rs.getString(12).equals("jpg") ? "photos-512" : "thumbs") + "/" + mid + ".jpg\" alt=\"\"/></a>");
+ out.println(" <div class=\"photo-ts\" title=\"" + rs.getString(9) + "\">" + formatDate(rs.getInt(8), rs.getString(9), locale) + "</div>");
+ out.println(" <div class=\"photo-uname\">@" + uname + "</div>");
+ if (rs.getInt(10) > 0) {
+ out.println(" <div class=\"photo-comments\">" + rs.getInt(10) + "</div>");
+ }
+ out.println(" <div class=\"photo-txt\">" + txt + "</div>");
+ out.println(" </td>");
+
+ cnt++;
+ }
+ } catch (SQLException e) {
+ System.err.println(e);
+ } finally {
+ Utils.finishSQL(rs, stmt);
+ }
+
+ out.println(" </tr>");
+ out.println("</table>");
+ }
+ */
}