aboutsummaryrefslogtreecommitdiff
path: root/src/java/com/juick/http/www/Blogs.java
diff options
context:
space:
mode:
authorGravatar Ugnich Anton2013-02-23 14:51:10 +0700
committerGravatar Ugnich Anton2013-02-23 14:51:10 +0700
commit19cf26ce2f8ee05fc8a9298e2c19b8fff589b8e6 (patch)
tree795b1a6bcdc3946c444709a3e1c68d67a64d5bb9 /src/java/com/juick/http/www/Blogs.java
parentcdbf949013fe140fed0e5ad79ad6111c97ea07ad (diff)
Yandex.Direct
Diffstat (limited to 'src/java/com/juick/http/www/Blogs.java')
-rw-r--r--src/java/com/juick/http/www/Blogs.java62
1 files changed, 31 insertions, 31 deletions
diff --git a/src/java/com/juick/http/www/Blogs.java b/src/java/com/juick/http/www/Blogs.java
index 5acc8947..4f455760 100644
--- a/src/java/com/juick/http/www/Blogs.java
+++ b/src/java/com/juick/http/www/Blogs.java
@@ -41,9 +41,9 @@ import javax.servlet.http.HttpServletResponse;
* @author Ugnich Anton
*/
public class Blogs {
-
+
private int relatedTagsStartMID = 0;
-
+
public Blogs(Connection sql) {
PreparedStatement stmt = null;
ResultSet rs = null;
@@ -59,7 +59,7 @@ public class Blogs {
Utils.finishSQL(rs, stmt);
}
}
-
+
protected void doGet(Connection sql, Connection sqlSearch, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String paramTagStrQuery = request.getParameter("tag");
if (paramTagStrQuery != null) {
@@ -70,18 +70,18 @@ public class Blogs {
}
Utils.sendPermanentRedirect(response, url);
}
-
+
com.juick.User visitor = Utils.getVisitorUser(sql, request);
Locale locale = request.getLocale();
ResourceBundle rb = ResourceBundle.getBundle("Blogs", locale);
-
+
String title;
ArrayList<Integer> mids;
-
+
String paramShow = request.getParameter("show");
-
+
String requesturi = request.getRequestURI();
-
+
int paramTag = 0;
String paramTagStr = null;
if (requesturi.startsWith("/tag/")) {
@@ -94,7 +94,7 @@ public class Blogs {
} else if (requesturi.startsWith("/places/")) {
//TODO перенести сюда блок, который страницей ниже
}
-
+
int paramBefore = 0;
String paramBeforeStr = request.getParameter("before");
if (paramBeforeStr != null) {
@@ -103,15 +103,15 @@ public class Blogs {
} catch (NumberFormatException e) {
}
}
-
+
String paramSearch = request.getParameter("search");
if (paramSearch != null && paramSearch.length() > 64) {
paramSearch = null;
}
-
+
com.juick.Place place = null;
int visitor_uid = visitor != null ? visitor.UID : 0;
-
+
if (paramShow == null) {
if (paramTag > 0) {
title = "*" + Utils.encodeHTML(paramTagStr);
@@ -179,27 +179,27 @@ public class Blogs {
response.sendError(404);
return;
}
-
+
response.setContentType("text/html; charset=UTF-8");
PrintWriter out = response.getWriter();
try {
PageTemplates.pageHead(out, title, null);
PageTemplates.pageNavigation(out, locale, visitor, paramSearch);
-
+
out.println("<div id=\"topwrapper\">");
out.println("<div id=\"wrapper\">");
out.println("<div id=\"content\">");
-
+
if (place != null) {
out.println("<div id=\"geomap\"><img src=\"http://maps.google.com/maps/api/staticmap?center=" + place.lat + "," + place.lon + "&amp;markers=color:orange|" + place.lat + "," + place.lon + "&amp;zoom=14&amp;size=600x300&amp;maptype=hybrid&amp;sensor=false\" width=\"600\" height=\"300\" alt=\"Map\"/></div>");
}
-
+
if (mids.size() > 0) {
out.println("<ul>");
- PageTemplates.printMessages(out, sql, null, mids, visitor, locale);
+ PageTemplates.printMessages(out, sql, null, mids, visitor, locale, visitor == null ? 2 : 3);
out.println("</ul>");
}
-
+
if (mids.size() == 20) {
String nextpage = "?before=" + mids.get(mids.size() - 1);
if (paramShow != null) {
@@ -214,7 +214,7 @@ public class Blogs {
out.println("</div>");
out.println("</div>"); // wrapper
-
+
out.println("<div id=\"column\" class=\"abs\">");
if (visitor != null) {
out.println(" <ul>");
@@ -233,9 +233,9 @@ public class Blogs {
out.println(" <hr/>");
out.println(" <p>" + getTags(sql, 40) + "</p>");
out.println("</div>");
-
+
out.println("<div id=\"rcol\" class=\"abs\">");
- PageTemplates.pageYandexAd(out, visitor == null ? 2 : 3); // разный ID для залогиненых и нет
+ //PageTemplates.pageYandexAd(out, visitor == null ? 2 : 3); // разный ID для залогиненых и нет
if (paramTag > 0 && relatedTagsStartMID > 0) {
String related = getRelatedTags(sql, paramTag, 15);
if (!related.isEmpty()) {
@@ -244,7 +244,7 @@ public class Blogs {
}
}
out.println("</div>");
-
+
out.println("</div>"); // topwrapper
PageTemplates.pageDialogTemplate(out, locale);
@@ -253,11 +253,11 @@ public class Blogs {
out.close();
}
}
-
+
private String getTags(Connection sql, int cnt) {
String ret = "";
com.juick.Tag tags[] = new com.juick.Tag[cnt];
-
+
int maxUsageCnt = 0;
PreparedStatement stmt = null;
ResultSet rs = null;
@@ -281,16 +281,16 @@ public class Blogs {
} finally {
Utils.finishSQL(rs, stmt);
}
-
+
Arrays.sort(tags, 0, cnt);
-
+
for (int i = 0; i < cnt; i++) {
String tag = Utils.encodeHTML(tags[i].Name);
try {
tag = "<a href=\"/tag/" + URLEncoder.encode(tags[i].Name, "UTF-8") + "\">" + tag + "</a>";
} catch (UnsupportedEncodingException e) {
}
-
+
if (tags[i].UsageCnt > maxUsageCnt / 3 * 2) {
ret += "<big>" + tag + "</big> ";
} else if (tags[i].UsageCnt > maxUsageCnt / 3) {
@@ -299,13 +299,13 @@ public class Blogs {
ret += tag + " ";
}
}
-
+
return ret;
}
-
+
private String getRelatedTags(Connection sql, int tag_id, int cnt) {
String ret = "";
-
+
PreparedStatement stmt = null;
ResultSet rs = null;
try {
@@ -325,7 +325,7 @@ public class Blogs {
} finally {
Utils.finishSQL(rs, stmt);
}
-
+
return ret;
}
}