From c49e78bef068f4c4607d6d572366661e40b404be Mon Sep 17 00:00:00 2001 From: Ugnich Anton Date: Tue, 16 Oct 2012 17:31:27 +0700 Subject: blog title --- src/java/com/juick/http/www/Blogs.java | 35 ++++++------ src/java/com/juick/http/www/PageTemplates.java | 74 +++----------------------- src/java/com/juick/http/www/Tags.java | 2 +- src/java/com/juick/http/www/User.java | 40 +++++++++----- 4 files changed, 52 insertions(+), 99 deletions(-) (limited to 'src/java/com/juick/http') diff --git a/src/java/com/juick/http/www/Blogs.java b/src/java/com/juick/http/www/Blogs.java index ea728eab..e43addb9 100644 --- a/src/java/com/juick/http/www/Blogs.java +++ b/src/java/com/juick/http/www/Blogs.java @@ -154,10 +154,10 @@ public class Blogs { if (mids.size() == 20) { String nextpage = "?before=" + mids.get(mids.size() - 1); if (paramShow != null) { - nextpage += "&show=" + paramShow; + nextpage += "&show=" + paramShow; } if (paramTag > 0) { - nextpage += "&tag=" + URLEncoder.encode(paramTagStr, "UTF-8"); + nextpage += "&tag=" + URLEncoder.encode(paramTagStr, "UTF-8"); } out.println("

Older →

"); } @@ -167,23 +167,22 @@ public class Blogs { out.println("
"); - out.println("

" + rb.getString("Lists") + "

"); if (visitor != null) { - out.println(""); - out.println("
"); + out.println(" "); + out.println("
"); } - out.println(""); - out.println("
"); - out.println("

" + getTags(sql, 30) + "

"); + out.println(" "); + out.println("
"); + out.println("

" + getTags(sql, 30) + "

"); out.println("
"); out.println("
"); @@ -204,7 +203,7 @@ public class Blogs { PreparedStatement stmt = null; ResultSet rs = null; try { - stmt = sql.prepareStatement("SELECT tags.name AS name,COUNT(DISTINCT messages.user_id) AS cnt FROM (messages INNER JOIN messages_tags ON (messages.ts>TIMESTAMPADD(DAY,-3,NOW()) AND messages.message_id=messages_tags.message_id)) INNER JOIN tags ON messages_tags.tag_id=tags.tag_id GROUP BY tags.tag_id ORDER BY cnt DESC LIMIT ?"); + stmt = sql.prepareStatement("SELECT tags.name AS name,COUNT(DISTINCT messages.user_id) AS cnt FROM (messages INNER JOIN messages_tags ON (messages.ts>TIMESTAMPADD(DAY,-3,NOW()) AND messages.message_id=messages_tags.message_id)) INNER JOIN tags ON messages_tags.tag_id=tags.tag_id WHERE tags.tag_id NOT IN (SELECT tag_id FROM tags_ignore) GROUP BY tags.tag_id ORDER BY cnt DESC LIMIT ?"); stmt.setInt(1, cnt); rs = stmt.executeQuery(); rs.beforeFirst(); diff --git a/src/java/com/juick/http/www/PageTemplates.java b/src/java/com/juick/http/www/PageTemplates.java index 922bc922..a38b90f8 100644 --- a/src/java/com/juick/http/www/PageTemplates.java +++ b/src/java/com/juick/http/www/PageTemplates.java @@ -17,6 +17,7 @@ */ package com.juick.http.www; +import com.juick.server.UserQueries; import java.io.PrintWriter; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; @@ -56,7 +57,6 @@ public class PageTemplates { out.println(" "); out.println(" "); out.println(" "); - out.println(" "); out.println(" "); out.println(" "); out.println(" "); @@ -135,73 +135,13 @@ public class PageTemplates { description = ""; } - // I read - int iread = 0; - try { - stmt = sql.prepareStatement("SELECT COUNT(*) FROM subscr_users WHERE suser_id=?"); - stmt.setInt(1, user.UID); - rs = stmt.executeQuery(); - if (rs.first()) { - iread = rs.getInt(1); - } - } catch (SQLException e) { - System.err.println(e); - } finally { - Utils.finishSQL(rs, stmt); - } - - // My readers - int myreaders = 0; - try { - stmt = sql.prepareStatement("SELECT COUNT(*) FROM subscr_users WHERE user_id=?"); - stmt.setInt(1, user.UID); - rs = stmt.executeQuery(); - if (rs.first()) { - myreaders = rs.getInt(1); - } - } catch (SQLException e) { - System.err.println(e); - } finally { - Utils.finishSQL(rs, stmt); - } - - // Messages - int messages = 0; - try { - stmt = sql.prepareStatement("SELECT COUNT(*) FROM messages WHERE user_id=?"); - stmt.setInt(1, user.UID); - rs = stmt.executeQuery(); - if (rs.first()) { - messages = rs.getInt(1); - } - } catch (SQLException e) { - System.err.println(e); - } finally { - Utils.finishSQL(rs, stmt); - } - - // Replies - int replies = 0; - try { - stmt = sql.prepareStatement("SELECT COUNT(*) FROM replies WHERE user_id=?"); - stmt.setInt(1, user.UID); - rs = stmt.executeQuery(); - if (rs.first()) { - replies = rs.getInt(1); - } - } catch (SQLException e) { - System.err.println(e); - } finally { - Utils.finishSQL(rs, stmt); - } - out.println("
"); out.println("
\""
"); out.println("
"); out.println("

" + fullname + "

" + description + "

"); out.println("
"); @@ -407,7 +347,7 @@ public class PageTemplates { out.println("
" + formatReplies(rs.getInt(10), locale) + " " + rb.getString("(replies) by") + " " + repliesby + "
"); } else if (cancomment) { out.println("
"); - out.println("
"); + out.println("
"); out.println("
"); } out.println(" "); @@ -417,7 +357,7 @@ public class PageTemplates { } finally { Utils.finishSQL(rs, stmt); } - } + } /* public static void printPhotos(PrintWriter out, Connection sql, ArrayList mids, Locale locale) { ResourceBundle rb = ResourceBundle.getBundle("Global", locale); diff --git a/src/java/com/juick/http/www/Tags.java b/src/java/com/juick/http/www/Tags.java index 07cff582..534ca8ef 100644 --- a/src/java/com/juick/http/www/Tags.java +++ b/src/java/com/juick/http/www/Tags.java @@ -41,7 +41,7 @@ public class Tags { PreparedStatement stmt = null; ResultSet rs = null; try { - stmt = sql.prepareStatement("SELECT tags.name AS name,COUNT(DISTINCT messages.user_id) AS cnt FROM (messages INNER JOIN messages_tags ON (messages.ts>TIMESTAMPADD(DAY,-3,NOW()) AND messages.message_id=messages_tags.message_id)) INNER JOIN tags ON messages_tags.tag_id=tags.tag_id GROUP BY tags.tag_id ORDER BY cnt DESC LIMIT ?"); + stmt = sql.prepareStatement("SELECT tags.name AS name,COUNT(DISTINCT messages.user_id) AS cnt FROM (messages INNER JOIN messages_tags ON (messages.ts>TIMESTAMPADD(DAY,-3,NOW()) AND messages.message_id=messages_tags.message_id)) INNER JOIN tags ON messages_tags.tag_id=tags.tag_id WHERE tags.tag_id NOT IN (SELECT tag_id FROM tags_ignore) GROUP BY tags.tag_id ORDER BY cnt DESC LIMIT ?"); stmt.setInt(1, cnt); rs = stmt.executeQuery(); rs.beforeFirst(); diff --git a/src/java/com/juick/http/www/User.java b/src/java/com/juick/http/www/User.java index 0ddac42d..a1a6029c 100644 --- a/src/java/com/juick/http/www/User.java +++ b/src/java/com/juick/http/www/User.java @@ -19,6 +19,7 @@ package com.juick.http.www; import com.juick.server.MessagesQueries; import com.juick.server.TagQueries; +import com.juick.server.UserQueries; import java.io.IOException; import java.io.PrintWriter; import java.io.UnsupportedEncodingException; @@ -98,7 +99,7 @@ public class User { try { PageTemplates.pageHead(out, title, null); PageTemplates.pageNavigation(out, locale, visitor); - PageTemplates.pageUserTitle(out, sql, locale, user, visitor); + //PageTemplates.pageUserTitle(out, sql, locale, user, visitor); out.println("
"); out.println("
"); @@ -112,10 +113,10 @@ public class User { if (mids.size() == 20) { String nextpage = "?before=" + mids.get(19); if (paramShow != null) { - nextpage += "&show=" + paramShow; + nextpage += "&show=" + paramShow; } if (paramTag > 0) { - nextpage += "&tag=" + URLEncoder.encode(paramTagStr, "UTF-8"); + nextpage += "&tag=" + URLEncoder.encode(paramTagStr, "UTF-8"); } out.println("

Older →

"); } @@ -171,6 +172,7 @@ public class User { PageTemplates.pageNavigation(out, locale, visitor); PageTemplates.pageUserTitle(out, sql, locale, user, visitor); + out.println("
"); out.println("
"); out.println("
"); out.println(""); @@ -200,6 +202,7 @@ public class User { out.println(""); pageUserColumn(out, sql, user, visitor, locale); out.println(""); + out.println(""); PageTemplates.pageFooter(request, out, locale, visitor); } finally { @@ -219,6 +222,7 @@ public class User { PageTemplates.pageNavigation(out, locale, visitor); //PageTemplates.pageUserTitle(out, sql, locale, user, visitor); + out.println("
"); out.println("
"); out.println("
"); out.println("
"); @@ -248,6 +252,7 @@ public class User { out.println(""); pageUserColumn(out, sql, user, visitor, locale); out.println(""); + out.println(""); PageTemplates.pageFooter(request, out, locale, visitor); } finally { @@ -259,16 +264,25 @@ public class User { ResourceBundle rb = ResourceBundle.getBundle("User", locale); out.println("
"); - out.println(""); - out.println("
"); - out.println("

" + pageUserTags(sql, user, visitor, 15) + "

"); - out.println("
"); - out.println("

"); - out.println(""); + out.println(" "); + out.println("
"); + out.println(" "); + out.println("
"); + out.println("
"); + out.println("

"); + out.println(" "); + out.println("

" + pageUserTags(sql, user, visitor, 15) + "

"); + out.println("
"); + out.println("
"); out.println("
"); } -- cgit v1.2.3